top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

Anatomy of a REST Request

Any REST request includes four essential parts:

  • HTTP method

  • Endpoint

  • Headers

  • Body

An HTTP method describes what is to be done with a resource. There are four basic methods also named CRUD operations:

POST to Create a resource,

GET to Retrieve a resource,

PUT to Update a resource, and

DELETE to Delete a resource.

Endpoint (or route) is the URL you request for. It contains a Uniform Resource Identifier (URI) indicating where and how to find the resource on the Internet. The most common type of URI is a Unique Resource Location (URL), serving as a complete web address.

Headers store information relevant to both the client and server. Mainly, headers provide authentication data — such as an API key, the name or IP address of the computer where the server is installed, and the information about the response format.

Body is used to convey additional information to the server. For instance, it may be a piece of data you want to add or replace.

What is Endpoints?

An endpoint is the place of interaction between applications. API refers to the whole set of protocols that allows communication between two systems while an endpoint is a URL that enables the API to gain access to resources on a server.

Endpoint plays a vital role in ensuring that the software which is interacting with the API is functioning correctly. Therefore, the performance and productivity of APIs depend on its ability to interact and communicate with endpoints effectively.

The well-formed Endpoint format:

scheme://host: port/path?queryString#fragment

Example:

which is composed of the following parts:

Endpoint Path : /homes

Query String : ?limit=5&format=json

Rest API URL : BaseURL + Endpoint path +Query string

Base URL :

The base URL is defined by schemes , host and base path on the root level of the API specification.

schemes are the transfer protocols used by the API, either HTTP or HTTPS.

host is the DomainName or IP address of the host serves API

Base Path is the URL prefix for all API paths, relative to the host root. It must start with a leading slash /. If base Path is not specified, it defaults to /, that is, all paths start at the host root.

Endpoint Path :

The Endpoint is a specific “point of entry” in an API. You attach these to the end of your Base URL and get results depending on which Endpoint you choose.

Query String :

Query String can be defined as the optional key-value pairs that appear after the question mark in the URL. Query parameters are appended to the end of the URL, using a ‘?’. The question mark sign is used to separate Endpoint path and query parameters. If you want to add multiple query parameters, an ‘&’ sign is placed in between them to form.

Some of the API endpoint response and Error Code Series

1XX code series is about temporary information

Example:

100 Continue

101 Switching Protocols

102 Processing

2xx code series is meant to success, the client accepts the Request, being processed successfully at the server

Example:

200 OK

201 Created

202 Accepted

3xx code series most of them indicates the URL redirection.

Example:

300 Multiple Choices

301 Moved Permanently

302 Found

4xx code series specific to client side error

Example:

400 Bad Request

401 Unauthorized

403 Forbidden

404 Not Found

5xx code series specific to server side error

Example:

500 Internal Server Error

501 Not Implemented

502 Bad Gateway

503 Service Unavailable

6xx codes always indicate that a request failed completely and were not executed.

Example:

600 Empty access token

601 Access token invalid

602 Access token expired

7xx errors indicate that the request failed, either because no data was returned, or the request was incorrectly parameterized, such as including an invalid date, or missing a required parameter.

Example:

701 cannot be blank

702 No data found for given search scenario

703 Feature is not enabled for the subscription

2,346 views1 comment

Recent Posts

See All
bottom of page