REST API design standards and best practices. URL naming (plural nouns, kebab-case), HTTP method semantics, status code reference, response envelope format, pagination strategy (cursor vs offset decision), rate limiting tiers, versioning, and API design checklist. Use when designing new APIs, reviewing API contracts, or building backend endpoints.
SUCCESS
200 OK GET/PUT/PATCH with body
201 Created POST (must include Location header)
204 No Content DELETE, PUT without body
CLIENT ERROR
400 Bad Request Malformed JSON, missing required field
401 Unauthorized No/invalid auth token
403 Forbidden Authenticated but no permission
404 Not Found Resource does not exist
409 Conflict Duplicate key, state machine violation
422 Unprocessable Valid JSON but semantically wrong data
429 Too Many Requests Rate limit hit (must include Retry-After)
SERVER ERROR
500 Internal Unexpected failure (NEVER expose internals)
502 Bad Gateway Upstream dependency failed
503 Unavailable Overload (must include Retry-After)
Dataset size?
├── <10K rows OR admin dashboard → Offset (page + per_page)
│ SQL: LIMIT 20 OFFSET 40
│ Pros: jump-to-page, simple
│ Cons: perf degrades at deep offsets, drift on concurrent writes
│
├── >10K rows OR infinite scroll OR feed → Cursor (opaque token)
│ SQL: WHERE id > :cursor LIMIT 21 (fetch N+1 to detect has_next)
│ Pros: O(1) at any depth, stable under writes
│ Cons: no jump-to-page
│
└── Public API → Cursor default, offset optional
Rate Limiting Tiers
Tier
Limit
Window
Scope
Anonymous
30/min
Per IP
Public read endpoints
Authenticated
100/min
Per user
Standard access
Premium
1000/min
Per API key
Paid plans
Internal
10000/min
Per service
Service-to-service
Headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset (unix epoch).
On 429: must return Retry-After header.
Versioning Strategy
1. Start at /api/v1/ — don't version until you must
2. Max 2 active versions (current + previous)
3. Non-breaking (no new version): add fields, add optional params, add endpoints
4. Breaking (new version): remove/rename fields, change types, change auth
5. Deprecation: 6-month notice → Sunset header → 410 Gone after sunset