Design consistent, production-ready REST APIs with practical conventions and patterns.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "api-design" skill from askskill: 1. Download https://raw.githubusercontent.com/affaan-m/ECC/main/skills/api-design/SKILL.md 2. Save it as ~/.claude/skills/api-design/SKILL.md 3. Reload skills and tell me it's ready
Design a REST API for an e-commerce system with users, orders, and order cancellation. Include resource naming, URL structure, HTTP methods, status codes, and error response format.
A clear API design proposal with resource paths, method semantics, common status codes, and a consistent error response format.
Review the following REST API design against best practices. Focus on URL naming, status code usage, pagination and filtering parameters, and whether verbs are incorrectly used in URLs.
An issue list for the API design, plus recommendations that better follow REST conventions.
Create a versioning and rate-limiting strategy for a public REST API, and explain which HTTP status codes should be returned and when to use them.
A versioning and rate-limiting plan for a public API, with guidance on relevant HTTP status codes.
Developers or product managers can use it to standardize resource naming, URL structure, method semantics, and status code rules when creating a new REST API. It is especially useful for developer-facing, partner-facing, or public APIs.
When a team needs to review whether an existing API contract is consistent and developer-friendly, it helps check plural resource names, filtering parameters, pagination design, and error response format. This improves readability and integration experience.
During API expansion, it is useful for adding pagination, filtering, sorting, and consistent error handling rules. This helps make the API more complete and reliable before production use.
The document summarizes conventions and best practices for designing consistent, developer-friendly REST APIs. It covers when to use the skill, URL and resource structure, naming rules, sub-resources, and limited action-style endpoints. It also explains HTTP method semantics, common success and error status codes, and shows good versus bad examples for error responses and resource creation behavior.
Conventions and best practices for designing consistent, developer-friendly REST APIs.
# Resources are nouns, plural, lowercase, kebab-case
GET /api/v1/users
GET /api/v1/users/:id
POST /api/v1/users
PUT /api/v1/users/:id
PATCH /api/v1/users/:id
DELETE /api/v1/users/:id
# Sub-resources for relationships
GET /api/v1/users/:id/orders
POST /api/v1/users/:id/orders
# Actions that don't map to CRUD (use verbs sparingly)
POST /api/v1/orders/:id/cancel
POST /api/v1/auth/login
POST /api/v1/auth/refresh
# GOOD
/api/v1/team-members # kebab-case for multi-word resources
/api/v1/orders?status=active # query params for filtering
/api/v1/users/123/orders # nested resources for ownership
# BAD
/api/v1/getUsers # verb in URL
/api/v1/user # singular (use plural)
/api/v1/team_members # snake_case in URLs
/api/v1/users/123/getOrders # verb in nested resource
| Method | Idempotent | Safe | Use For |
|---|---|---|---|
| GET | Yes | Yes | Retrieve resources |
| POST | No | No | Create resources, trigger actions |
| PUT | Yes | No | Full replacement of a resource |
| PATCH | No* | No | Partial update of a resource |
| DELETE | Yes | No | Remove a resource |
*PATCH can be made idempotent with proper implementation
# Success
200 OK — GET, PUT, PATCH (with response body)
201 Created — POST (include Location header)
204 No Content — DELETE, PUT (no response body)
# Client Errors
400 Bad Request — Validation failure, malformed JSON
401 Unauthorized — Missing or invalid authentication
403 Forbidden — Authenticated but not authorized
404 Not Found — Resource doesn't exist
409 Conflict — Duplicate entry, state conflict
422 Unprocessable Entity — Semantically invalid (valid JSON, bad data)
429 Too Many Requests — Rate limit exceeded
# Server Errors
500 Internal Server Error — Unexpected failure (never expose details)
502 Bad Gateway — Upstream service failed
503 Service Unavailable — Temporary overload, include Retry-After
# BAD: 200 for everything
{ "status": 200, "success": false, "error": "Not found" }
# GOOD: Use HTTP status codes semantically
HTTP/1.1 404 Not Found
{ "error": { "code": "not_found", "message": "User not found" } }
# BAD: 500 for validation errors
# GOOD: 400 or 422 with field-level details
# BAD: 200 for created resources
# GOOD: 201 with Location header
HTTP/1.1 201 Created
Location: /api/v1/users/abc-123
{
"data": {
"id": "abc-123",
"email": "[email protected]",
"name": "Alice",
"created_at": "2025-01-15T10:30:00Z"
}
}
{
"data": [
{ "id": "abc-123", "name": "Alice" },
{ "id": "def-456", "name": "Bob" }
],
"meta": {
"total": 142,
"page": 1,
"per_page": 20,
"total_pages": 8
},
"links": {
"self": "/api/v1/users?page=1&per_page=20",
"next": "/api/v1/users?page=2&per_page=20",
"last": "/api/v1/users?page=8&per_page=20"
}
}
{
"error": {
"code": "validation_error",
"message": "Request validation failed",
"details": [
{
"field": "email",
"message": "Must be a valid email address",
"code": "invalid_format"
},
{
"field": "age",
"message": "Must be between 0 and 150",
…
It focuses on REST API design patterns, including resource naming, status codes, pagination, filtering, error responses, versioning, and rate limiting. The goal is to make APIs more consistent and developer-friendly.
It can be used when designing new endpoints, reviewing existing API contracts, adding pagination and filtering rules, implementing error handling, and planning versioning. The document excerpt explicitly lists these common use cases.
The docs emphasize plural noun resources, lowercase kebab-case URLs, query parameters for filtering, and semantically correct HTTP status codes. They also note that verb-based paths should be used sparingly for non-CRUD actions.
Design reliable deployment workflows, CI/CD pipelines, and production release strategies.
Orchestrate parallel AI agent workflows with dmux for faster development execution.
Helps developers follow this JavaScript repository's coding, testing, and commit conventions.
Apply modern, safe, idiomatic C++ standards for writing, review, and refactoring.
Search PubMed literature, MeSH terms, PMIDs, and citation data efficiently.
Audit, plan, and implement SEO improvements for better search visibility.
Design or evaluate web services, APIs, scalability, and reliability tradeoffs.
Identify customer-facing API changes and determine release, review, and deprecation requirements.
Reference a compliant modern banking API design to kickstart development.
Learn Django architecture, DRF API design, and production-ready development practices.
Turn finalized designs into clear developer handoff specs for implementation.
Generate UI design rules, color palettes, and brand design references.