Skip to content
IRC-Coding IRC-Coding
REST HATEOAS ETag Caching OpenAPI

REST Fundamentals Explained: Constraints, HATEOAS & Caching

Master REST: 6 constraints, resources/URIs, HTTP methods, status codes, HATEOAS, ETag caching & API design best practices.

S

schutzgeist

2 min read
REST Fundamentals Explained: Constraints, HATEOAS & Caching

REST Fundamentals

This article is a definition of terms for REST – including exam questions, practical example, and tags.

In a Nutshell

REST is an architectural style for distributed HTTP-based systems: resources are addressed via URIs, manipulated through methods, and transferred via representations. Goal: loose coupling, scalability, caching.

Compact Technical Description

REST defines six constraints:

  • Client-Server
  • Statelessness
  • Cache-ability
  • Uniform Interface
  • Layered
  • Optional Code on Demand

Resources are business objects (e.g., /orders/42). Representations transport state (JSON/XML), negotiated via Accept/Content-Type.

Method semantics:

  • GET: safe + idempotent
  • POST: not idempotent
  • PUT: idempotent
  • PATCH: not necessarily idempotent
  • DELETE: idempotent

Status codes signal successes/failures (200/201/204/400/401/403/404/409/500). HATEOAS uses links in representations for “discoverable” workflows. Caching uses Cache-Control, ETag, If-None-Match.

Exam-Relevant Key Points

  • Resource-oriented URI design (no verbs in path)
  • Safe/Idempotent semantics of methods
  • Status codes correct (Location for 201)
  • Idempotency Key for POST (if needed)
  • Security: TLS, OAuth/OIDC/JWT, CORS, Rate Limiting
  • Cost-effectiveness: loose coupling
  • Documentation: OpenAPI + error catalog

Core Components

  1. Resource + URI Design
  2. Representations + Media Types
  3. Method Semantics
  4. Status Codes + Headers
  5. Content Negotiation
  6. Caching (ETag)
  7. Security
  8. Versioning
  9. Observability
  10. Tests (Contract/API)

Practical Example (Orders + HATEOAS)

{
  "id": 42,
  "status": "created",
  "links": [
    { "rel": "self", "href": "/orders/42" },
    { "rel": "confirm", "method": "POST", "href": "/orders/42/confirm" }
  ]
}

Advantages and Disadvantages

Advantages

  • Interoperability through standards
  • Loose coupling
  • Good scalability through statelessness
  • Efficient caching

Disadvantages

  • Overfetching/Underfetching possible
  • Complex write processes require idempotency strategies
  • HATEOAS is often not applied consistently

Typical Exam Questions (with Brief Answers)

  1. What REST constraints exist? Client-Server, Stateless, Cache, Uniform Interface, Layered, optional Code on Demand.
  2. PUT vs PATCH regarding idempotency? PUT idempotent, PATCH not automatically.
  3. How do ETag + conditional requests work? Client sends If-None-Match, server responds with 304 or delivers new body.

Free Response

REST is more than “JSON over HTTP”: the constraints and method semantics are decisive. Clean error objects, versioning, and observability make APIs maintainable.

Learning Strategy

  1. Analyze public APIs and assign constraints.
  2. Design resource model (URIs/methods/status codes).
  3. Practice method semantics table (safe/idempotent).
  4. Avoid verbs in path.

Most Important Sources

  1. https://roy.gbiv.com/untangled
  2. https://www.rfc-editor.org/rfc/rfc9110
  3. https://learn.microsoft.com/azure/architecture/best-practices/api-design
Back to Blog
Share:

Related Posts