A REST API (Representational State Transfer Application Programming Interface) is a way for software systems to communicate with each other over the internet using a standardized set of conventions built on top of HTTP - the same protocol your browser uses to load web pages.

When you open a weather app and see current conditions for your city, the app is asking a remote server for that data through a REST API. When you post a photo on a social platform, your device sends that photo to the platform's servers through a REST API.

When an e-commerce site confirms your order and charges your card, it is communicating with a payment processor's system through a REST API in real time.

REST is not a protocol, a tool, or a formal specification. It is an architectural style: a set of constraints for how distributed systems should be designed to communicate reliably, scalably, and simply over HTTP.

To grasp how the modern web works under the hood, you have to understand REST, since REST APIs act as the connective tissue tying almost every digital product and service together.

A 2023 survey by Postman (the API development platform used by over 30 million developers) found that 89 percent of developers said they use REST APIs in their work. That makes REST by far the dominant API architecture.

RapidAPI's 2023 State of APIs Report found that the number of publicly available APIs had grown substantially, the vast majority of them RESTful.

"The key abstraction of information in REST is a resource. Any information that can be named can be a resource."

Roy Fielding, Architectural Styles and the Design of Network-based Software Architectures (2000)

The Origins: Roy Fielding's Dissertation

REST was defined in 2000 by Roy Fielding in his doctoral dissertation at the University of California, Irvine, titled Architectural Styles and the Design of Network-based Software Architectures.

Fielding was not working in the abstract - he was one of the principal authors of the HTTP/1.1 specification (RFC 2616, since superseded by RFCs 7230-7235 and RFC 9110) and a co-founder of the Apache HTTP Server project.

He had spent years building the infrastructure of the web and was trying to articulate the architectural principles that had made the World Wide Web scale so successfully.

Fielding saw that specific constraints made the web work as well as it did. They were how HTTP worked, how URLs identified resources and how responses could be cached and passed through intermediaries.

He turned those observations into six architectural constraints that, when applied consistently to API design, give systems the same strengths the web itself showed: scalability, simplicity, loose coupling and visibility.

Those constraints became REST, and they have since been applied to build the APIs that power virtually every digital product and service.

Fielding's dissertation has been cited over 12,000 times according to Google Scholar and remains the definitive reference for understanding what REST actually means - as opposed to the loose, colloquial usage the term has acquired in industry practice.

It is worth noting that many APIs described as "RESTful" in practice do not fully implement Fielding's constraints. The term has become somewhat diluted in common usage to mean any HTTP-based API that uses JSON and standard HTTP methods.

Fielding himself has written critically about this dilution, arguing that APIs that do not implement hypermedia controls (HATEOAS) should not be called RESTful.


The Six REST Constraints

Six constraints were defined by Fielding (five required plus optional code on demand) that characterize a REST architecture. All of them are not implemented perfectly by every REST-style API but grasping them makes clear what REST is trying to achieve and explains why it works as well as it does.

1. Client-Server Architecture

The client (a browser, mobile app, or other API consumer) and the server (which stores and manages data) are separated. The client is responsible for the user interface; the server is responsible for data storage and business logic. Neither knows the internal implementation details of the other.

With this separation, each side can evolve independently and a mobile app can be redesigned without altering the server. Migration of the server's database from PostgreSQL to MongoDB can go through without the client knowing as long as the API contract between them stays consistent.

That independence makes it possible for one API to supply a web application, a mobile app, a third-party integration and an internal analytics dashboard all at once.

2. Statelessness

Statelessness is the most operationally significant REST constraint. It means that each request from a client to a server must contain all of the information the server needs to process it. The server does not store any client context between requests.

No session state. No "remember who I am from the last request." If authentication is required, the credentials or token must be sent with every request. If context is needed (which page of results, what filter is applied, what language to respond in), it must be encoded in the request itself.

This constraint has profound implications for scalability. Because no server needs to remember which client it has been talking to, any server instance in a cluster can handle any request.

Add more servers, and you can handle more requests - no shared session storage, no sticky sessions, no complex state synchronization required. This is why stateless architectures dominate cloud computing and why REST APIs scale so well behind load balancers.

Amazon's engineering blog (2023) reported that their internal services handle over 100 billion API calls per day, a scale made possible in large part by the stateless architecture of their service-to-service communication.

