APIs 101 with POSTMAN: A Beginners Guide (2022)
Tags: beginners, api, postman
Published: 2022-03-07 19:52:54

**Postman** has become a popular tool for developers for Creating, Testing and Managing APIs. But what are APIs in the first place and why are they used?
👉Let’s find out what is an API, what is it used for, what is Postman and it's role as an API management tool.

So, the _Agenda of the Blog_ is:
1. Introduction to APIs and Postman
2. Requests and Responses
3. Hands on detailed lab session
4. Follow-up Opportunities and Learning Resources

***

**API** stands for Application Programming Interface
To explain what an API is, we take a simple example...

**APIs: A Digital Restaurant**
Suppose you, the customer, visit your favourite restaurant and request for a bowl of ice-cream for which the waiter acts as a mode of communication between you and the chef. The function of the waiter is to communicate to you whether there is a stock of ice-cream or not, if there is, he will bring it for you.


![APIs: A Digital Restaurant](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ee6cj5crs0ewp59nvayg.png)

Similarly, the role of an API is to act as the middleman for the communicator between softwares. [ Remember, don’t call the waiter at your favourite restaurant an API, he probably won’t understand 🙂 ]

The above depiction shows us how in the Software Development World, the client (the person requiring the data), sends a request which is taken by the API to the Server (where the data is stored) and the action is performed accordingly.


**Why do we use APIs and not directly access the data from the servers??**


![What is an API](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7t5hf7n7j608zovnk8a.png)

APIs make the task of developers easier by removing the need to create every service from scratch.

***

You must have used the Instagram app.
Let me demonstrate how the APIs help us with an example of it's simple implementation on Instagram.


![APIs through Instagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qyqyirfby8yry2evaakc.png)


Step 1: You select a photograph from your gallery to upload (API required to fetch that photograph)
Step 2: You modify the photograph by applying filters (API to modify this photograph)
Step 3: You finally publish this photograph (API sends this photograph to the server to store it)
Step 4: Instagram displays the photograph to you and your followers (API fetched the photograph from the server)

So, you see that the process which happens within seconds on our devices, runs a lot of API calls in the background, but thanks to the developers of Instagram, you do not experience the lag in service.

Let us now understand the role of Postman.

## WHAT IS POSTMAN?
Postman is a collaborative API development platform that makes it easy for us to create, test and monitor APIs. It's environment makes it a popular Industry standard equipment for companies like PayPal, Uber, Atlassian etc.


![What is Postman](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nd7x3q6inpavyrwvh7sg.png)

In earlier days, the complex structure of the command line interface, while implementing API requests, made it difficult to read and manage the code. So, to solve this problem, Postman was created which had a minimalistic UI (User Interface) helping developers manage APIs.

Now, let’s dive into the "Technical Part" about APIs… don’t stop, I assure you it’s _very_ simple 😎

The interaction with the API starts with making a **REQUEST**, which carries the following parameters …


1. Method (GET, POST, PUT etc.)
2. Address/Endpoint (URL – Uniform Resource Locator)
3. Path

***

**1. Requests – Methods and Endpoints:**
The Method parameter specifies which type of action will be performed in our API call, some main actions are -
**GET** – for retrieving information
**POST** – for sending information
**PUT/PATCH** – for updating information
**DELETE** – for deleting the information


![Request Methods and Endpoints](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s7h0n2jfklh3bpnu1q37.png)

