3. Working with APIs

3.1 How to work with an API?

So far we have learnt what request, response are. We also learnt about endpoint, query parameter and body data.

To get started with any API, you need to do the following things ➖

  • Read the API documentation carefully.
  • Find which Endpoints matches your business need.
  • Check whether there is any authentication / authorisation required to access the API.
  • Test the API through Postman or by curl request.
  • Implement in Code

3.2 Exploring an API documentation

Let's say you want to integrate Google signup API on your site (i.e. you want that your users can signup using their Google account )

What would be the step one? The first step would be to visit the APIs documentation. API documentation is the starting point when it comes to working with APIs.

Remember! A good API should have detailed documentation explaining how to work with it.

  • It should describe the basics what the API does, what type of data you can get from it.
  • It should explain the requirements for using the API. Is it free or paid? Does it require you to register and obtain a key?
  • It should also provide examples of how to make requests and the responses returned.
  • And most importantly, for actually working with the API, it should provide you with endpoints and parameters.

Note - API Documentation is also called as API contract.


3.3 Working with Github API ( Example 1)

Problem Statement : Show profile information of a user based on GitHub username.

It is highly recommended to do it yourself first.

Let's get started according to our checklist.

  • Find official API documentation
  • Find the api endpoint which match your problem statement.
  • Test the api request using curl or postman.


curl -i https://api.github.com/users/dipakkr

Here are few examples of best API documentation you can read and play around with.

  1. Stripe - https://stripe.com/docs/api
  2. Notion - https://developers.notion.com/
  3. SendGrid - https://sendgrid.com/solutions/email-api/
  4. Github - https://docs.github.com/en/rest