The RESTful API requires that requests contain the following basic components:

A unique resource identifier

The server assigns each resource a unique resource identifier. In the case of REST services, the server identifies resources using a universal resource locator (URL). A URL specifies the path to a resource. A URL is similar to a Web site address that you enter in a browser to visit a Web page. The URL is also called the request address and clearly tells the server what the client requires.

Method

Typically, developers implement a RESTful API using the Hypertext Transfer Protocol (HTTP). The HTTP method tells the server what it needs to do with the resource. Below are four common HTTP methods:

GET

Clients use GET to access resources located on the server at a specified URL. They can cache GET requests and send parameters in the RESTful API request to tell the server to filter the data before sending it.

POST

Clients use POST to send data to the server. In doing so, they include data views in the request. Sending the same POST request multiple times has the side effect of creating the same resource multiple times.

PUT

Clients use PUT to update existing resources on the server. Unlike POST, sending the same PUT request multiple times produces the same result in a RESTful web service.

DELETE

Clients use a DELETE request to delete a resource. A DELETE request can change the state of the server. However, if the user does not have proper authentication, the request fails.

HTTP Headers

Request headers are metadata exchanged between the client and server. For example, a request header specifies the format of the request and response, provides information about the status of the request, and so on.

Data

REST API requests can include data for successful operation of POST, PUT and other HTTP methods.

Parameters

RESTful API requests can include parameters that provide the server with more detailed information about the required actions. The following are some types of parameters:

  • Path parameters, which define the details of the URL;
  • Query parameters that request additional information about the resource;
  • Cookie parameters that quickly authenticate clients.