liveBook · Manning

REST

As explained in Building Web APIs with ASP.NET Core

REST is an architectural style for network-based applications that uses standardized operations and resource representations over a uniform interface.

Representational state transfer (REST) is an architectural style for network-based applications. In a web API, clients use standard HTTP methods to access and change resources. REST offers more than a convenient set of endpoints: its guiding constraints shape how clients, servers, and responses work together. An API that uses HTTP methods with REST in mind is not necessarily fully RESTful. section 1.1.4 section 10.0

Choose the method that matches the intended operation:

  • GET reads data; POST creates a resource or performs a state change. section 1.1.4
  • PATCH updates an existing resource; PUT replaces one, or creates it if absent. section 1.1.4
  • DELETE permanently erases a resource. section 1.1.4

For a board-game API, the design question is not just which method handles a request. Keep client UI concerns separate from server data storage, and make each request carry the context it needs, such as an authentication key, rather than relying on information retained from a previous call. These client-server and statelessness constraints help keep the parts of the system simpler to change. section 1.1.4 section 3.0

In ASP.NET Core, put the constraints to work through the API’s configuration and responses:

  • Configure CORS services and middleware when a browser client must load resources from an allowed external origin. section 3.5
  • Set response-caching HTTP headers, including through the [ResponseCache] attribute, when caching can reduce latency and bandwidth use. section 3.5
  • Consider a response DTO containing data, structured links, and metadata so a client can discover possible next requests; this applies the uniform-interface goal through hypermedia. section 3.5

Check the resulting behavior, not just the route names: can a client make a request without relying on a previous call, and do the returned links help it decide what to do next? REST is a practical default for many APIs, but it is not always the best fit. Fixed endpoints can return more data than needed or require several round trips to gather too little; GraphQL offers client-shaped queries as one alternative. section 1.1.4 section 3.5 section 10.6

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Moves from HTTP method meanings and guiding constraints to ASP.NET Core configuration and response design, without dwelling on theory.
Examples
Uses a board-game API and ASP.NET Core response caching, CORS, and hypermedia responses as implementation contexts.
What it assumes
Builds on a running minimal web API and introduces REST properties before applying them.
What you can do after
Apply it via ASP.NET Core to make a board-game API more RESTful and evaluate when REST’s fetching trade-offs warrant an alternative.
How it connects
Connects statelessness and the uniform interface with CORS, response caching, hypermedia, and GraphQL.

Also explained in

Compare how 22 books explain REST →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.