image de chargement
Back to glossary

REST (Representational State Transfer)

Software architecture for web APIs based on HTTP, using identifiable resources and standardized methods for communication.

Updated on January 7, 2026

REST (Representational State Transfer) is a software architectural style that defines a set of constraints for creating web services. Introduced by Roy Fielding in 2000, REST uses standard HTTP protocols and methods to enable stateless, scalable, and maintainable client-server communication.

Fundamentals

  • Client-server architecture with separation of concerns between user interface and data storage
  • Stateless communication where each request contains all necessary information
  • Resources identifiable by URI with multiple representations (JSON, XML, HTML)
  • Use of standard HTTP methods (GET, POST, PUT, DELETE, PATCH) to manipulate resources

Benefits

  • Horizontal scalability facilitated by stateless principle and caching
  • Implementation simplicity using existing web standards (HTTP, URI)
  • Interoperability across different platforms and programming languages
  • Optimized performance through native HTTP caching
  • System evolvability with loose coupling between client and server

Practical Example

Here's a REST API for managing users, illustrating fundamental principles and HTTP methods:

user-api.ts
// REST route definitions for "users" resource
import express, { Request, Response } from 'express';

const app = express();
app.use(express.json());

// GET /api/users - Retrieve all users
app.get('/api/users', async (req: Request, res: Response) => {
  const users = await db.users.findAll();
  res.status(200).json({
    data: users,
    meta: { total: users.length }
  });
});

// GET /api/users/:id - Retrieve a specific user
app.get('/api/users/:id', async (req: Request, res: Response) => {
  const user = await db.users.findById(req.params.id);
  if (!user) {
    return res.status(404).json({ error: 'User not found' });
  }
  res.status(200).json({ data: user });
});

// POST /api/users - Create a new user
app.post('/api/users', async (req: Request, res: Response) => {
  const newUser = await db.users.create(req.body);
  res.status(201)
    .location(`/api/users/${newUser.id}`)
    .json({ data: newUser });
});

// PUT /api/users/:id - Completely replace a user
app.put('/api/users/:id', async (req: Request, res: Response) => {
  const updated = await db.users.replace(req.params.id, req.body);
  res.status(200).json({ data: updated });
});

// PATCH /api/users/:id - Partially modify a user
app.patch('/api/users/:id', async (req: Request, res: Response) => {
  const updated = await db.users.update(req.params.id, req.body);
  res.status(200).json({ data: updated });
});

// DELETE /api/users/:id - Delete a user
app.delete('/api/users/:id', async (req: Request, res: Response) => {
  await db.users.delete(req.params.id);
  res.status(204).send();
});

Implementation

  1. Identify and model business resources with plural nouns (/users, /products)
  2. Define coherent and hierarchical URI structure to represent relationships
  3. Implement appropriate HTTP methods respecting their semantics (GET idempotent, POST non-idempotent)
  4. Use standard HTTP status codes (200 OK, 201 Created, 404 Not Found, 500 Internal Error)
  5. Define consistent representation format (JSON recommended) with API versioning
  6. Optionally implement HATEOAS for discoverability (hypermedia as the engine of application state)
  7. Configure cache headers (Cache-Control, ETag) to optimize performance
  8. Secure with authentication (OAuth 2.0, JWT) and mandatory HTTPS

Professional Tip

Respect the idempotence principle: GET, PUT, DELETE must produce the same result on multiple calls. Use PATCH for partial updates rather than PUT which replaces the entire resource. Version your API from the start (v1, v2) via URI or headers to facilitate evolution without breaking existing clients.

  • Swagger/OpenAPI for REST API documentation and specification
  • Postman and Insomnia for API testing and development
  • Express.js, FastAPI, Spring Boot as REST backend frameworks
  • Axios, Fetch API for consuming REST APIs client-side
  • RESTful API Modeling Language (RAML) for API design
  • JSON Schema for payload validation

REST remains the dominant architecture for public web APIs thanks to its simplicity and universal adoption. While alternatives like GraphQL gain popularity for specific use cases, REST offers an excellent balance between performance, maintainability, and standardization for most projects. Its alignment with HTTP standards makes it a strategic choice for interoperable and scalable systems.

Related terms

Themoneyisalreadyonthetable.

In 1 hour, discover exactly how much you're losing and how to recover it.