
api-plugin
Skill-based HTTP API testing plugin for Supertest, httpx, and pytest, with contract-testing setup delegated elsewhere.
- version
- 2.0.1
- GitHub stars
- 60
Own this plugin? Claim it
What it does
- Adds the
api-testingskill for HTTP API tests with Supertest (TypeScript) and httpx with pytest (Python) - Covers request, response, authentication, error handling, file upload, GraphQL, and database integration tests
- Recommends per-test database resets and transactions that roll back, keeping tests isolated from one another
- Designed for teams testing REST endpoints in Express, Vitest, FastAPI, or pytest projects
API integration and testing - REST endpoints, client generation
Add marketplace
/plugin marketplace add laurigates/claude-pluginsRun it inside Claude Code once, then install the plugin below.
Install
/plugin install api-plugin@laurigates-claude-pluginsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceAPI Testing
Expert knowledge for testing HTTP APIs with Supertest (TypeScript/JavaScript) and httpx/pytest (Python).
When to Use This Skill
| Use this skill when... | Use configure-plugin:configure-api-tests instead when... |
|---|---|
| Writing Supertest endpoint tests against an Express/Fastify app | Setting up Pact consumer/provider contract testing infrastructure |
| Writing httpx + pytest tests for a Python REST/GraphQL API | Validating an OpenAPI specification or wiring schema (Zod/AJV) checks into CI |
| Validating request/response shapes, status codes, and auth flows in test code | Auditing or scaffolding API contract testing tooling for a project |
| Asserting error handling (4xx/5xx) and integration state in functional tests | Adding breaking-change detection workflows to CI |
Core Expertise
API Testing Capabilities
- Request testing: Headers, query params, request bodies
- Response validation: Status codes, headers, JSON schemas
- Authentication: Bearer tokens, cookies, OAuth flows
- Error handling: 4xx/5xx responses, validation errors
- Integration: Database state, external services
- Performance: Response times, load testing basics
TypeScript/JavaScript (Supertest)
Installation
# Using Bun
bun add -d supertest @types/supertest
# Using npm
npm install -D supertest @types/supertest
Basic Setup with Express
// app.ts
import express from 'express'
export const app = express()
app.use(express.json())
app.get('/api/health', (req, res) => {
res.json({ status: 'ok' })
})
app.post('/api/users', (req, res) => {
const { name, email } = req.body
if (!name || !email) {
return res.status(400).json({ error: 'Missing required fields' })
}
res.status(201).json({ id: 1, name, email })
})
// app.test.ts
import { describe, it, expect } from 'vitest'
import request from 'supertest'
import { app } from './app'
describe('API Tests', () => {
it('returns health status', async () => {
const response = await request(app)
.get('/api/health')
.expect(200)
expect(response.body).toEqual({ status: 'ok' })
})
it('creates a user', async () => {
const response = await request(app)
.post('/api/users')
.send({ name: 'John Doe', email: 'john@example.com' })
.expect(201)
expect(response.body).toMatchObject({
id: expect.any(Number),
name: 'John Doe',
email: 'john@example.com',
})
})
it('validates required fields', async () => {
const response = await request(app)
.post('/api/users')
.send({ name: 'John Doe' })
.expect(400)
expect(response.body.error).toBeDefined()
})
})
Request Methods
import request from 'supertest'
import { app } from './app'
// GET request
await request(app).get('/api/users').expect(200)
// POST request with body
await request(app).post('/api/users')
.send({ name: 'John', email: 'john@example.com' }).expect(201)
// PUT request
await request(app).put('/api/users/1')
.send({ name: 'Jane' }).expect(200)
// PATCH request
await request(app).patch('/api/users/1')
.send({ email: 'jane@example.com' }).expect(200)
// DELETE request
await request(app).delete('/api/users/1').expect(204)
Headers and Query Parameters
// Set headers
await request(app)
.get('/api/protected')
.set('Authorization', 'Bearer token123')
.set('Content-Type', 'application/json')
.expect(200)
// Query parameters
await request(app)
.get('/api/users')
.query({ page: 1, limit: 10 })
.expect(200)
Response Assertions
describe('Response validation', () => {
it('validates status code', async () => {
await request(app).get('/api/users').expect(200)
})
it('validates headers', async () => {
await request(app).get('/api/users')
.expect('Content-Type', /json/).expect(200)
})
it('validates response body', async () => {
const response = await request(app).get('/api/users/1').expect(200)
expect(response.body).toEqual({
id: 1,
name: 'John Doe',
email: 'john@example.com',
createdAt: expect.any(String),
})
})
it('validates array responses', async () => {
const response = await request(app).get('/api/users').expect(200)
expect(response.body).toBeInstanceOf(Array)
expect(response.body).toHaveLength(5)
expect(response.body[0]).toHaveProperty('id')
})
})
Python (httpx + pytest)
Installation
# Using uv
uv add --dev httpx pytest-asyncio
# Using pip
pip install httpx pytest-asyncio
Basic Setup with FastAPI
# main.py
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
app = FastAPI()
class User(BaseModel):
name: str
email: str
@app.get("/api/health")
def health_check():
return {"status": "ok"}
@app.post("/api/users", status_code=201)
def create_user(user: User):
return {"id": 1, "name": user.name, "email": user.email}
@app.get("/api/users/{user_id}")
def get_user(user_id: int):
if user_id == 999:
raise HTTPException(status_code=404, detail="User not found")
return {"id": user_id, "name": "John Doe", "email": "john@example.com"}
# test_main.py
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def test_health_check():
response = client.get("/api/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
def test_create_user():
response = client.post(
"/api/users",
json={"name": "John Doe", "email": "john@example.com"}
)
assert response.status_code == 201
data = response.json()
assert data["name"] == "John Doe"
assert "id" in data
def test_validation_error():
response = client.post("/api/users", json={"name": "John"})
assert response.status_code == 422 # FastAPI validation error
def test_not_found():
response = client.get("/api/users/999")
assert response.status_code == 404
For detailed examples including authentication testing, file uploads, cookie testing, database integration, schema validation, GraphQL testing, performance testing, best practices, and troubleshooting, see REFERENCE.md.
Agentic Optimizations
| Context | Command |
|---|---|
| Quick test (Bun) | bun test --dots --bail=1 api |
| Quick test (pytest) | pytest -x --tb=short tests/api/ |
| Run single test file | bun test --dots path/to/test.ts |
| Verbose on failure | bun test --bail=1 api |
See Also
vitest-testing- Unit testing frameworkpython-testing- Python pytest patternsplaywright-testing- E2E API testingtest-quality-analysis- Test quality patterns
References
- Supertest: https://github.com/ladjs/supertest
- httpx: https://www.python-httpx.org/
- FastAPI Testing: https://fastapi.tiangolo.com/tutorial/testing/
- Node.js Testing Best Practices: https://github.com/goldbergyoni/nodejs-testing-best-practices
Readme
API Plugin
A comprehensive Claude Code plugin for API integration and testing, providing specialized agents, skills, and commands for working with REST APIs.
Overview
The API Plugin provides tools for:
- API Testing: Supertest (TypeScript/JavaScript) and httpx/pytest (Python)
- API Integration: Discovering, exploring, and integrating with REST APIs
- Contract Testing: Pact consumer-driven contracts
- OpenAPI Validation: Request/response validation against OpenAPI specs
- Schema Testing: JSON Schema and Zod validation
Components
Skills
api-testing
Expert knowledge for HTTP API testing with Supertest (TypeScript/JavaScript) and httpx/pytest (Python).
Covers:
- Request testing (headers, query params, request bodies)
- Response validation (status codes, headers, JSON schemas)
- Authentication testing (Bearer tokens, cookies, OAuth)
- Error handling (4xx/5xx responses, validation errors)
- File upload and cookie testing
- GraphQL API testing
- Database integration testing
- Performance testing
Technologies:
- TypeScript/JavaScript: Supertest, Express, Vitest
- Python: httpx, pytest, FastAPI
Setting up the contract-testing infrastructure (Pact, OpenAPI validation, schema testing, breaking-change CI) is
configure-plugin:configure-api-tests(/configure:api-tests). This plugin previously shipped a duplicateapi-testsskill; it was removed in favor of the canonical configure skill.
Installation
Install this plugin in your Claude Code environment:
# From the plugin directory
cd /path/to/api-plugin
# The plugin is now available to Claude Code
Usage
Using the API Testing Skill
The skill is automatically activated when discussing API testing:
How do I test a REST API endpoint with authentication using Supertest?
Or explicitly:
Using the api-testing skill, show me how to test file uploads in FastAPI
Configuring Contract-Testing Infrastructure
Use the canonical configure skill (from configure-plugin):
/configure:api-tests --check-only
/configure:api-tests --fix
/configure:api-tests --fix --type pact
API Testing Types
Contract Testing (Pact)
Consumer-driven contracts for microservices.
When to use:
- Multiple services with API dependencies
- Need to detect breaking changes early
- Want to test service integration without running all services
Setup includes:
- Consumer contract tests
- Provider verification
- Optional Pact Broker integration
- CI/CD pipeline configuration
OpenAPI Validation
Validate requests and responses against OpenAPI specification.
When to use:
- API-first development
- Documentation-driven testing
- Need to ensure API implementation matches spec
Setup includes:
- OpenAPI specification file
- Request/response validation helpers
- Breaking change detection
- TypeScript types generation
Schema Testing
JSON Schema or Zod validation for API responses.
When to use:
- Simple validation needs
- GraphQL APIs
- Single service applications
- Want type-safe schemas in code
Setup includes:
- Schema definitions (Zod or JSON Schema)
- Response validation helpers
- Type inference from schemas
Examples
Testing a REST API with Supertest (TypeScript)
import { describe, it, expect } from 'vitest'
import request from 'supertest'
import { app } from './app'
describe('Users API', () => {
it('creates a new user', async () => {
const response = await request(app)
.post('/api/users')
.send({ name: 'John Doe', email: 'john@example.com' })
.expect(201)
expect(response.body).toMatchObject({
id: expect.any(Number),
name: 'John Doe',
email: 'john@example.com',
})
})
it('requires authentication', async () => {
await request(app)
.get('/api/protected')
.expect(401)
await request(app)
.get('/api/protected')
.set('Authorization', 'Bearer valid-token')
.expect(200)
})
})
Testing with httpx (Python)
import pytest
from fastapi.testclient import TestClient
from main import app
@pytest.fixture
def client():
return TestClient(app)
def test_create_user(client):
response = client.post(
"/api/users",
json={"name": "John Doe", "email": "john@example.com"}
)
assert response.status_code == 201
data = response.json()
assert data["name"] == "John Doe"
def test_authentication(client):
# Without token
response = client.get("/api/protected")
assert response.status_code == 401
# With token
response = client.get(
"/api/protected",
headers={"Authorization": "Bearer valid-token"}
)
assert response.status_code == 200
Pact Contract Testing
import { PactV4, MatchersV3 } from '@pact-foundation/pact';
const { like, regex, datetime } = MatchersV3;
const provider = new PactV4({
consumer: 'frontend-app',
provider: 'user-service',
});
describe('User Service Contract', () => {
it('returns a user', async () => {
await provider
.addInteraction()
.given('a user with ID 1 exists')
.uponReceiving('a request to get user 1')
.withRequest({
method: 'GET',
path: '/api/users/1',
})
.willRespondWith({
status: 200,
body: {
id: like(1),
name: like('John Doe'),
email: regex(/^[\w.-]+@[\w.-]+\.\w+$/, 'john@example.com'),
createdAt: datetime("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"),
},
})
.executeTest(async (mockServer) => {
const response = await fetch(`${mockServer.url}/api/users/1`);
expect(response.status).toBe(200);
});
});
});
Best Practices
Test Organization
- Group related endpoints in describe blocks
- Use fixtures for common setup
- Keep tests focused on single behavior
- Test both happy path and error cases
Database State
- Reset database between tests
- Use transactions that rollback
- Seed minimal test data
- Avoid depending on test execution order
Assertions
- Validate status codes first
- Check response structure
- Verify specific field values
- Test error message format
Performance
- Mock expensive external service calls
- Use in-memory databases for tests
- Run tests in parallel when possible
- Keep test suites fast (< 30s for unit, < 5min for integration)
CI/CD Integration
The plugin provides GitHub Actions workflow templates for:
- Consumer contract tests
- Provider verification
- OpenAPI validation
- Breaking change detection
- Pact artifact management
Related Tools
- Supertest: HTTP assertions for Node.js
- httpx: Modern HTTP client for Python
- Pact: Consumer-driven contract testing
- OpenAPI: API specification standard
- Zod: TypeScript-first schema validation
- AJV: JSON Schema validator
References
- Supertest Documentation
- httpx Documentation
- Pact Documentation
- OpenAPI Specification
- Zod Documentation
- FastAPI Testing Guide
- Node.js Testing Best Practices
Version
1.0.0
Author
Lauri Gates
License
See project license for details.
Details
- Marketplace
- laurigates/claude-plugins
- Source
- api-plugin
- Author
- Lauri Gates
- Category
- Development
- License
- MIT
- Keywords
- api, rest, integration, testing
- Listed since
- Apr 7, 2026
More from laurigates/claude-plugins
All 52- bevy-pluginv1.4.2
- bios-pluginv1.2.0
- blog-pluginv1.3.4
- blueprint-pluginv3.52.0
- cloud-pluginv1.1.1
- code-quality-pluginv1.30.4
- codebase-attributes-pluginv1.3.4
- comfyui-pluginv1.15.7
- communication-pluginv1.2.7
- component-patterns-pluginv1.5.4
- configure-pluginv1.43.12
- container-pluginv2.11.5
- css-pluginv1.2.4
- documentation-pluginv1.16.1
- evaluate-pluginv1.21.1
- feedback-pluginv1.16.3
- finops-pluginv1.4.7
- foundryvtt-pluginv1.6.4
- git-pluginv2.74.4
- github-actions-pluginv1.13.8
- health-pluginv1.24.9
- home-assistant-pluginv1.4.1
- hooks-pluginv2.22.3
- kernel-pluginv1.1.1
Similar to api-plugin
More Testing & QA
api-scaffoldingwshobson/agents42.8K starsREST and GraphQL API scaffolding, framework selection, backend architecture, and API generation
api-toolsmiles990/claude-software-skills26 starsAPI testing, documentation, and development tools
do-apiTheBushidoCollective/han201 starsAPI engineering agents providing expertise in API design, contracts, and gateway patterns
api-testing-observabilitywshobson/agents42.8K starsAPI testing automation, request mocking, OpenAPI documentation generation, observability setup, and monitoring
contract-testerrohitg00/awesome-claude-code-toolkit2.8K starsAPI contract testing with Pact for microservice compatibility
api-connectorglincker/claude-code-marketplace38 starsConnect to 100+ popular APIs using natural language