**2. Address/Endpoint (Parts of a URL):**
The **Protocol** is the scheme of the request, here it is an [HTTPS](https://developer.mozilla.org/en-US/docs/Glossary/https) request.

The **Host** is the address of the server, the place where the code lives which you need to connect to.

**3. The Path** is the destination where the request can be heard or executed.

The **Body** is that part of the API which contains the data that we want send or receive.

***
## Request Body:


![Requests Body](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e8x0r56z3wh96hj4s807.png)

The data payload (which is the data sent by the client to your API), is optional but often supplied with the POST and PUT requests.
The Data can be sent in various formats; Text, HTML, XML etc. but the most used format is [JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON) or JavaScript Object Notation. 

***

**A feel of the Postman platform:**


![Postman Platform:](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1q6v4ffkwp65z1pgkgbj.png)

We enter the public workspace on the platform which is made to be visible to everyone and to learn how to interact with APIs.

Now, we **should not tamper** with the **original code** unless we are absolutely sure about what we are doing. So, to avoid problems in the public workspace, we fork a copy of the public workspace into our personal workspace (which only we have access to). This function is similar to forking a git repository from [Github](https://github.com/).


![My Workspace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yl82fd1h4zb86oyl90uz.png)

Forked public workspace is now in “My workspace”.

Now, to understand what we are about to do, we read the [Documentation](https://www.geeksforgeeks.org/overview-software-documentation/).


![Documentation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x479z8tnc8304z9ihx3p.png)

To perform our very first action, we accessed the Get Data file and we sent a valid API call to google.com and received a status [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
Status 200 OK – means that the request was correct and the desired response has been sent to the client.


![Status 200 OK](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xk31vix3wd70ehbfv95.png)

Now, whenever we google something, we can see this on the URL bar: 


![Google Search](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/euwqt84ysdgny58yirkp.png)

This **q** symbolizes [Query](https://www.wordstream.com/blog/ws/2012/12/10/three-types-of-search-queries), the term which we are looking for (here  q=Postman). Basically, it tells the search engine what we are looking for.

On Postman, we can set the query parameter in a similar way.

***

**Retrieving Data using API call:**
We then navigate to the Book API and used the **GET** method to call the Base URL set to a path - /book which retrieved random books from the database and displayed it in JSON format.


![GET Method](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bcsb16p3bzs1njgzqah.png)

To get a particular book, we set the path parameter, **id**, to different values. 

**Adding Data using API call:** 
We then added a request to add data to the server by using the **POST** method. But first read the documentation to get a idea on what code to add in the JSON.

![POST Method](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f2f830vjz0iflsq5qk6b.png)

Whenever we want to add some information, we enclose it within the Body of the request and select type as JSON.

Every book should have a unique id. Hence, we take an arbitrary value of id and send in the API call. Upon successful adding of the data, we get a [201 Created](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201) which is for a new resource being created.


![201 Created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/06pa8ygr51pqxhu8ohcj.png)

To verify if your data was sent correctly, we go to the Get data tab and enter the id we sent for the post request.


![Checking GET Method](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ebztufqdyp5mcbi6wuow.png)

If we get back the same data we added in the POST method, then our implementation was correctly executed.

**Modifying Data using API call:**
To Modify the data, we use the **PUT** method and we add this request in a new tab.
We input the JSON text from the documentation in the similar way to POST method.


![204 No Content](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/epfh3le0kc6q52ye5shy.png)

We get a [204 No Content](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 ) because it is a confirmation that the data was added correctly, but there is nothing to return here.
We can again verify the information by requesting a GET data method.

**Deleting Data using API call:**
To delete a particular book, we add a new request with the **DELETE** method.
We specify the path (/book) and an id to delete the book at that id.
On running the command, we get an output “Book with id ___ is deleted.”


![DELETE Method](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ipvaa2ayj8y53wc3hgo.png)

On checking in Get Data, we get a message saying “Book not found” because it has been deleted successfully. 

We also had this UI which made it simple to understand the various changes to the data by presenting it visually.


![UI for checking API Implementation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o3ugzxdy07v7fl9xbt1b.png)

***

**Wrapping Up:** 🌠
We learnt about APIs and it’s uses, why is Postman used and how to implement basic API calls using Postman 🤩

**Way forward:** 📈
We can continue Learning APIs as a Student Expert and get certified 🎓


![Get Certified by Postman](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90c7yohzrq9y0wa7uy2j.png)

***

## Credits

This Blog is my complete breakdown of the Session - APIs 101 with Postman by **Satabrata Paul** [@SatabrataYo](https://twitter.com/SatabrataYo) (Postman Student Expert and Core Member GDSC HITK) which was conducted on 5th March, 2022.

You can find the complete YouTube tutorial [here](https://www.youtube.com/watch?v=JAouM2q0g68)


👉 You can follow me on Twitter [@Dev_ikr](https://twitter.com/Dev_ikr) 

Thanks for sticking around till the end 😃

- #PostmanStudent #PostmanAPI [](url)