Skip to content
RESTful API Reference & Cheatsheet — Status Codes, Methods & Best Practices

RESTful API Reference & Cheatsheet — Status Codes, Methods & Best Practices

DodaTech Updated Jun 6, 2026 5 min read

RESTful API reference and cheatsheet for HTTP methods, status codes, caching directives, security patterns, and REST design principles organized for daily use.

What You’ll Learn

  • HTTP methods with idempotency and safety at a glance
  • Complete status code reference (2xx, 3xx, 4xx, 5xx)
  • Cache-Control directives and ETag usage
  • Standard error response format
  • Security patterns and best practices

Why This Reference Matters

Even experienced developers need quick access to status code ranges, method semantics, and header formats. DodaTech’s engineering team uses this reference daily when building and maintaining Durga Antivirus Pro’s REST API — it ensures consistency across all 50+ endpoints.

    flowchart LR
    A["REST Reference"] --> B["HTTP Methods"]
    A --> C["Status Codes"]
    A --> D["Caching"]
    A --> E["Security"]
    A --> F["Error Format"]
    style A fill:#dbeafe,stroke:#2563eb
  
Prerequisites: Familiarity with REST. This is a reference, not a tutorial — use it alongside the RESTful Resources and RESTful Methods.

HTTP Methods Reference

MethodCRUDSafeIdempotentRequest BodyResponse
GETReadYesYesNo200 OK
POSTCreateNoNoYes201 Created
PUTReplaceNoYesYes200 OK
PATCHPartial updateNoNoYes200 OK
DELETEDeleteNoYesNo204 No Content

Safe: No server-side side effects. Idempotent: N identical requests produce the same server state as 1 request.

Status Codes Quick Reference

2xx Success

CodeMeaningUsage
200OKStandard success for GET, PUT, PATCH
201CreatedPOST — new resource created
202AcceptedAsync processing accepted
204No ContentDELETE — resource removed

3xx Redirection

CodeMeaningUsage
301Moved PermanentlyEndpoint migrated
304Not ModifiedConditional GET — use cache

4xx Client Error

CodeMeaningUsage
400Bad RequestInvalid JSON, missing fields
401UnauthorizedMissing/invalid credentials
403ForbiddenAuthenticated but no permission
404Not FoundResource doesn’t exist
405Method Not AllowedWrong HTTP method
409ConflictDuplicate, stale version
422Unprocessable EntityValidation failed
429Too Many RequestsRate limit exceeded

5xx Server Error

CodeMeaningUsage
500Internal Server ErrorUnexpected failure
502Bad GatewayUpstream service failed
503Service UnavailableOverloaded, maintenance

Cache-Control Directives

DirectiveMeaningExample
publicAny cache can storepublic, max-age=3600
privateOnly browser cacheprivate, max-age=600
no-storeNever cacheno-store
no-cacheRevalidate before useno-cache
max-age=NValid for N secondsmax-age=86400 (1 day)
must-revalidateMust check originmust-revalidate

Standard Error Response Format

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Human-readable summary",
    "details": [
      { "field": "email", "message": "Must be valid email" }
    ],
    "requestId": "req-abc-123"
  }
}

Security Reference

PatternImplementationEndpoint Example
API KeyX-API-Key headerPublic read-only endpoints
JWT BearerAuthorization: Bearer <token>All authenticated endpoints
OAuth 2.0Authorization code flowThird-party integrations
Rate Limiting100 req/min per keyAll endpoints
HTTPSTLS 1.2+ enforcedAll endpoints

Design Principles Reference

  • Nouns, not verbs: /users, not /getUsers
  • Plural collections: /users, /products, /threats
  • Nested scope: /users/{id}/orders
  • Versioned: /api/v1/...
  • Consistent errors: Same JSON structure everywhere
  • Idempotent methods: PUT, DELETE (same call, same result)
  • Stateless: No server-side sessions, JWT carries state

Common Mistakes

  1. Inconsistent error formats — clients need different parsers per endpoint
  2. Not versioning — breaking changes break all existing clients
  3. Returning 200 for everything — loses semantic meaning
  4. No caching headers — caches behave unpredictably
  5. Session state on server — breaks horizontal scaling
  6. Exposing internal IDs — couples API to DB schema

Practice Questions

  1. What status code should a POST request return on success?
  2. Which HTTP methods are idempotent and why?
  3. What Cache-Control directive prevents any caching?
  4. What is the difference between 401 and 403?
  5. How does JWT maintain statelessness?

Answers:

  1. 201 Created with a Location header pointing to the new resource.
  2. GET, PUT, DELETE — calling them multiple times produces the same server state.
  3. Cache-Control: no-store
  4. 401 = not authenticated (missing/invalid credentials). 403 = authenticated but not authorized.
  5. The JWT contains all user data (ID, role, permissions) signed by the server — no database lookup needed, no server-side state.

Challenge: Create a 5-line implementation of a rate limiter middleware for Express.js that tracks requests by IP and returns 429 when the limit is exceeded.

FAQ

What is the difference between REST API and RESTful API?
: REST is the architectural style. RESTful describes an API that implements REST principles. Same relationship as “Marxist” to “Marx” — the adjective form.
Should I always use plural resource names?
: Yes — /users (collection) and /users/123 (member) is the standard. Singular names (/user) suggest there’s only one, which creates awkward URIs for collections.
Is GraphQL a replacement for REST?
: Not exactly. GraphQL solves specific REST pain points (over-fetching, under-fetching, multiple round trips). But REST is simpler, has better caching, and is more widely supported. Choose based on your use case.
Can I have a RESTful API that uses WebSockets?
: REST is fundamentally request-response over HTTP. WebSockets are full-duplex and stateful, which conflicts with REST constraints. Use REST for synchronous CRUD operations and WebSockets for real-time events alongside it.

What’s Next

TopicDescription
Firebase IntroductionBaaS platform with real-time database and auth
GraphQL IntroductionFlexible data fetching and schema-based APIs
SOAP & Web ServicesEnterprise API patterns for comparison
HTTP Protocol Deep DiveFoundation protocol for all web APIs

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro