RESTful API
Learn about the REST API with the help of some examples.
We'll cover the following...
What is a REST API?
The clients' programs use web APIs to communicate with the web servers. A web API takes the client's requests, interacts with the back-end servers, and responds back to the clients.
Many of today's APIs can be classified as REST APIs. Our purpose is not mere understanding but rather drawing insights into the REST architectural style of developing APIs.
Note: A REST API is a web API that conforms to the commonly used REST architectural style.
Many programming languages and protocols use insert
, select
, update
, and delete
. Similarly, interacting with the REST application often involves CRUD operations because the REST-based applications are built around resources that need to be created, read, updated, and deleted. REST APIs are protocol agnostics; however, the underlying protocol they use widely for communication is HTTP. Therefore, the CRUD operations can be easily mapped to major HTTP methods, as shown in the following table.
CRUD One-to-One Mapping with HTTP Methods
CRUD Operation | HTTP Method | Description |
CREATE |
|
|
READ |
|
|
UPDATE |
|
|
DELETE |
|
|
What makes an API RESTful?
In the previous lesson, we studied the REST constraints, collectively called a web architectural style. Now, let's revisit those constraints from a different perspective. This time, we’ll see how an API should follow those constraints that make them a REST API.
-
Client-server: In the client-server setup, communication is initiated by the client via HTTP protocol by calling different HTTP methods. Since client and server are considered independent of each other, applications on both sides can evolve independently without affecting each other.
-
...