Postman is a popular tool for developing and testing APIs (Application Programming Interfaces). It allows developers to test the functionality of their APIs by sending various types of requests, such as GET, POST, PUT, and DELETE, and analyzing the responses. It also provides features such as the ability to save and organize requests, create and manage environments, and generate code snippets for different programming languages.
What is an API?
An API, or Application Programming Interface, is a set of rules and protocols that allows different software applications to communicate with each other. Didn't make any sense?? API acts as an intermediary between different systems, allowing them to share data and functionality. Think like you are in a restaurant. You can't directly go into their kitchen and take anything you want. That is not how it works. There is an intermediate person, the waiter who deals with our orders. He took our orders back to the kitchen and serves the food. We don't know what is going on behind it. API is just like that. If you tell them to get the list of orders, it will give you a list of orders.
How Postman is useful?
Postman allows developers to easily create, test, and share API requests and responses. It can use as a front-end to test your APIs.
With Postman, you can create and organize complex API requests with multiple headers, parameters, and body data, and save them for later use. You can also create and run automated tests for your APIs to ensure they are working correctly. Additionally, Postman allows for easy documentation and sharing of APIs with others, making it a valuable tool for development teams.
So an API means accessing some data from another server. You can access these data through requests. There are many API providers available. Most of them are not free. For our study purpose, we use DogAPI. It is free and fun to interact with API.
Testing API using Postman
Now we will see how to test our API using Postman. For that, you need to install Postman and open a new window.
Insert this link
https://api.thedogapi.com/v1/images/search?size=med&mime_types=jpg&format=json&has_breeds=true&order=RANDOM&page=0&limit=1 in the request-url section. Then using the GET method send the request to the server.
We can see random information is sent from the server to us. This is because of the query we gave to the server.
The URL we used returned random image of a dog in medium size, with the file format of JPG, with breed info and can be returned in JSON format.
The query parameters used in the URL are:
size=med: this parameter specifies that the returned images should be in medium size.
mime_types=jpg: this parameter specifies that the returned images should be in JPG format.
format=json: this parameter specifies that the returned data should be in JSON format.
has_breeds=true: this parameter specifies that the returned images should have breed information.
order=RANDOM: this parameter specifies that the returned images should be in random order.
page=0: this parameter specifies the page number of the images to be returned.
limit=1: this parameter specifies the number of images to be returned in one request.
Note:- we are using form-data format to send the data. If you are getting any error, select the "Body" tab in the request editor. Under the "Body" tab, select the "form-data" option.
Similarly, we can retrieve the data of a dog with its id:-
Here I am passing an ID
RX0knn4z4 , which is unique for a dog. So the details of the dog with the corresponding ID can be retrieved from the server. Let's see how to do that.
Insert the url by passing the ID
You can see all the details about the dog displayed in the output.
Did you find this article valuable?
Support shamnad sherief by becoming a sponsor. Any amount is appreciated!