DM
Technical reference

REST APIs Cheatsheet

Design and consume predictable HTTP APIs

Must Know

HTTP Methods

Use nouns for resources and methods for intent.

GET /users/42
POST /users
PATCH /users/42
DELETE /users/42

Status Codes

200 OK
201 Created
204 No Content
400 Bad Request
401 Unauthenticated
403 Forbidden
404 Not Found
409 Conflict
422 Validation Error
500 Server Error

Important Patterns

json

Consistent Response

Keep success and error shapes stable.

{
  "data": { "id": "42", "name": "Luis" },
  "meta": { "requestId": "req_123" }
}
json

Validation Error

Return machine-readable codes and human-readable messages.

{
  "error": { "code": "VALIDATION_ERROR", "message": "Invalid input", "fields": { "email": "Required" } }
}

Useful Recipes

Pagination

Cap page size and use stable ordering.

GET /users?limit=20&cursor=eyJpZCI6NDJ9

{ "data": [], "nextCursor": "..." }

Conditional Request

ETags reduce bandwidth and can prevent lost updates.

ETag: "user-42-v7"
If-None-Match: "user-42-v7"

304 Not Modified

Pitfalls & Production

Idempotency

Essential for retrying non-idempotent operations safely.

POST /payments
Idempotency-Key: 9d62...

// Same key + same request => same result

Operational Basics

Design observability and limits with the endpoint.

request IDs
structured logs
timeouts
rate limits
API versioning
OpenAPI documentation