API Request Anatomy

Profile picture for user devraj
Submitted by devraj on

An API request allows you to retrieve and send data to a data source or server. The API request is formed up of four things:

  1. The endpoint
  2. The method
  3. The headers
  4. The data (or body)

1. Endpoint

Endpoint or route is the URL you request for. It follows this structure:


Root Endpoint + Resource + Parameters (Query/Path/Any other)
  • Root Endpoint: The root-endpoint is the starting point of the API you’re requesting. The root-endpoint of Twitter APIs is https://api.twitter.com and Facebook graph API is https://graph.facebook.com/.
  • Resource: /cars, /fruits, /user, /product
  • Parameters: Query, Path, Form or any other type of parameter.

Query parameters consist of key-value pairs which always begin with a question mark (?). Each parameter pair is then separated with an ampersand (&), like this:


PATH Parameter: required to access the resource E.g. /user/1 (/user/{user_id}) 

# /product/{product_id}

2. HTTP Method

The following are the most popular:

  1. Get (Search for data)
  2. Post (Send data)
  3. Put (Update data)
  4. Patch (Partial Update)
  5. Delete (Delete data)

3. Request Headers

The additional details provided for communication between client and server. Some of the common headers are: 

  • accept-language
  • Accept-Charset
  • Accept-Encoding
  • Authorization
  • Content-Type

4. Request Body 

Also called request data, request message, body parameters or payload. contains the info you want to send to the server. Like for login request you send information like username and password.

    "gender": "Male",
    "name": "Harry Potter",
    "email": "hoggwarts@wiz.com",
    "status": "active"

Video Tutorial: Anatomy of An API