Play With API Using Postman | Postman Tutorial For Beginner
API is one of the greatest feature of this programming era using which one can access another service easily. Its full form is Application Programming Interface. I am sure that you all have been used one api till date like OpenWeather , currency rate , YouTube api etc. In this post , we will see how to use Postman
Postman Tutorial For Beginner
Postman is an API platform used for building & testing APIs. It provide organized collection of data & test of APIs graphically (GUI) with numbers of HTTP requests like GET, POST, PUT, POST and DELETE.
Creating Postman Account
The first step is to create a Postman account. If you already own an account , then you can skip this step. To create a new Postman account , you need to follow the following steps
- Go to https://identity.getpostman.com/signup
- Enter your email , username & password and click on 'create account'
- After that you need to enter your name & role (like student / developer etc)
- Then it will ask you to invite your team. Skip this process by clicking on 'Continue without team'
- Verify your email
- Done , you have successfully created a Postman account
After creating a Postman account , we will learn how to play with API
Forking Collection In Postman
Go to https://go.narendradwivedi.org/apipm. It will open a collection in Postman. Choose 'Basics of API' and click on Fork to fork it
Enter a label to identify your project like 'APITut' and select 'My Workspace' from workspace and click on Fork Collection to fork the collection.
Documentation
Documentation is one of the most important part to be read by a developer or tester using which they can understand how to use the product/services. In some of the program , it is also called as ReadMe
Endpoint URL
In this tutorial , we will use http://postman-student.herokuapp.com as our testing url on which we will perform various HTTP requests. Using this url , we can perform api testing on three path , i.e /joke , /book & /quote. In this tutorial i will be using joke so our main url will be http://postman-student.herokuapp.com/joke
GET Request In Postman
Lets start playing with GET request. From the collection , expand your main project (Basic of API) and click on GET Data. After that enter https://postman-student.herokuapp.com/joke as request url , choose GET as method and click on Send button. At the bottom you can see a Body section which displays result in brackets format. This format is JSON format which is known as JavaScript Object Notation. In maximum cases all the output of APIs are returned as JSON format.
Each time we send GET request on https://postman-student.herokuapp.com/joke , it will return random jokes. If you want to show a specific joke , you can do it by using its id. For this pass https://postman-student.herokuapp.com/joke/youridhere as request url. For example : https://postman-student.herokuapp.com/joke/1214. This time it will return the data of id 1214 only. Make sure to click on save button to save your works.
POST Request In Postman
Now lets try POST Request. Click on three dots on corner of collection & click on Add Request
It will create a new request. Name it anything like POST (Add). Using POST method , we can add jokes. Lets try it
In the request url , enter https://postman-student.herokuapp.com/joke and select POST as method. Now select Body -> raw and select JSON from dropdown.
In its content , enter
{
"id": 100,
"author": "ND",
"joke": "New Joke",
"source": "narendradwivedi.org"
}
Modify the above code of your choice. Now click on send. You will see the following responsePUT Request In Postman
Using PUT request , we can modify our existing data. Lets create a new request .Click on three dots on corner of collection & click on Add Request. Name it as PUT (Update).
In the request url , enter https://postman-student.herokuapp.com/joke and select PUT as method. Now select Body -> raw and select JSON from dropdown.In its content , enter
{
"id": 1237,
"author": "ND",
"joke": "New Joke Updated",
"source": "narendradwivedi.org"
}
In the above code , modify id with the id of the joke you want to modify. Also you can modify author , joke and source. After that click on Send.DELETE Request In Postman
Using DELETE request , we can delete our joke (completely with author & source). Lets try this.
Create a new request .Click on three dots on corner of collection & click on Add Request. Name it as DELETE.
In the request url , enter https://postman-student.herokuapp.com/joke/yourid (for example : https://postman-student.herokuapp.com/joke/1237 ) and select DELETE as method. Replace yourid with the id of the joke you want to delete. Click on send button.
FAQ
What is the use of GET request ?
Using GET request , we can view the data
What is the use of POST request ?
Using POST request , we can add new data
What is the use of PUT request ?
Using PUT request , we can modify our data
What is the use of DELETE request ?
Using DELETE request , we can delete data
About This Tutorial
A wonderful session was conducted by Kiran Lavhale and Rohan Kulkarni On POSTMAN and i published this post covering the tutorial.
Don't forget to add me on LinkedIn (https://www.linkedin.com/in/narendradwivedi/)
Post a Comment