3. Cacheability

Responses should explicitly indicate whether they can be cached and for how long. Cached responses reduce server load and latency, often dramatically. HTTP already provides rich caching semantics through headers like Cache-Control, ETag and Last-Modified and REST leverages these fully.

For 60 minutes, a GET request that fetches a product catalog could be cached. An order creation request sent by POST should never get cached. When fetching a user's profile with a GET request, an ETag may be used so that the client can see if the data has changed without having to download it again.

Proper cache control headers communicate these policies to clients and to any intermediary caches (CDNs, reverse proxies) between them.

Akamai Technologies (2023) said that effective caching strategies bring down origin server load by 60-80 percent for most web apps. That brings a cut in infrastructure costs as well as swifter response times for users.

4. Uniform Interface

What makes REST recognizable and interoperable across different systems, teams and organizations is the uniform interface. All REST APIs follow the same conventions for identifying and manipulating resources.

  • Resource identification: Every resource is identified by a URL (Uniform Resource Locator)
  • Resource manipulation through representations: Clients interact with resources through representations - typically JSON documents - that contain enough information to modify or delete the resource
  • Self-descriptive messages: Each request and response includes enough metadata (content type, status code, caching directives) to describe how to process it
  • Hypermedia as the Engine of Application State (HATEOAS). Responses contain links to related resources and available actions that let clients move around the API dynamically.

Of all constraints, HATEOAS gets implemented least often in practice. Real-world REST APIs most often send back data with no navigation links and clients have to build URLs out of documentation instead of finding them in responses. That is why Fielding says most "REST" APIs are not actually RESTful.

5. Layered System

A client cannot tell whether it connects directly to the application server or goes through an intermediary such as a load balancer, a CDN, a caching proxy, an API gateway or a security layer. This transparency lets intermediaries be added or removed without changing how the client works.

When put into practice, a standard API request goes through Cloudflare for DDoS protection, an AWS Application Load Balancer that distributes traffic. An API gateway such as Kong or AWS API Gateway that handles rate limiting and authentication before it finally reaches the application server.

The client sends one HTTP request and gets one HTTP response without knowing about the layers in between.

6. Code on Demand (Optional)

By sending executable code such as JavaScript that the client runs, servers can add to what clients can do. That is the only optional constraint and in practice it applies mainly to web browsers that get and run JavaScript from servers instead of to most API clients that take in data rather than executable code.


Resources and URLs: The Nouns of REST

In REST, everything is a resource: a user, an order, a product, a message, an article, a payment. Resources are the nouns of the API. They are identified by URLs that follow predictable conventions.

Good REST URL design makes APIs intuitive and self-documenting:

GET    /articles           -> list all articles
GET    /articles/42        -> get article with ID 42
POST   /articles           -> create a new article
PUT    /articles/42        -> replace article 42 entirely
PATCH  /articles/42        -> partially update article 42
DELETE /articles/42        -> delete article 42

Resources can be nested to express relationships:

GET    /users/7/orders     -> all orders for user 7
GET    /users/7/orders/12  -> order 12 belonging to user 7

The URL identifies what the resource is. The HTTP method identifies what to do with it.

This separation of noun and verb is a core REST design principle and is what makes well-designed REST APIs readable even to people who have never seen the documentation.

Naming conventions matter. Style guides from Google, Microsoft and Stripe express the industry consensus.

ConventionExampleWhy
Plural nouns for collections/articles not /articleCollections contain multiple items
Lowercase with hyphens/blog-posts not /blogPostsURLs are case-sensitive; hyphens are readable
No verbs in URLs/articles not /getArticlesThe HTTP method provides the verb
Nesting for relationships/users/7/ordersExpresses the parent-child relationship
Query parameters for filtering/articles?status=published&sort=dateKeeps the URL structure clean

HTTP Methods: The Verbs of REST

MethodPurposeSafeIdempotentTypical Response Code
GETRetrieve a resourceYesYes200 OK
POSTCreate a new resourceNoNo201 Created
PUTReplace a resource entirelyNoYes200 OK
PATCHPartially update a resourceNoNo*200 OK
DELETERemove a resourceNoYes204 No Content
HEADRetrieve headers only (no body)YesYes200 OK
OPTIONSList allowed methods for a resourceYesYes200 OK

