DEV Community

Cover image for A Comprehensive Guide to GET, POST, PUT, and DELETE Methods in API Development with Postman
TanooshKondu
TanooshKondu

Posted on

A Comprehensive Guide to GET, POST, PUT, and DELETE Methods in API Development with Postman

API can be compared to a waiter in a restaurant, who takes requests from clients/customer to a chef in the kitchen, then gets back to the customer with feedback, either with the food ordered present or not. Same way, API acts as a link between a user of a program and a server.

Client/customer = user
API = waiter
Chef = Server
API full form is Application Programming Interface.

POSTMAN APIs

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/PATCH, POST and DELETE.
GET - Retrieve information
POST - send information
PUT/PATCH- Update information
DELETE- delete information

Introduction to APIs using postman:

In the world of API development, the HTTP methods GET, POST, PUT, and DELETE play a crucial role in interacting with resources. These methods enable developers to perform various operations on data, such as retrieving information, creating new records, updating existing data, and deleting resources. In this blog post, we will explore the significance of these methods and how they can be utilized effectively using the popular API development tool, Postman.

Create 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;

  1. Go to https://identity.getpostman.com/signup
  2. Enter your email , username & password and click on 'create account'
  3. After that you need to enter your name & role (like student / developer)
  4. Then it will ask you to invite your team. Skip this process by clicking on 'Continue without team'
  5. Verify your email
  6. Done , you have successfully created a Postman account

Getting Started with APIs

Forking Collection In Postman

Enter a label to identify your project like 'APITut' and select 'My Workspace' from workspace and click on Fork Collection to fork the collection.
Go to https://bit.ly/postman-demo. It will open a collection in Postman. Choose 'Basics of API' and click on Fork to fork it.

Image description

Documentation

Documentation is one of the most important part to be read by a developer SO that 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://postmanstudent.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.

Paths:

  1. /joke For working with Jokes API.
  2. /quote For working with Quotes API.
  3. /book For working with Books API.

In this tutorial i will be using joke so our main url will be http://postman-student.herokuapp.com/joke

Understanding the Fundamentals:

1.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.

Image description

Image description

2.POST Request In Postman:

Now lets try POST Request. Click on three dots on corner of collection & click on Add Request

Image description
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://postmanstudent.herokuapp.com/joke and select POST as method. Now select Body -> raw and select JSON from dropdown.

Image description
In its content , enter

{
        "id": 100,
        "author": "ND",
        "joke": "New Joke",
        "source": "kipngeno.org"
    }
Enter fullscreen mode Exit fullscreen mode

Modify the above code of your choice. Now click on send. You will see the following response

This has assigned us a random id '1237'. By sending GET request as http://postman-student.herokuapp.com/joke/1237 , we can access this joke

Manipulating Data:

3.PUT 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://postmanstudent.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": "kipngeno.org",
}
Enter fullscreen mode Exit fullscreen mode

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.
You can see a text with status code 204 : No content. It means your update has been successfully pushed. Now to see whether data is changed or not , run GET request with your id.

So , the data is changed that means our request was executed successfully.

4.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://postmanstudent.herokuapp.com/joke/yourid (for example : https://postman-student.herokuapp.com/joke/1237 ) and select DELETE as method. Replace your id with the id of the joke you want to delete. Click on send button.

Image description
Our joke with id 1237 deleted successfully.

Conclusion:

Understanding the GET, POST, PUT, and DELETE methods is essential for developing robust and efficient APIs. With Postman's user-friendly interface and powerful features, you can easily work with these methods and streamline your API development process. By mastering these HTTP methods and utilizing Postman's capabilities, you'll be well-equipped to create high-quality APIs that meet the needs of your applications and users.

Remember, API development is an iterative process, and practice is key to becoming proficient. So, let's dive into the world of API development using GET, POST, PUT, and DELETE methods with Postman!

Top comments (0)