Developer

REST

Definition: Architectural style for designing web APIs.

REST: Representational State Transfer

Overview & History

REST, or Representational State Transfer, is an architectural style for designing networked applications. It was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation as a set of principles for building scalable web services. RESTful services use HTTP requests to perform CRUD (Create, Read, Update, Delete) operations on resources, which are identified by URLs.

REST developer glossary illustration

Core Concepts & Architecture

Key Features & Capabilities

Installation & Getting Started

REST itself is not a protocol or software to install but a set of guidelines. To start using REST, you can:

  1. Choose a programming language and framework that supports RESTful API development (e.g., Node.js with Express, Python with Flask or Django).
  2. Design your API endpoints with resource-based URIs.
  3. Implement HTTP methods to interact with these resources.

Usage & Code Examples

Here's a simple example of a RESTful API using Node.js and Express:

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

let books = [
  { id: 1, title: '1984', author: 'George Orwell' },
  { id: 2, title: 'To Kill a Mockingbird', author: 'Harper Lee' }
];

// GET all books
app.get('/books', (req, res) => {
  res.json(books);
});

// GET a book by ID
app.get('/books/:id', (req, res) => {
  const book = books.find(b => b.id === parseInt(req.params.id));
  if (!book) return res.status(404).send('Book not found');
  res.json(book);
});

// POST a new book
app.post('/books', (req, res) => {
  const book = {
    id: books.length + 1,
    title: req.body.title,
    author: req.body.author
  };
  books.push(book);
  res.status(201).json(book);
});

// PUT update a book by ID
app.put('/books/:id', (req, res) => {
  const book = books.find(b => b.id === parseInt(req.params.id));
  if (!book) return res.status(404).send('Book not found');

  book.title = req.body.title;
  book.author = req.body.author;
  res.json(book);
});

// DELETE a book by ID
app.delete('/books/:id', (req, res) => {
  const bookIndex = books.findIndex(b => b.id === parseInt(req.params.id));
  if (bookIndex === -1) return res.status(404).send('Book not found');

  const deletedBook = books.splice(bookIndex, 1);
  res.json(deletedBook);
});

app.listen(3000, () => console.log('Server running on port 3000'));

Ecosystem & Community

REST is widely adopted in the web development community. Numerous frameworks and tools support RESTful API development, including:

Comparisons

REST vs. SOAP:

REST vs. GraphQL:

Strengths & Weaknesses

Strengths

Weaknesses

Advanced Topics & Tips

Future Roadmap & Trends

REST continues to be a foundational technology for web services. Trends include:

Learning Resources & References

Continue Exploring

More Developer Terms

Browse the full topic index or move directly into related glossary entries.