SkillStorr
Catalog/Coding/API design
A
Promptv1.0.0 · current

API design

REST API design patterns including resource naming, status codes, pagination, filtering, error responses, versioning, and rate limiting for production APIs. origin: ECC

B
Bohdan Tsaryk
·Published May 31, 2026·Token count not tracked
Uses (30d)
Stars
0
Versions
1
Forks
0
References
0

Full prompt

v1.0.0
prompt.md
preview

API Design Patterns

Conventions and best practices for designing consistent, developer-friendly REST APIs.

When to Activate

  • Designing new API endpoints
  • Reviewing existing API contracts
  • Adding pagination, filtering, or sorting
  • Implementing error handling for APIs
  • Planning API versioning strategy
  • Building public or partner-facing APIs

Resource Design

URL Structure

# 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

Naming Rules

# 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

HTTP Methods and Status Codes

Method Semantics

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

Status Code Reference

# 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

Common Mistakes

# 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

Response Format

Success Response

{
"data": {
"id": "abc-123",
"email": "[email protected]",
"name": "Alice",
"created_at": "2025-01-15T10:30:00Z"
}
}

Collection Response (with Pagination)

{
"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 Response

{
"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",
"code": "out_of_range"
}
]
}
}

Response Envelope Variants

// Option A: Envelope with data wrapper (recommended for public APIs)
interface ApiResponse


Use it anywhere

Profile required

Connect once — every prompt in your profile becomes available across the tools you use. Pick a method, then your editor.

Claude Desktop · MCP
3-step setup · ~2 minutes
Full docs ↗
1
Open Claude Desktop → Settings → Developer → Edit Config.
2
Paste the SkillStorr MCP entry into claude_desktop_config.json:
{ "mcpServers": { "skillstorr": { "command": "npx", "args": ["-y", "@skillstorr/mcp"], "env": { "SKILLSTORR_TOKEN": "<paste from skillstorr.dev/keys>" } } } }
3
Restart Claude. The prompt appears under MCP tools in any chat.
Calls count against your monthly use cap. Free plan: 200 calls / month across all prompts in your profile.