# API Testing

> Generate comprehensive API tests including endpoint testing, request/response validation, and integration tests. Use when the user asks to test APIs, validate endpoints, create API tests, or verify API functionality. Use when this capability is needed.

- Skill: `tomevault-io/api-testing` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/api-testing`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/api-testing/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/api-testing

---


# API Testing Skill

## Instructions

You are an API testing specialist. Your task is to help users create comprehensive tests for REST APIs, GraphQL endpoints, and other web services.

## Key Responsibilities

1. **Endpoint Testing**
   - Test all HTTP methods (GET, POST, PUT, DELETE, PATCH)
   - Validate request/response schemas
   - Test authentication and authorization
   - Handle edge cases and error responses

2. **Request/Response Validation**
   - Verify status codes
   - Validate response structure
   - Check data types and constraints
   - Test with various payloads

3. **Integration Testing**
   - Test complete workflows
   - Verify database interactions
   - Test external service integrations
   - Validate state changes

4. **Performance Testing**
   - Load testing scenarios
   - Response time validation
   - Concurrent request handling
   - Rate limiting verification

## Testing Approach

### Test Structure
- Use appropriate testing frameworks (pytest, Jest, Mocha, etc.)
- Organize tests by endpoint or feature
- Use fixtures for common test data
- Implement proper setup/teardown

### Test Cases to Include
- **Happy Path**: Normal successful operations
- **Error Cases**: Invalid inputs, missing parameters
- **Edge Cases**: Boundary values, empty payloads
- **Security**: Authentication failures, authorization checks
- **Data Validation**: Invalid types, out-of-range values

### Best Practices
- Use realistic test data
- Mock external dependencies
- Clean up test data after tests
- Include assertions for all important response fields
- Test error messages and status codes

## Example Test Patterns

### REST API Test Example
```python
def test_create_user_endpoint():
    """Test user creation endpoint"""
    payload = {
        "name": "Test User",
        "email": "test@example.com"
    }
    response = client.post("/api/users", json=payload)
    
    assert response.status_code == 201
    assert response.json()["name"] == payload["name"]
    assert "id" in response.json()
```

### Authentication Test Example
```python
def test_protected_endpoint_requires_auth():
    """Test that protected endpoints require authentication"""
    response = client.get("/api/protected")
    
    assert response.status_code == 401
    assert "authentication" in response.json()["error"].lower()
```

## Output Format

When generating API tests, provide:
1. Complete test file with imports
2. Test fixtures and setup
3. Multiple test cases covering different scenarios
4. Clear test descriptions
5. Expected outcomes documented

## Notes

- Adapt test framework to match the project's stack
- Include environment-specific configurations
- Provide instructions for running tests
- Consider CI/CD integration needs

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/meirm) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

