
Product
Introducing Socket MCP for Claude Desktop
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
@single9/api-tester
Advanced tools
A RESTful API tester
npm i @single9/api-tester
const ApiTester = require('@single9/api-tester');
const api = new ApiTester([
{
name: '<Api Name>', // only allow certain words and digits
path: '<Api Path>', // e.g. /api/posts
method: '<HTTP Method>', // e.g. post
},
], {
rootUrl: '<API root URL>' // e.g. https://jsonplaceholder.typicode.com
// Default: http://localhost:3000
showResult: true, // set false to disable results console log
headers: {
// The headers you want to send. e.g. 'authorization': 'Bearer SAdoweasd...',
},
auth: { // authorization
username: 'username',
password: 'password',
}
})
ApiTester.<your_api_name>(params)
Used for query string. e.g. /users?limit=100
api.test({
queryString: {
key: value
}
})
api.test({
queryString: [
{
name: string,
value: string | number,
}
]
})
Used for path parameters. e.g. /user/:id
api.test({
pathParams: {
key: value
}
})
api.test({
pathParams: [
{
name: string,
value: string | number,
}
]
})
Used for request body.
api.test({
body: {
key: value
}
})
Used for upload files.
api.test({
uploads: [
{
fieldName: '<form feild name>',
path: '<file path>'
filename?: '<file name>',
}
]
})
Do some test after responded.
api.test({
tester: function (res) {
assert(res === string);
}
})
const api = new ApiTester([
{
name: 'getPosts',
path: '/api/posts',
method: 'get',
},
], {
showResult: true // set false to disable results console log
});
api.getPosts()
.then(result => console.log(result))
.catch(err => console.error(err))
ApiTester.Apis.<ApiName>({
uploads: [
fieldName: '<Form Field Name>',
path: '<File Path>',
filename: '<File Name>',
]
})
const path = require('path');
const api = new ApiTester([
{
name: 'uploadFile',
path: '/api/upload',
method: 'post',
},
], {
showResult: true // set false to disable results console log
});
const filePath = path.join(__dirname, 'image.jpg'),
api.uploadFile({
uploads: [
fieldName: 'file',
path: filePath,
filename: path.basename(filePath),
]
})
.then(result => console.log(result))
.catch(err => console.error(err))
const assert = require('assert').strict;
const ApiTester = require('@single9/api-tester');
// Create your API schema
const schema = [
{
name: 'newPost', // this is your api function name
path: '/posts',
method: 'post',
},
{
name: 'getTodo',
path: '/todos/:todoId', // path parameter
method: 'get',
},
];
const api = new ApiTester(schema, {
rootUrl: 'https://jsonplaceholder.typicode.com',
showResult: true
});
async function start() {
try {
await api.newPost({
// Post Body
body: {
title: 'foo!!!!!!',
body: 'bar!!',
userId: 1
},
// Tester
tester: function(resp) {
assert.equal(typeof(resp.id), 'number');
}
});
await api.getTodo({
pathParams: [{
name: 'todoId', // replace `:todoId` in path
value: 2
}],
tester: function(resp) {
assert.equal(typeof(resp.title), 'string');
}
});
} catch (err) {
console.error(err);
}
}
start();
FAQs
Api Tester
The npm package @single9/api-tester receives a total of 1 weekly downloads. As such, @single9/api-tester popularity was classified as not popular.
We found that @single9/api-tester demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.