What APIs look like

As we said in Introduction to APIs, there's two parts composing an API, a request and a response.

API requests

An API request must contain certain elements that are necessary for clients to communicate with it. These elements typically include:

  • Request Methods APIs can use different HTTP methods such as GET, POST, PUT, DELETE, PATCH to perform different operations on the server.

  • URL Path APIs typically use URLs (Uniform Resource Locators) to identify the resources that they provide access to. The URL path specifies the location of the resource within the API.

  • Request Body APIs can use request bodies to transmit data from the client to the server. The request body can contain data in different formats such as JSON, XML, or plain text.

  • Headers APIs use headers to transmit metadata along with the request or response. Headers can contain information about the content type, authorization, caching, and other aspects of the request.

API responses

Similarily, responses can contain different elements.

  • Query Parameters APIs can use query parameters to filter, sort, or search for specific data within a resource. Query parameters are specified in the URL.

  • Response Body APIs can use response bodies to transmit data from the server to the client. The response body can contain data in different formats such as JSON, XML, or plain text.

  • Status Codes APIs use status codes to indicate the result of the request. Status codes can include success codes, error codes, and other types of codes.

  • Authentication and Authorization Mechanisms APIs can use various authentication and authorization mechanisms to ensure that only authorized clients can access the resources.

Last updated

#4:

Change request updated