Skip to content
hostcomplex

What Is a REST API?

Maarten Soetens 3 min read

REST as an Architectural Style for Web APIs

What is a REST API? A REST API is an application programming interface that follows the principles of REST, short for Representational State Transfer. REST is an architectural style, meaning a set of design constraints, rather than a protocol or a product.

Roy Fielding described the style in his doctoral dissertation in 2000. Fielding was also one of the authors of the HTTP specification, and REST reflects how the web itself works. Clients request representations of resources, and servers respond with the current state of those resources. A representation is one format of a resource, such as a JSON document that describes a customer. Most REST APIs run over HTTP and exchange data in formats such as JSON.

The Core Principles Behind REST

  • Resources. Everything the API exposes is a resource with its own URL. A customer, an invoice or a domain each has an address.
  • Client-server separation. The client handles the user interface and the server handles data and rules, so each side can change independently.
  • Statelessness. Each request carries all the information the server needs, and the server keeps no session context between calls.
  • Cacheability. Responses indicate whether they can be stored and reused, which reduces load on the server.
  • Uniform interface. Resources are handled through standard methods and representations, so clients learn fewer special rules.

The full definition also includes a layered system, optional code on demand, and a principle called hypermedia, in which responses contain links to related actions. Many APIs described as RESTful skip hypermedia, which is common in practice.

What RESTful Design Looks Like in Practice

A RESTful API organizes its URLs around nouns and uses HTTP methods for actions. A list of customers lives at a collection address, each customer has its own address, and the method shows what the client wants to do with it. The URL design itself is covered in API endpoints.

A typical REST API therefore uses GET to read, POST to create, PUT or PATCH to update and DELETE to remove. Responses use standard status codes, and the body is usually JSON. Because each call is self-contained and uses standard HTTP features, tools such as browsers, proxies and content delivery networks can often work with the API as well.

REST is a style, not a certification that an API must pass. Two APIs can both be called REST and still differ in naming, error formats and versioning, which is why good documentation matters. REST is often compared with SOAP and GraphQL.

Frequently asked questions

Is REST the same as HTTP?

No. HTTP is the protocol that carries messages between clients and servers and defines methods, status codes and headers. REST is a set of design principles for building APIs on top of HTTP. A REST API uses HTTP, but HTTP is used for many things that are not REST.

Does a REST API have to use JSON?

No. REST does not require a specific data format. JSON is the most common choice because programs can parse it easily, but REST APIs can also return XML, plain text or other formats. The client and server agree on the format through content type headers and the API documentation.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.