Postman: A hands-on tutorial: Day 2— Create your first API request

Dipan Saha
6 min readJan 15, 2024

--

Welcome back to Day 2 of our hands-on tutorial series on Postman! Now that you have Postman installed, it’s time to dive into the exciting world of creating your first API request. Whether you’re a seasoned developer or just starting, this tutorial will guide you through the process of making your first API call using Postman.

What is API?

API (or Application Programming Interface) is a set of rules and protocols that allows different software applications to communicate with each other. It defines what operations are available, what data they need, and what they will provide in return. It simplifies interaction between different systems by providing a standardized way for them to communicate and share information.

How do APIs work?

APIs work by sharing data between applications, systems, and devices. This happens through a request and response cycle. A user initiates a request for data by interacting with an application. The request is sent to the API, which retrieves the data and returns it to the user.

API Types

There are different kinds of APIs. For example:

  • Web APIs (RESTful APIs),
  • SOAP APIs,
  • GraphQL APIs,
  • Library APIs.

The most commons are the Web APIs or the RESTful APIs. These follow the principles of Representational State Transfer (REST). Web APIs enable communication over the internet using standard HTTP methods, such as GET, POST, PUT, and DELETE. They are widely used in web development for creating interactive and dynamic applications.

Understanding the Postman Interface

Before we jump into creating a request, let’s take a quick look at the Postman interface:

  1. Workspace: The left sidebar where you manage your collections, environments, and history.
  2. Header Bar: The top bar where you can choose your workspace, switch between different features, and manage your account.
  3. Request Builder: The main area where you’ll be creating and sending your API requests.
  4. Tabs: The tabs at the bottom, such as “Params,” “Authorization,” etc., allow you to configure various aspects of your request.

Workspace, Collection and Request

Workspaces: Your Collaborative Playground

Postman Workspaces are collaborative environments where you can organize your API work. Whether you’re working solo or as part of a team, Workspaces provide a structured space to manage your collections, environments, and requests.

Click on the New button and select Workspace

Next, select the Blank Workspace option and provide a workspace name.

Workspaces act as containers for your API development projects, allowing seamless collaboration and organization.

Collections: Bundling Requests for Efficiency

Collections in Postman are containers for your API requests. They enable you to organize, run, and share multiple requests as a single entity.

Collections provide a structured way to manage related requests, making it easy to execute sequences and scenarios during development and testing.

Requests: Building Blocks of API Interaction

Requests are the heart of Postman. They represent your interactions with APIs, allowing you to make calls, receive responses, and test functionalities.

Let’s start by making a simple GET request to a public API (https://www.google.com).

Click on Add a request.

Give the request a name (Say Google)

  1. Choose Request Type: Select the HTTP method (GET, POST, PUT, DELETE, etc.) for your request. In our case, it will be GET.
  2. Enter Request Details: Fill in the request URL, parameters, headers, and body as needed. In our case, we shall just populate the request URL as https://www.google.com to start with.
  3. Save Your Request: Click on Save to add the request to your collection.
  4. Send your request: Click on the send button. Now you should be able to see the response under the Response body.

If you click on the preview tab, it will show you a preview of the response webpage.

API Request and Response

An API request contains:

  • An address
  • A Request method
  • Headers
  • Body

An API response contains:

  • Status Code
  • Header &
  • Body

Postman API Request Types

Understanding these Postman API request types empowers you to interact effectively with different APIs. Whether you’re fetching data, creating new resources, or updating existing ones, Postman provides the tools you need for seamless API development.

GET Requests: Retrieving Data

  • Purpose: Used to retrieve data from the server.
  • When to Use: GET requests are ideal for fetching information from the server without modifying it. They are commonly employed for reading data from APIs.

POST Requests: Creating Data

  • Purpose: Used to submit data to the server to create a new resource.
  • When to Use: POST requests are employed when you want to create a new resource on the server, such as submitting a form or adding a record to a database.

PUT Requests: Updating Data

  • Purpose: Used to update existing data on the server.
  • When to Use: PUT requests come into play when you need to modify or update an existing resource. They replace the current representation with the new one you provide.

PATCH Requests: Partially Updating Data

  • Purpose: Similar to PUT, but used for partial updates.
  • When to Use: PATCH requests are suitable when you want to update only specific fields of an existing resource, rather than replacing the entire resource.

DELETE Requests: Removing Data

  • Purpose: Used to request the removal of a resource on the server.
  • When to Use: DELETE requests are employed when you want to delete a specific resource. Exercise caution, as this action is irreversible.

HEAD Requests: Getting Only Headers

  • Purpose: Similar to a GET request, but only returns the headers and not the actual data.
  • When to Use: HEAD requests are useful when you want to check if a resource has changed since a certain date or time without downloading it.

OPTIONS Requests: Checking Server Capabilities

  • Purpose: Used to describe the communication options for the target resource.
  • When to Use: OPTIONS requests provide information about the communication options available for a particular resource. This can be useful for cross-origin resource sharing (CORS) scenarios.

TRACE Requests: Echoing Request

  • Purpose: Used to perform a message loop-back test.
  • When to Use: TRACE requests are typically used for diagnostic purposes, echoing the received request back to the client.

Conclusion

Congratulations! You’ve successfully created your first API request. Stay tuned for Day 3, where we’ll take a deep dive into a Postman request.

Happy coding!

--

--

Dipan Saha

Cloud Architect (Certified GCP Professional Architect & Snowflake Core Pro)