APIs 101 with Postman

shubhangi013

shubhangi013

Posted on September 28, 2021

APIs 101 with Postman



Image source:here

‘Application Programming Interface’: The name sure is intimidating!
As someone who is fascinated by constant tech developments, how everything is becoming more sophisticated yet simplified, I find APIs very captivating. I was looking forward to learning more about them and the platform I use the most while working with them: Postman. With the
‘APIs 101 with Postman’ organized by The Club of Programmers, IIT (BHU) and hosted by @king11 , we all got an opportunity to hone our existing knowledge and learn new ones.

INTRODUCTION

The session kicked off with Lakshay Bhaiya taking up our branch names as the ‘ice-breaker’ XD.
He asked us to put up our branch name on the chat. AND…
Drum Rolls
The PPT rolled off with a comparison between a restaurant and how the ‘client-server’ system works. The server was compared to the Chef and the client was the person who ordered the food.
The example compared the APIs with a waiter. Hence, an API bridges the gap and enables communication between the client and the server.

Next, from the ‘not-so tech example', we moved on to the technical definition of an API.

Application Programming Interfaces (APIs) allow services to communicate with each other.

This put into perspective what exactly is the role of an API and how easy Postman makes it for us to work with them. One can use their terminal to work with an API but for a better experience and efficient workflow, Postman has proven to be a useful platform.

The session continued with an analysis of how requests are made and responses are received.
I’ve worked with APIs and Postman multiple times before but this session gave me a clearer idea of what I do while sending or retrieving data via APIs. The whole understructure of every application we use rely on the APIs, this itself speaks volumes about why one must invest time in learning about them.

HANDS-ON EXPERIENCE

After a PPT-oriented introduction and constant quizzing by bhaiya on simple concepts (which made the session fun!), we moved on to a hands-on experience of working with a simple API.
Here is the link to the whole set-up.

Using the endpoint URL,we chose to work with the path ‘/joke’ (because why not!?): a random joke would come up with GET requests to the API. Needless to say, we crashed the server XD, a probable reason: too many requests being sent at once to it.
A major takeaway from this section was how the major methods: GET, PUT, PATCH and POST work.


HTTP VERBS :

GET : This method requests the resource
POST : This method is used to 'submit' or 'create' a resource
PUT : This method is used to 'replace' an existing resource or 'create' one if not found
PATCH : This method is used to 'modify' an existing resource and is required to contain only the changes to the resource
DELETE : As evident by it's name, this method is used to delete the specified resource

DIFFERENCE BETWEEN PUT AND PATCH METHODS :

Although both these methods are used to update the existing data, they are different in terms of the extent to which they modify the data. PUT method updates the entire resource or creates a new one if it already doesn't exist, whereas PATCH method updates partial-data as sent by the client or throws exception when the resource is not found.
As an example, consider the following code snippet :

     axios({
         headers: {
             Authorization: "Token " + localStorage.getItem("token")
         },
         url: API_BASE_URL + "todo/" + id + "/",
         method: "patch",
         data: { title: taskEntry }
     })
Enter fullscreen mode Exit fullscreen mode

It's a snippet from a function that updates task in a To-Do web-app. I've used the PATCH method here because I wanted the function to update just the task the user wanted to update.
You can find the entire function and the rest of the methods I've used here.

To learn more about these methods, I would recommend you to visit this link


The session also gave clarity regarding the Params, Body, Header, and everything one can spot or could have a query for while working with an API in Postman.

After an amazing experience, the session came to an end :(
Postman is really a great platform to work with APIs.

Build them, test them and have FUN while doing it!

💖 💪 🙅 🚩
shubhangi013
shubhangi013

Posted on September 28, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

APIs 101 with Postman
postmanstudents APIs 101 with Postman

September 28, 2021