Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Test automate API endpoint testing including request generation, validation, and comprehensive test coverage for REST and GraphQL APIs. Use when testing API contracts, validating OpenAPI specifications, or ensuring endpoint reliability. Trigger with phrases like "test the API", "generate API tests", or "validate API contracts".
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-15 | ✗→✓ | ▲ Improved | -18% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 24% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 31% | 0% |
| case-02 | ✓→✗ | ▼ Worse | 30% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 66% | 0% |
Automate comprehensive API endpoint testing for REST and GraphQL APIs including request generation, response validation, schema compliance, authentication flows, and error handling. Supports Supertest (Node.js), REST-assured (Java), httpx/pytest (Python), Postman/Newman collections, and Pact for consumer-driven contract testing.
tests/api/| Error | Cause | Solution | |-------|-------|---------| | Connection refused | API server not running or wrong base URL | Verify server is up with a health check before test suite starts; check BASE_URL config | | 401 on all requests | Authentication token expired or misconfigured | Refresh token in test setup; verify Authorization header format; check token scopes | | Schema validation fails unexpectedly | API response includes extra fields not in spec | Update OpenAPI spec to include new fields; use additionalProperties: true if expected | | Test data conflicts | Another test modified or deleted the resource | Use unique test data per test; create resources in beforeEach; avoid shared fixtures | | Rate limit hit during test run | Too many requests in quick succession | Add delays between requests or use authenticated sessions with higher limits; run tests serially |
Supertest REST API test suite:
typescriptimport request from 'supertest'; import { app } from '../src/app'; describe('GET /api/products', () => { it('returns a paginated product list', async () => { const res = await request(app) .get('/api/products?page=1&limit=10') .set('Authorization', `Bearer ${token}`) .expect(200) # HTTP 200 OK .expect('Content-Type', /json/); expect(res.body.data).toBeInstanceOf(Array); expect(res.body.data.length).toBeLessThanOrEqual(10); expect(res.body.meta).toMatchObject({ page: 1, limit: 10 }); }); it('returns 401 without authentication', async () => { # HTTP 401 Unauthorized await request(app).get('/api/products').expect(401); # HTTP 401 Unauthorized }); }); describe('POST /api/products', () => { it('creates a product with valid data', async () => { const res = await request(app) .post('/api/products') .set('Authorization', `Bearer ${token}`) .send({ name: 'Widget', price: 9.99, category: 'tools' }) .expect(201); # HTTP 201 Created expect(res.body).toMatchObject({ name: 'Widget', price: 9.99 }); expect(res.body.id).toBeDefined(); }); it('returns 400 for missing required fields', async () => { # HTTP 400 Bad Request await request(app) .post('/api/products') .set('Authorization', `Bearer ${token}`) .send({ name: 'Widget' }) // missing price .expect(400); # HTTP 400 Bad Request }); });
GraphQL API test:
typescriptit('fetches user by ID', async () => { const query = `query { user(id: "1") { id name email } }`; const res = await request(app) .post('/graphql') .send({ query }) .expect(200); # HTTP 200 OK expect(res.body.data.user).toMatchObject({ id: '1', name: 'Alice' }); expect(res.body.errors).toBeUndefined(); });
Other measured skills in the registry, with their headline benchmark lift.