Skip to content
doubtly

1 answer

An API is RESTful when it follows the REST architectural constraints: client–server, statelessness, cacheability, a uniform interface, a layered system, and optionally code on demand.

  1. Client–server separation: the client (UI) and server (data and logic) are independent and communicate only through requests and responses, so each can evolve separately.
  2. Stateless: every request carries all the information needed to process it (e.g. an auth token); the server stores no client session between requests.
  3. Cacheable: responses must say whether they can be cached (e.g. Cache-Control, ETag headers) to improve performance.
  4. Uniform interface:
    • Resources are identified by URIs, e.g. /students/42.
    • Resources are manipulated through representations (JSON, XML) using standard HTTP methods: GET (read), POST (create), PUT/PATCH (update), DELETE (remove).
    • Self-descriptive messages: correct status codes (200, 201, 404, 500) and headers such as Content-Type.
    • HATEOAS: responses can include links to related actions/resources.
  5. Layered system: the client does not need to know whether it talks to the actual server or to intermediaries such as load balancers, proxies or caches.
  6. Code on demand (optional): the server may send executable code (e.g. JavaScript) to extend the client.

Example of RESTful endpoints

GET    /api/books        list books
GET    /api/books/7      get book 7
POST   /api/books        create a book
PUT    /api/books/7      replace book 7
DELETE /api/books/7      delete book 7

Good practice also includes using nouns (not verbs) in URIs, versioning (/api/v1/), and idempotent PUT/DELETE.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.