Skip to content

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

DodaTech Updated 2026-06-06 6 min read

In this tutorial, you'll learn about RESTful API Reference & Cheatsheet. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

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

{{< callout type="info" icon="sparkles" >}} Prerequisites: Familiarity with REST. This is a reference, not a tutorial — use it alongside the RESTful Resources and RESTful Methods. {{< /callout >}}

HTTP Methods Reference

Method CRUD Safe Idempotent Request Body Response
GET Read Yes Yes No 200 OK
POST Create No No Yes 201 Created
PUT Replace No Yes Yes 200 OK
PATCH Partial update No No Yes 200 OK
DELETE Delete No Yes No 204 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

Code Meaning Usage
200 OK Standard success for GET, PUT, PATCH
201 Created POST — new resource created
202 Accepted Async processing accepted
204 No Content DELETE — resource removed

3xx Redirection

Code Meaning Usage
301 Moved Permanently Endpoint migrated
304 Not Modified Conditional GET — use cache

4xx Client Error

Code Meaning Usage
400 Bad Request Invalid JSON, missing fields
401 Unauthorized Missing/invalid credentials
403 Forbidden Authenticated but no permission
404 Not Found Resource doesn't exist
405 Method Not Allowed Wrong HTTP method
409 Conflict Duplicate, stale version
422 Unprocessable Entity Validation failed
429 Too Many Requests Rate limit exceeded

5xx Server Error

Code Meaning Usage
500 Internal Server Error Unexpected failure
502 Bad Gateway Upstream service failed
503 Service Unavailable Overloaded, maintenance

Cache-Control Directives

Directive Meaning Example
public Any cache can store public, max-age=3600
private Only browser cache private, max-age=600
no-store Never cache no-store
no-cache Revalidate before use no-cache
max-age=N Valid for N seconds max-age=86400 (1 day)
must-revalidate Must check origin must-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

Pattern Implementation Endpoint Example
API Key X-API-Key header Public read-only endpoints
JWT Bearer Authorization: Bearer <token> All authenticated endpoints
OAuth 2.0 Authorization code flow Third-party integrations
Rate Limiting 100 req/min per key All endpoints
HTTPS TLS 1.2+ enforced All 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

Topic Description
Firebase Introduction BaaS platform with real-time database and auth
GraphQL Introduction Flexible data fetching and schema-based APIs
SOAP & Web Services Enterprise API patterns for comparison
HTTP Protocol Deep Dive Foundation protocol for all web APIs
⬅ REST API Security
➡ Database Design for APIs

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro