REST as an architectural style: Fielding's six constraints, the four parts of the uniform interface, and the gap between academic REST and the pragmatic "RESTful" JSON-over-HTTP APIs most teams build.
REST (Representational State Transfer) is an architectural style Roy Fielding described in 2000, not a protocol. It is defined by six constraints: client-server, stateless requests, cacheable responses, a uniform interface, a layered system, and optional code on demand. The uniform interface is the heart of it: resources identified by URIs, changed through representations (JSON, XML), self-descriptive messages (methods, status codes, media types) and hypermedia links that drive the client (HATEOAS).
In practice, when a team says "RESTful" they usually mean resource-oriented URLs, correct HTTP methods and status codes, and JSON, but no hypermedia. That is fine for most internal and partner APIs; the trade-off is that clients hard-code URLs and workflows instead of discovering them.
"REST is an architectural style from Roy Fielding's 2000 dissertation, describing what made the web itself scale. It isn't a standard or a library; it's a set of constraints, and you get certain properties if you follow them. Client-server separates the UI from storage. Stateless means every request carries everything the server needs, such as the bearer token, so any instance can serve it and you can scale horizontally. Cacheable means responses say whether and for how long they can be reused. Layered system means the client can't tell whether it's talking to a CDN, an API gateway or the origin. Code on demand, the server sending executable code such as JavaScript, is the one constraint Fielding made optional. And the uniform interface is the big one: resources have identifiers, you manipulate them by sending representations, messages are self-descriptive through methods, status codes and media types, and hypermedia links tell the client what it can do next.
In ASP.NET Core most of that shows up as resource routes like
/orders/{id},MapGet,MapPutandMapDeleteused for their real meanings,TypedResults.Createdwith aLocationheader,ProblemDetailsfor errors andCache-ControlorETagheaders where reads are cacheable. Statelessness means no in-memory session; if I need state across requests it goes into the resource or a shared store.The mistake I see is calling any JSON-over-HTTP API RESTful, including RPC endpoints like
/api/createOrderthat use POST for everything. What most of us build is Richardson level 2: resources plus HTTP semantics, without hypermedia. I'm comfortable saying that honestly; the senior point is knowing which constraints you've kept, which you've dropped, and what that costs your clients."
| Constraint | Means | Property you get | ASP.NET Core / Azure shape |
|---|---|---|---|
| Client-server | UI and data storage evolve separately | Independent deployment | SPA or mobile app + API |
| Stateless | No server-side session between requests | Horizontal scale, simple failover | JWT bearer tokens, no sticky sessions |
| Cacheable | Responses declare cacheability | Lower latency and load | Cache-Control, ETag, output caching, Azure Front Door |
| Uniform interface | Standard way to identify and change resources | Generic tooling and intermediaries | URIs, methods, status codes, media types, links |
| Layered system | Client sees one layer only | Gateways, CDNs, proxies can be inserted | Azure API Management, YARP |
| Code on demand (optional) | Server can send executable code | Extensibility | Browsers running server-sent JavaScript; rare for JSON APIs |
| Part | Example |
|---|---|
| Identification of resources | /customers/42/orders/1001 |
| Manipulation through representations | PUT a JSON body that replaces the order |
| Self-descriptive messages | Content-Type: application/json, 201 Created, Cache-Control: max-age=60 |
| Hypermedia as the engine of application state | "links": { "cancel": { "href": "/orders/1001/cancellation" } } |
Hypermedia as the engine of application state means the client starts at one entry URL and from then on only follows links and forms the server puts in each response, exactly as a browser follows links in HTML. If an order is already shipped, the server simply omits the cancel link, so the client doesn't need to duplicate the business rule "only unshipped orders can be cancelled", and the server can move resources to new URLs without breaking clients. The cost is a richer media type (HAL, JSON:API, Siren), clients written to follow links rather than build URLs, and more design effort, which is why most JSON APIs skip it and rely on OpenAPI documentation instead.
| Academic REST | Typical "RESTful" API |
|---|---|
| Hypermedia drives every transition | URLs documented in OpenAPI and hard-coded in clients |
| Media types define semantics | application/json plus a schema |
| Clients discover capabilities | Clients read docs and SDKs |
A [team] moved session state from in-memory ISession to the request (JWT claims plus resource state in Azure SQL). That removed sticky sessions on the load balancer, and scaling from [2 to 6] instances during a sale cut p95 latency from [~900 ms to ~250 ms] without users being logged out during deployments.
Checks that the candidate knows REST is an architectural style with specific constraints and can separate textbook REST from what teams actually ship.
Green flags
Red flags
Fielding co-authored HTTP/1.1 and described REST in chapter 5 of his 2000 dissertation as the style that explained why the web scaled. He derived it by starting from "no constraints" and adding one at a time, each giving a property (scalability, visibility, evolvability) at some cost (usually efficiency).
Client Instance A Instance B
| GET /orders (token) --> | serves |
| GET /orders/7 (token) ---------------> | serves (no shared session needed)
Resource state (an order in SQL) lives on the server; that's fine. What REST forbids is application/session state kept between requests on the server. Each request must be understandable on its own. Cost: requests are bigger (a token every time), but any instance can answer and a failed instance loses nothing.
Intermediaries can only cache what the response labels. Cache-Control: public, max-age=300 lets Azure Front Door serve 5 minutes of reads; ETag lets clients revalidate cheaply with If-None-Match and get 304 Not Modified.
Client -> Azure Front Door -> API Management -> YARP -> ASP.NET Core
Each layer only knows its neighbours. This is why X-Forwarded-* headers exist: the origin needs to reconstruct what the client actually sent.
Using the same methods and status codes for every resource means a generic gateway can retry PUTs, a CDN can cache GETs and a browser can follow links. The cost Fielding names is efficiency: data is transferred in a standard form rather than one optimised for each application. That is one reason gRPC exists for internal, chatty calls.
Fielding has said (2008, "REST APIs must be hypertext-driven") that without hypermedia an API is not REST. The Richardson maturity model puts that as level 3. Most production APIs stop at level 2 and use OpenAPI for discoverability instead.
MapGet("/orders/{id}") and MapPut, then call it through curl -i and list which parts of the response are "self-descriptive".ISession to an API, run two instances behind YARP without sticky sessions, and watch requests lose state.Cache-Control: public, max-age=60 to a GET and observe a browser or proxy serving it without hitting the server (check the server log).A small Minimal API that respects the main constraints: resource URIs, method semantics, self-descriptive responses, cacheability and no server session.
// Program.cs (.NET 10)
using System.Collections.Concurrent;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddProblemDetails(); // self-descriptive errors (RFC 9457)
var app = builder.Build();
var orders = new ConcurrentDictionary<int, Order>();
var nextId = 0;
// Resource identification: /orders/{id}. Stateless: nothing kept between calls except resource state.
app.MapGet("/orders/{id:int}", (int id, HttpContext ctx) =>
{
if (!orders.TryGetValue(id, out var order))
return Results.Problem(statusCode: 404, title: "Order not found");
// Cacheable: label the response so clients and proxies may reuse it.
ctx.Response.Headers.CacheControl = "private, max-age=30";
return Results.Ok(order);
});
// Manipulation through representations: the client sends a representation, the server creates a resource.
app.MapPost("/orders", (CreateOrder cmd) =>
{
var id = Interlocked.Increment(ref nextId);
var order = new Order(id, cmd.CustomerId, cmd.Total);
orders[id] = order;
return Results.Created($"/orders/{id}", order); // 201 + Location
});
app.Run();
public sealed record Order(int Id, int CustomerId, decimal Total);
public sealed record CreateOrder(int CustomerId, decimal Total);
ISession, static dictionaries). Why it is wrong: It breaks statelessness, forces sticky sessions and loses state on restarts or scale-in. Instead: Put session data in the token, the resource, or a shared store such as Redis.POST /api/createOrder) RESTful. Why it is wrong: There are no resources and no method semantics, so caches and retries can't help. Instead: Model resources (POST /orders) and use methods for their meaning.no-store copied everywhere. Why it is wrong: Without explicit Cache-Control or ETag, every read hits the database, conditional requests (304) are impossible and intermediaries may apply heuristic caching you didn't intend; blanket no-store throws away the cacheability constraint entirely. Instead: Decide cacheability per endpoint (private, max-age=30, public for shared reference data, no-store only for sensitive data) and add ETags for revalidation.Seniors treat REST as a menu of constraints with known payoffs, not a purity test. Statelessness and cacheability are the ones that pay for themselves operationally: they let you scale out on Azure App Service or Container Apps without session affinity and let Azure Front Door or output caching absorb read load. Hypermedia pays off mainly for long-lived public APIs with many independent clients, and even then OpenAPI plus good versioning usually wins on cost.
What I measure: cache hit ratio at the CDN, the share of requests that need affinity (should be zero), and how often clients break when we change URLs (a signal that hypermedia or better versioning would help).
| Constraint | Keep it when | Cost | Consider dropping when |
|---|---|---|---|
| Stateless | Almost always | Larger requests (tokens) | Real-time connections (SignalR) |
| Cacheable | Read-heavy resources | Invalidation complexity | Highly personalised, rapidly changing data |
| Uniform interface (methods, status codes) | Any HTTP API | Some inefficiency vs custom RPC | Internal high-throughput calls (gRPC) |
| Hypermedia | Public APIs with many clients and evolving workflows | Design and client complexity | Internal APIs with a known SPA or mobile client |
HTTP is a request/response protocol: method + path + headers (+ body) in, status + headers (+ body) out.
GET/HEAD/OPTIONS are safe; GET, PUT, DELETE are idempotent (repeating has the same effect); POST and usually PATCH are not, so retries need an idempotency key.Content-Type, Accept, Authorization, Cache-Control, ETag/If-None-Match, Retry-After, traceparent.GET reads, POST creates or runs a command, PUT replaces a resource at a known URI, PATCH partially updates it, DELETE removes it, HEAD is GET without the body, and OPTIONS asks what is allowed (used by CORS preflight).
These properties are a contract that caches, proxies, browsers and retry policies rely on: a gateway may retry a timed-out PUT but must not blindly retry a POST. Breaking the contract, such as changing state on GET, causes duplicate side effects and crawler disasters.
Last updated 23 Nov 2026.