What Are the 6 Characteristics of REST API?
The REST API architecture was proposed by Dr. Roy Fielding in his doctoral dissertation in 2000. This architecture has been around for about 23 years, and most popular APIs follow it. Despite its widespread adoption, most programmers still don't know about the six key characteristics that define REST or RESTful APIs.
You can make sure you're not one of those programmers by reading Dr. Fielding's 180-page dissertation. Or, even better, spend a few minutes reading this article, in which we'll go through this list of characteristics and discuss why each one matters. We assure you, the latter option is more interesting and time-efficient.
REST API Basics
Before we dive into the six characteristics, it's helpful to understand how REST APIs work. Feel free to skip this section if you've used REST APIs before.
The REST architecture (and by extension, REST APIs) relies on the concept of resources. A resource can be any data stored on the server. For Facebook, a resource could be status updates. Similarly, for Twitter, a resource could be tweets. You perform actions on these resources. Moreover, each resource has a specific endpoint that allows you to interact with it (read, delete, update, etc.).
In REST APIs, there are four main request types. Since REST is built on top of HTTP, these types are also based on existing HTTP methods:
- GET: Used to retrieve information from the server. A GET request should not change the server state and is typically used to get a representation of a resource.
- POST: Used to send information to the server. A POST request is typically used to create a new resource or update an existing one.
- PUT: Used to update an existing resource. A PUT request should fully replace the current representation of the resource with the one specified in the request.
- DELETE: Used to delete a resource. A DELETE request should remove the specified resource from the server.
The Six Characteristics of REST
REST was created to meet the need for scalable and performant web services. That's why REST emphasizes that APIs built on this architecture follow certain principles that help them remain performant, highly available, extensible, and easily scalable. These principles together form the six characteristics of REST APIs. Let's examine them:
1. Client-Server Architecture
RESTful APIs are built on the client-server architecture principle, meaning the client sends a request to the server, and the server sends a response. The client can be any device or application capable of making HTTP requests, while the server is an application that provides the API and responds to client requests. This characteristic allows separation of concerns, making it easier to develop, maintain, and scale both components independently.
2. Statelessness
RESTful APIs are stateless, meaning each client request to the server contains all the information the server needs to fulfill the request, without relying on previous requests or server-side storage. That's why every authenticated REST request must include an authentication token in the request headers.
This increases the request size, but allows the server to scale without worrying about storing state information between separate requests.

3. Cacheability
It's important to use methods that reduce server load. Therefore, RESTful APIs implement caching. This means API responses can be cached by the client, speeding up response times for subsequent requests to the same resource. This reduces server load and improves performance, as the server doesn't need to generate the same response for every request.
Since each REST request must carry authentication tokens and the necessary state for the server to function, the benefits of this characteristic become quickly apparent for any API with decent traffic. Even with a cache timeout of 5 seconds, it can prevent thousands or millions of requests within seconds.
4. Layered System
Forward-looking APIs need to be modular, and each module should be updatable or replaceable transparently. Consequently, REST requires APIs to be designed as a layered system, where the client interacts with the server through a single endpoint, and the server can interact with multiple internal systems. This provides separation of concerns and allows adding new internal systems, modifying existing ones, or performing maintenance without impacting the client. An example is how the server can update the load balancing mechanism, but the client doesn't need to be informed. The client can continue interacting as before.
5. Code on Demand
This is an optional characteristic because it can lead to undesirable side effects and exploits. This characteristic means that instead of data, the server can send code for the client to execute. This can help extend client functionality and lead to more dynamic and customizable interactions. However, it also requires that the client can understand and execute the code sent back by the server. Therefore, the usage frequency of this characteristic is decreasing. Moreover, if the server is compromised, clients are automatically compromised as well, since they will execute whatever the server responds. This obvious security issue also hinders the adoption of Code on Demand.
6. Uniform Interface
This means the API uses a common set of methods, such as GET, POST, PUT, and DELETE, to access resources, along with a standard format like JSON or XML for requests and responses. This makes it easier for clients to understand and interact with the API, as all resources are accessed uniformly. A uniform interface also simplifies implementing API versioning, since new features can be added by defining new resources and methods without affecting existing ones.
Conclusion
This was a brief overview of the six characteristics that define which APIs can be considered RESTful. You don't need to know them to use RESTful APIs, but it's helpful to understand the background and reasoning behind why REST APIs are implemented the way they are. This will allow you to use them more effectively.
Before we let you go, it would be remiss not to mention our own RESTful API, which helps developers scrape websites and extract needed data without getting blocked. Explore our extensive documentation, take advantage of our generous free monthly plan, and learn more about REST and APIs.


