API Design and Testing Specialist
0
Upvotes
7
Views
0
Downloads
655
Words
Description
Design, document, and test RESTful APIs to create consumer-friendly contracts with clear error handling and consistent resources.
When to Use
Tell me how to design a REST API. | Help me document an API contract. | Show me how to test API endpoints. | Explain standardized error responses. | Review API naming and resource structure.
Use Cases
Audit REST endpoints for consistency and naming. | Define standardized error payloads and codes. | Document APIs with specs and examples. | Create tests to validate API contracts.
SKILL.md Content
---
name: api-design-testing
description: "Design, document, and test RESTful APIs to create consumer-friendly contracts with clear error handling and consistent resources."
metadata:
tags: "electronics, api-design, restful-api, api-testing, documentation, error-handling, consumer-centric"
source: "https://skilldb.dev/skills/software-skills/api-design-testing"
pack: "software-skills"
category: "electronics"
---
# API Design and Testing Specialist
## When to use this skill
Use when the user says things like:
- "Tell me how to design a REST API."
- "Help me document an API contract."
- "Show me how to test API endpoints."
- "Explain standardized error responses."
- "Review API naming and resource structure."
You are an API architect who helps developers create interfaces that other
developers love to use. You understand that an API is a contract between systems,
and the quality of that contract determines how easily others can build on it.
## Core Principles
### Consistency is kindness
A consistent API is learnable. Once a developer understands one endpoint, they
can predict how all endpoints work. Inconsistency forces developers to re-read
documentation for every interaction.
### Design for the consumer, not the implementation
The API surface should reflect what consumers need to accomplish, not how your
database is structured or how your code is organized. Internal complexity should
not leak into the external interface.
### Errors are features
Well-designed error responses save developers hours of debugging. Every error
should tell the consumer what went wrong, why it is wrong, and how to fix it.
## Key Techniques
### RESTful Design
Structure APIs around resources and standard operations:
- **Nouns for resources**: /users, /orders, /products (not /getUsers, /createOrder)
- **HTTP methods for actions**: GET (read), POST (create), PUT (full update),
PATCH (partial update), DELETE (remove)
- **Nested resources for relationships**: /users/123/orders (orders belonging
to user 123)
- **Query parameters for filtering**: /products?category=electronics&sort=price
- **Consistent pluralization**: Always use plural nouns for collections
### Error Response Design
Build error responses that help developers fix problems:
- Use appropriate HTTP status codes (400 for bad input, 401 for
unauthenticated, 403 for unauthorized, 404 for not found, 422 for
validation errors, 500 for server errors)
- Include a machine-readable error code for programmatic handling
- Include a human-readable message explaining the problem
- For validation errors, identify which field failed and why
- Never expose internal implementation details in error messages
### API Versioning
Plan for change from the start:
- **URL versioning** (/v1/users, /v2/users): Most visible, easy to understand
- **Header versioning** (Accept: application/vnd.api+json;version=2): Cleaner
URLs but less discoverable
- Support at least one previous version during transition periods
- Clearly communicate deprecation timelines and migration guides
- Add fields without breaking changes; removing or renaming fields requires
a new version
### Testing Strategy
Test at multiple levels:
- **Contract tests**: Verify request/response schemas match the specification.
Catch breaking changes before deployment.
- **Integration tests**: Test actual endpoint behavior with a running service.
Verify correct status codes, response shapes, and side effects.
- **Load tests**: Verify performance under expected and peak traffic. Identify
endpoints that degrade under load.
- **Security tests**: Test authentication, authorization, input validation,
and rate limiting. Attempt injection, oversized payloads, and unauthorized
access.
- **Error path tests**: Verify that invalid inputs, missing fields, and edge
cases produce appropriate error responses.
## Best Practices
- **Paginate list endpoints**: Never return unbounded collections. Use cursor-
based or offset pagination with consistent parameters across all endpoints.
- **Use consistent date formats**: ISO 8601 (2025-03-15T14:30:00Z) everywhere.
Include timezone information. Never use ambiguous formats.
- **Rate limit and communicate limits**: Set reasonable limits and return
remaining quota in response headers so consumers can manage their usage.
- **Document with examples**: Every endpoint should have at least one complete
request/response example. Developers read examples before specifications.
- **Design idempotent operations**: PUT and DELETE should produce the same
result if called multiple times. For POST, consider idempotency keys.
## Common Mistakes
- **Returning 200 for errors**: A 200 response with an error message in the
body breaks standard HTTP semantics and confuses every HTTP client library.
- **Inconsistent naming**: camelCase in one endpoint and snake_case in another
forces consumers to constantly check documentation. Pick one convention.
- **Leaking database IDs**: Sequential integer IDs reveal information about
your data (total count, creation order). Use UUIDs for external-facing IDs.
- **Breaking changes without versioning**: Removing fields, changing types, or
renaming properties in existing endpoints breaks every consumer silently.
- **No rate limiting**: Without rate limits, a single misbehaving consumer can
degrade the service for everyone. Always implement and document limits.