Safe means the operation does not modify the resource - calling a safe method is a pure read with no side effects. Idempotent means calling the method multiple times has the same effect as calling it once.

Reliability depends a great deal on these properties. Safe methods can be cached aggressively. Idempotent methods can be retried on network failure without any risk of making duplicate records or corrupting data.

The GET/POST/PUT/DELETE pattern lines up roughly with the classic database CRUD operations of Create, Read, Update and Delete. That is why REST feels intuitive to developers who have worked with databases.


HTTP Status Codes: How Servers Respond

REST uses standard HTTP status codes to communicate what happened with each request.

Instead of giving 200 OK for every response and putting errors in the body of the response, a well-designed API uses these codes exactly. A pattern known as "200 OK with an error message" breaks HTTP semantics and makes automated error handling unreliable by that approach.

CodeMeaningWhen to Use
200 OKSuccessSuccessful GET, PUT, PATCH
201 CreatedResource createdSuccessful POST that creates a new resource
204 No ContentSuccess, no bodySuccessful DELETE
301 Moved PermanentlyResource relocatedURL has permanently changed
304 Not ModifiedCached version is currentClient's cached copy is still valid
400 Bad RequestClient error in requestMalformed JSON, invalid parameters
401 UnauthorizedAuthentication requiredMissing or expired token
403 ForbiddenAuthenticated but not permittedValid token but insufficient permissions
404 Not FoundResource does not existWrong ID or URL
409 ConflictResource conflictDuplicate unique field, version conflict
422 Unprocessable EntityValidation failedValid JSON but business rules violated
429 Too Many RequestsRate limitedClient exceeding rate limit
500 Internal Server ErrorServer errorUnhandled exception on the server
503 Service UnavailableServer temporarily downMaintenance, overload, or dependency failure

Status codes allow clients to handle different outcomes programmatically. A client that receives a 401 knows to re-authenticate. A client that receives a 429 knows to back off and retry after a delay.

When a client gets a 503, it knows the server is temporarily unavailable and can retry with exponential backoff. The machine-readable communication layer that this creates is what makes API integrations robust.


Authentication in REST APIs

Because REST is stateless, authentication credentials must accompany every request. The three dominant patterns each serve different use cases.

API Keys

The simplest approach: a secret string sent in a request header or query parameter. Used for server-to-server communication and developer tool access where the client is a trusted application.

Authorization: ApiKey sk_live_abc123def456

Though easy to put in place, API keys have limits. They identify the application rather than the user and cannot convey fine-grained permissions or expiration. These are suitable for server-side integrations as well as development environments but they are not right for user-facing authentication.

Bearer Tokens (JWT)

JSON Web Tokens (JWT) are signed tokens that encode claims about the user - their identity, their permissions, and when the token expires. The server validates the signature mathematically without consulting a database, making JWT authentication fast and scalable.

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Three parts make up a JWT. The header says what algorithm and token type is used. The payload contains claims about the user and the signature is cryptographic verification.

Using a secret key, the server signs the token. Any following request that carries that token can be validated by checking the signature alone without any database query.

JWTs become especially well suited for microservice architectures in which several services each have to validate authentication on their own.

OAuth 2.0

The industry standard for delegated authorization - allowing a third-party application to access resources on a user's behalf without receiving their password. OAuth 2.0 issues access tokens with defined scopes (what the token allows) and expiration times.

Behind "Sign in with Google," "Connect with GitHub" and almost every third-party integration on today's web lies this mechanism.

OAuth 2.0 is a framework rather than a single protocol. Its four grant types (authorization code, implicit, client credentials and resource owner password) serve different security contexts.

The authorization code flow with PKCE (Proof Key for Code Exchange) is now recommended for virtually all client-facing applications, including single-page applications and mobile apps.


JSON: The Default Language of REST

While REST does not mandate any particular data format, JSON (JavaScript Object Notation) has become the overwhelming standard. It is lightweight, human-readable, and natively supported in virtually every programming language.

A typical REST response for a single resource:

