REST API

REST API provides an interface for applications to interact with sites by sending and receiving data as JSON (JavaScript Object Notation) objects to the endpoints (URLs) to query, modify and create content on the site.

In the REST APIs communication between the client and the server is easy. The server acts as a data store, and the client retrieves and stores data. This is the main difference between the REST API and the SOAP API.

A single uniform interface of REST API defines an interface between client and server and simplifies the architecture so that its services can be managed independently.

REST is resource-based, and resources are identified by URI.

REST API Request Parts


  • An Endpoint URL with a domain, port, path, and/or querystring.
  • The HTTP method to implement CRUD (create, read, update, and delete ) operations.
  • HTTP headers containing information such as authentication tokens or cookies.
  • Body Data: JSON string with data.

REST API Example


POST JSON String Example Live Request
POST /echo/post/json HTTP/1.1
Host: reqbin.com
Accept: application/json
Content-Type: application/json
Content-Length: 45

{"login":"my-login","password":"my-password"}


Server Response with JSON String
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19
Connection: keep-alive

{"success":"true"}

The response payload can be an image, an audio file, and so on. Data responses are typically JSON-strings.

REST doesn’t have a standard messaging system; response depends on the way the request is formulated; in case of failure REST handles messaging errors by retrying.

REST has layered system with an opportunity for each component to interact only within the immediate layer. The data are labeled implicitly or explicitly as cacheable or non-cacheable.
Last updated: Viewed: 434 times