A REST API (also known as RESTful API) is an application programming interface that conforms to the constraints of REST architecture. REST stands for representational state transfer.
An API, or application programming interface, is a set of definitions and protocols for building and integrating application software. It’s sometimes referred to as a contract between an information provider and an information user—establishing the content required from the consumer (the call) and the content required by the producer (the response).
In other words, if you want to interact with a computer or system to retrieve information or perform a function, an API helps you communicate what you want to that system so it can understand and fulfill the request.
REST is a set of architectural principles, not a protocol or a standard. API developers can implement REST in a variety of ways.
What is a REST API example?
The Twitter API comes to mind. It’s a sound example because it implements the REST API. The Stripe API is also used quite frequently due to the advanced features like enlargement and pagination. It’s a well-used model of how REST APIs work. The Slack API is also used with REST APIs and GitHub API v3. Stress-free utilization makes it quick to implement.
Other popular examples to consider are Google APIs. Google has many uses with its APIs including YouTube API, Google Analytics API, Google Font API, Blogger API, plus many more. They all use REST APIs as part of their technology. Other social media platforms using APIs such as Facebook and LinkedIn are using REST APIs.
Architectural constraints of REST API:
In order for an API to be considered RESTful, it has to conform to these criteria:
Client-Server: This constraint operates on the concept that the client and the server should be separate from each other and allowed to evolve individually.
Stateless: REST APIs are stateless, meaning that calls can be made independently of one another, and each call contains all of the data necessary to complete itself successfully.
Cache: Because a stateless API can increase request overhead by handling large loads of incoming and outbound calls, a REST API should be designed to encourage the storage of cache-able data.
Uniform Interface: The key to the decoupling client from server is having a uniform interface that allows independent evolution of the application without having the application’s services, or models and actions, tightly coupled to the API layer itself.
Layered System: REST APIs have different layers of their architecture working together to build a hierarchy that helps create a more scalable and modular application.
Code on Demand: Code on Demand allows for code or applets to be transmitted via the API for use within the application.
REST API framework ( Source: https://towardsdatascience.com/)
There are four main methods that are generally used when making requests with a REST API: GET, POST, PUT, and DELETE. While these methods are mostly self-explanatory, the main takeaway is that data can be retrieved, added, or deleted from any given database using these methods. GET requests are the most common type of request mainly used to retrieve data from a server or database. POST requests are used to send data to an API in order to create or update an entry. Similarly to POST, PUT requests are used to send data to an API in order to create or update an entry, however, PUT requests are idempotent, meaning that the application of this method multiple times can be done without changing the final result. Finally, DELETE requests are used to delete certain entries within the database.
What are the uses of REST APIs?
REST APIs have many uses because the API calls are stateless. They can also be beneficial in cloud applications. Cloud computing and microservices are on the road to making RESTful API design the directive for the future.
Stateless elements can be easily redistributed is there is a failure on hand. Another use is that they can measure to adjust for load changes. The reason being that any specific request can be pointed to any request of an element. Nothing can be saved that has to be in memory for the next transaction. This makes REST APIs the go-to component for web use and cloud computing.