{
  "id": 42,
  "title": "What Is REST API",
  "author": {
    "id": 7,
    "name": "Jane Smith"
  },
  "published_at": "2024-03-15T10:30:00Z",
  "tags": ["api", "web development", "programming"],
  "_links": {
    "self": "/articles/42",
    "author": "/users/7",
    "comments": "/articles/42/comments"
  }
}

The _links field in this example represents HATEOAS - providing navigation links that allow the client to discover related resources from the response itself.

Very few APIs go all the way with this in practice, yet the pattern shows what Fielding had in mind for a genuinely RESTful API.

Around 2012 to 2015, JSON took over from XML as the preferred format for web APIs. It is more compact, less verbose, needs no schema definition and fits naturally with data structures in JavaScript, Python, Ruby, Go and most other languages.

Some enterprise, financial services and legacy SOAP-based contexts still use XML but ProgrammableWeb says that approximately 95 percent of new API implementations use JSON across the whole of 2023.


REST vs. GraphQL vs. gRPC

REST dominates but it is not universal. Two other architectural approaches have won large adoption each for particular use cases.

GraphQL

Internally developed at Facebook in 2012 and made public in 2015, GraphQL is an API query language in which clients say precisely what data they want in one request.

Under REST, consumers have to take whatever data structure each endpoint defines and with GraphQL the client can ask for the user's name and their last five orders including each order's total and status but not the full order details. That gets around two specific problems REST has.

  • Over-fetching: Getting more data than needed (downloading a full user object with 30 fields when you only need the name)
  • Under-fetching: Needing multiple sequential requests to get related data (fetching a user, then fetching their orders, then fetching each order's items)

There are real trade-offs. The learning curve for GraphQL is steeper and server implementation is more complex. Queries are POST requests with variable bodies that are not cacheable GETs. Caching is less direct and deep nested queries from clients can bring about performance issues by causing costly database operations.

REST is most often simpler for simple and stable data structures. When data is complex and interconnected with highly variable client needs, GraphQL can be much more efficient.

gRPC

gRPC (Google Remote Procedure Call) uses Protocol Buffers, a binary serialization format, instead of JSON and runs on HTTP/2 instead of HTTP/1.1. It is much faster and more efficient than REST for high-volume, low-latency communication, particularly between internal microservices.

gRPC supports bidirectional streaming (both client and server can send messages simultaneously), strongly typed contracts defined in .proto files, and automatic code generation for client and server stubs in multiple languages. Google uses gRPC internally for communication between microservices handling billions of requests per day.

The trade-off is that gRPC is not human readable. Its binary format needs tooling to inspect, does not function natively in browsers (which calls for a proxy such as gRPC-Web) and demands that both client and server use the same Protocol Buffer schema definition.

Where performance matters most, it is the right choice for internal service-to-service communication and where developer experience and accessibility count, REST is still the standard for public-facing APIs.

FeatureRESTGraphQLgRPC
ProtocolHTTP/1.1 or HTTP/2HTTP/1.1 or HTTP/2HTTP/2
Data formatJSON (typical)JSONProtocol Buffers (binary)
Client flexibilityLow (server defines responses)High (client defines queries)Low (schema-defined)
CachingEasy (HTTP caching)Complex (POST-based)Custom implementation
Browser supportNativeNativeRequires proxy
Learning curveLowMediumHigh
Best forPublic APIs, simple CRUDComplex data, mobile clientsInternal services, streaming
Adoption~89% of developers~35% of developers~11% of developers

Adoption figures from Postman's 2023 State of the API Report.


What Makes a REST API "Good"

A technically RESTful API can still be frustrating to use if it violates common conventions or neglects developer experience. The best APIs in production - Stripe, Twilio, GitHub - share characteristics that go beyond the six REST constraints.

Consistent and Predictable Naming

Plural nouns for collections (/articles, not /article or /getArticles). Consistent casing. Predictable patterns that let a developer guess an endpoint's URL correctly before reading the documentation.

Meaningful Error Messages

Errors should return appropriate 4xx/5xx status codes with structured error bodies that explain what went wrong and, ideally, how to fix it. The Stripe API is widely regarded as the gold standard here. Every error includes a type, a code, a human-readable message and a documentation URL.

Versioning

Major breaking changes should be introduced through versioned URLs (/v1/articles, /v2/articles) or header-based versioning, to avoid breaking existing clients. The industry has not converged on a single versioning strategy, but URL-based versioning is the most common and the most visible.

Pagination, Filtering, and Sorting

List endpoints should return paginated results with metadata about total count and navigation links. They should support query parameters for filtering (?status=published&author_id=7) and sorting (?sort=created_at&order=desc).

There is a reliability risk in returning unbounded result sets. A collection with 10 million records should never come back in a single response.

Rate Limiting

APIs should enforce and communicate rate limits using standard headers (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset) and return 429 Too Many Requests when limits are exceeded. Rate limiting protects both the API provider and well-behaved clients from the effects of misbehaving ones.

Documentation

OpenAPI Specification, formerly known as Swagger, documents endpoints, parameters, request bodies and response schemas in a machine-readable format that can generate interactive documentation, client SDKs and test suites.

"A REST API is a product. Its users are developers. Good API design means those developers can figure out how to use it without reading the source code."

widely attributed, API design community

Building Your First REST API: A Practical Orientation

Developers new to API development find that the practical world of REST frameworks is wide but well mapped.

LanguagePopular REST FrameworksNotable Example
JavaScript/Node.jsExpress.js, Fastify, Nest.jsExpress powers millions of APIs globally
PythonFastAPI, Django REST Framework, FlaskFastAPI combines performance with automatic docs
GoGin, Echo, ChiGin is used at scale by companies like Stripe
JavaSpring Boot, QuarkusSpring Boot dominates enterprise Java
RubyRails (API mode), SinatraRails API mode strips frontend concerns
RustActix Web, AxumEmerging for performance-critical APIs

What matters less than the design principles put in place is the choice of framework. Any of these frameworks can produce a well-designed REST API that follows the same conventions for URL structure, HTTP methods, status codes and error handling. The constraints are language-agnostic and that is, after all, the point.


Key Takeaways

  • REST is an architectural style - a set of constraints originally defined by Roy Fielding in his 2000 doctoral dissertation - not a protocol or specification
  • The six constraints are client-server separation, statelessness, cacheability, uniform interface, layered system, and optional code on demand
  • Statelessness is the most operationally important constraint: every request is self-contained, enabling horizontal scaling to billions of requests per day
  • HTTP methods map to operations on resources. GET retrieves, POST creates, PUT replaces, PATCH partially updates and DELETE removes.
  • HTTP status codes communicate outcomes precisely and should be used correctly rather than returning 200 for everything
  • Authentication. The system deals with authentication through API keys, JWT bearer tokens or OAuth 2.0 and each approach is suited to different trust levels as well as use cases.
  • GraphQL deals with over-fetching as well as under-fetching for complex data requirements. Internal service communication with gRPC is faster but public-facing APIs continue to use REST by default as the standard for public APIs.
  • Developer experience gets treated as a first-class concern by the best REST APIs. These have consistent naming, meaningful errors, full documentation and behavior that is predictable.

Sources & Further Reading

  1. Fielding, R. T. Architectural Styles and the Design of Network-based Software Architectures. Doctoral dissertation, University of California, Irvine, 2000. Available at: View source
  2. Fielding, R. T., & Taylor, R. N. "Principled Design of the Modern Web Architecture." ACM Transactions on Internet Technology, vol. 2, no. 2, 2002. View source
  3. Richardson, L., Amundsen, M., & Ruby, S. RESTful Web APIs. O'Reilly Media, 2013.
  4. Masse, M. REST API Design Rulebook. O'Reilly Media, 2011.
  5. Postman. "2023 State of the API Report.", 2023.
  6. RapidAPI. "2023 State of APIs Report.", 2023.
  7. SmartBear. "State of API 2023.", 2023.
  8. Fielding, R. T. "REST APIs Must Be Hypertext-Driven.", 2008.
  9. Google. "API Design Guide.", 2023.
  10. Microsoft. "RESTful Web API Design.", 2023.
  11. Stripe. "API Reference.", 2024.
  12. Mozilla Developer Network. "HTTP Status Codes." View source, 2024.
  13. IETF. "RFC 7231: Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content." View source, 2014.
  14. Facebook Engineering. "GraphQL: A Data Query Language.", 2015.
  15. Google. "Introduction to gRPC." View source, 2024.