Skip to content
IRC-CodingIRC-Coding
RESTHATEOASETagCachingOpenAPI

REST Basics Explained: Constraints, HATEOAS & Caching

Master REST fundamentals: 6 constraints, resources, HTTP methods, status codes, HATEOAS, ETag caching, and API design best practices.

S

schutzgeist

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

REST Fundamentals

This post is a concept guide to REST – including exam questions, practical examples, and key terms.

In a Nutshell

REST is an architectural style for distributed systems over HTTP: resources are addressed via URIs, manipulated through methods, and transferred as representations. The goal is loose coupling, scalability, and effective caching.

Technical Overview

REST defines six constraints:

  • Client-Server
  • Statelessness
  • Cacheability
  • Uniform Interface
  • Layered System
  • Optional Code on Demand

Resources are domain objects (e.g. /orders/42). Representations carry state in formats like JSON or XML, negotiated via Accept and Content-Type headers.

Method semantics:

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

Status codes signal success or failure (200/201/204/400/401/403/404/409/500). HATEOAS uses links in representations to enable discoverable workflows. Caching relies on Cache-Control, ETag, and If-None-Match.

Exam-Relevant Essentials

  • Resource-oriented URI design (no verbs in paths)
  • Safe and idempotent semantics of methods
  • Correct status codes (Location header with 201)
  • Idempotency Key for POST (when needed)
  • Security: TLS, OAuth/OIDC/JWT, CORS, rate limiting
  • Economics: loose coupling
  • Documentation: OpenAPI and error catalogs

Core Components

  1. Resource and URI design
  2. Representations and media types
  3. Method semantics
  4. Status codes and headers
  5. Content negotiation
  6. Caching (ETag)
  7. Security
  8. Versioning
  9. Observability
  10. Testing (contract and API)

Practical Example (Orders with HATEOAS)

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

Strengths and Weaknesses

Strengths

  • Interoperability through standards
  • Loose coupling
  • Strong scalability via statelessness
  • Efficient caching

Weaknesses

  • Overfetching and underfetching are possible
  • Complex write operations require idempotency strategies
  • HATEOAS is often not applied consistently

Common Exam Questions (with Quick Answers)

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

Key Takeaway

REST is more than “JSON over HTTP”: the constraints and method semantics are what matter. Well-structured error objects, versioning, and observability are what make APIs maintainable.

Study Strategy

  1. Analyze public APIs and map them to the constraints.
  2. Design your resource model (URIs, methods, status codes).
  3. Practice the method semantics table (safe/idempotent).
  4. Avoid verbs in your paths.

Essential Resources

  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