| name | api-tools |
| description | API testing, documentation, and development tools |
| domain | tools-integrations |
| version | 1.0.0 |
| tags | ["postman","insomnia","swagger","openapi","curl","httpie"] |
| triggers | {"keywords":{"primary":["postman","insomnia","curl","httpie","swagger","openapi"],"secondary":["api test","request","response","collection","mock server","bruno"]},"context_boost":["api","endpoint","http","rest"],"context_penalty":["frontend","ui","design"],"priority":"medium"} |
API Tools
Overview
Tools and techniques for API development, testing, documentation, and debugging.
HTTP Clients
cURL
curl https://api.example.com/users
curl -H "Authorization: Bearer TOKEN" \
-H "Accept: application/json" \
https://api.example.com/users
curl -X POST \
-H "Content-Type: application/json" \
-d '{"name": "John", "email": "john@example.com"}' \
https://api.example.com/users
curl -X POST \
-F "file=@document.pdf" \
-F "name=My Document" \
https://api.example.com/upload
curl -X PUT \
-H "Content-Type: application/json" \
-d '{"name": "Updated Name"}' \
https://api.example.com/users/123
curl -X DELETE https://api.example.com/users/123
curl -i https://api.example.com/users
curl -v https://api.example.com/users
curl -L https://example.com/redirect
curl -o response.json https://api.example.com/users
curl -u username:password https://api.example.com/protected
curl --oauth2-bearer TOKEN https://api.example.com/protected
curl -w "@curl-format.txt" -o /dev/null -s https://api.example.com
# curl-format.txt
time_namelookup: %{time_namelookup}s\n
time_connect: %{time_connect}s\n
time_appconnect: %{time_appconnect}s\n
time_pretransfer: %{time_pretransfer}s\n
time_redirect: %{time_redirect}s\n
time_starttransfer: %{time_starttransfer}s\n
----------\n
time_total: %{time_total}s\n
HTTPie
http https://api.example.com/users
http https://api.example.com/users \
Authorization:"Bearer TOKEN" \
Accept:application/json
http POST https://api.example.com/users \
name=John \
email=john@example.com
http POST https://api.example.com/users \
< user.json
http -f POST https://api.example.com/login \
username=john \
password=secret
http -f POST https://api.example.com/upload \
file@document.pdf
http --download https://api.example.com/files/document.pdf
http --session=user-session POST https://api.example.com/login
http --session=user-session GET https://api.example.com/profile
http --headers https://api.example.com/users
http --body https://api.example.com/users
API Testing
Postman Collections
{
"info": {
"name": "User API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"variable": [
{
"key": "baseUrl",
"value": "https://api.example.com"
},
{
"key": "token",
"value": ""
}
],
"item": [
{
"name": "Auth",
"item": [
{
"name": "Login",
"request": {
"method"
Newman CLI
newman run collection.json
newman run collection.json -e environment.json
newman run collection.json \
--reporters cli,html \
--reporter-html-export report.html
newman run collection.json --folder "Users"
newman run collection.json -d data.json -n 10
newman run collection.json \
--env-var "baseUrl=https://staging.api.example.com" \
--env-var "token=xxx"
OpenAPI / Swagger
OpenAPI Specification
openapi: 3.0.3
info:
title: User API
description: API for managing users
version: 1.0.0
contact:
email: api@example.com
license:
name: MIT
servers:
- url: https://api.example.com/v1
description: Production
- url: https://staging-api.example.com/v1
description: Staging
tags:
- name: Users
description: User management operations
- name: Auth
description: Authentication operations
paths:
/users:
get:
summary: List users
description: Returns a paginated
[]
[]
[]
[, ]
Generate Client SDK
npx openapi-generator-cli generate \
-i openapi.yaml \
-g typescript-fetch \
-o ./generated/client
openapi-generator generate \
-i openapi.yaml \
-g python \
-o ./generated/python-client
Mock Servers
Prism (OpenAPI Mock Server)
npx @stoplight/prism-cli mock openapi.yaml
npx @stoplight/prism-cli mock openapi.yaml --dynamic
npx @stoplight/prism-cli mock openapi.yaml -p 4010
JSON Server (Quick REST API)
{
"users": [
{ "id": 1, "name": "John", "email": "john@example.com" },
{ "id": 2, "name": "Jane", "email": "jane@example.com" }
],
"posts": [
{ "id": 1, "title": "Hello World", "userId": 1 }
]
}
npx json-server --watch db.json --port 3001
API Debugging
Request/Response Logging
import axios from 'axios';
axios.interceptors.request.use((config) => {
console.log('Request:', {
method: config.method?.toUpperCase(),
url: config.url,
params: config.params,
data: config.data,
headers: config.headers,
});
return config;
});
axios.interceptors.response.use(
(response) => {
console.log('Response:', {
status: response.status,
headers: response.headers,
data: response.data,
});
return response;
},
(error) => {
console.log('Error:', {
status: error.response?.status,
data: error.response?.data,
});
.(error);
}
);
Related Skills
- [[api-design]] - API design patterns
- [[testing-strategies]] - API testing
- [[backend]] - Backend development