How To Use Postman? Guide For Beginners

Postman is an API (Application Programming Interface) platform that helps developers build, test, modify, and document APIs. It simplifies the process of sending HTTP requests and viewing responses through a user friendly interface instead of writing complex code.

What is Postman.com?

Postman acts as a middleman between your computer and a server. It allows you to test how an API behaves before integrating it into a software application.

You can learn how to use Postman for API development and testing using step by step guide.

Key Features

  • Request Builder: Create and save complex HTTP requests (GET, POST, PUT, DELETE).
  • Collections: Group related requests into folders for organized testing.
  • Environments: Switch easily between different setups like Development, Testing, and Production.
  • Automated Testing: Write scripts to validate server responses automatically.
  • Documentation: Generate public or private web pages detailing how to use your API.

Benefits

  • No Code Required: Test endpoints without writing custom backend code.
  • Collaboration: Share API collections instantly with team members.
  • History Tracking: Revisit and reuse past requests with a single click.

How to use Postman? Beginner’s Guide

Follow these steps to send your very first API request using a free, public testing API (https://typicode.com).

Step 1: Install and Launch Postman

  1. Go to postman.com and download the desktop application.
  2. Open the application.
  3. Sign up for a free account to save your work, or skip to enter the scratchpad.

Step 2: Create a Workspace

  1. Click Workspaces in the top left menu.
  2. Select Create Workspace.
  3. Name it My First Workspace.
  4. Choose Personal visibility and click Create.

Step 3: Create a New Request

  1. Click the + (New) button or the + tab in the main panel.
  2. Locate the dropdown menu that defaults to GET.
  3. Leave it as GET (used to retrieve data).

Step 4: Enter the URL and Send

  1. In the text bar next to GET, paste this URL: https://typicode.com
  2. Click the blue Send button on the right.

Step 5: Analyze the Response

  1. Look at the bottom panel labeled Response.
  2. Check the Status Code (it should say 200 OK, meaning success).
  3. View the Body tab (you will see data formatted in JSON containing a user ID, title, and body text).

Step 6: Create a POST Request (Sending Data)

  • Open a new tab by clicking the +
  • Change the dropdown method from GET to POST.
  • Enter the URL: https://typicode.com
  • Click the Body tab below the URL bar.
  • Select the raw radio button, and change the format dropdown from Text to JSON.
  • Paste the following data into the text area:
json
{
    "title": "Learning Postman",
    "body": "This is my first test.",
    "userId": 1
}
  • Click Send.
  • Verify the response status is 201 Created and see your data returned with a new ID.

Postman AI-native API Platform banner for developing, testing, and managing APIs.

How To Write Automated Test Scripts?

Automated test scripts in Postman let you validate that your API returns the correct data, status codes, and performance metrics. Postman uses JavaScript for these tests, which execute automatically every time you click the Send button.

Core Testing Concepts

Postman offers two tabs below the URL bar for writing code:

  • Pre request Script: JavaScript that runs before the request is sent (e.g., setting dynamic timestamps).
  • Tests: JavaScript that runs after the response is received (used to validate results).

Follow this guide using the free public API: https://typicode.com

Step 1: Open the Tests Tab

  1. Open a new GET request tab in Postman.
  2. Enter the URL: https://typicode.com
  3. Click on the Tests tab located directly under the URL bar.

Step 2: Use a Snippet for Status Code Validation

Postman provides ready to use code snippets on the right side of the screen.

  1. Scroll through the Snippets panel on the right.
  2. Click on Status code: Code is 200.
  3. Postman will automatically insert this code into your editor:
javascript
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

Step 3: Parse and Test JSON Data

To check the actual data inside the response body, you must first convert the response text into a JavaScript object.

  1. Add a new line in your editor.
  2. Copy and paste the following code to verify that the id field in the response equals 1:
javascript
pm.test("Check if ID is 1", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.id).to.eql(1);
});

Step 4: Run the Request and View Test Results

  1. Click the blue Send button.
  2. Look at the bottom Response panel.
  3. Click on the Test Results tab (next to Body, Cookies, and Headers).
  4. You will see green badges saying PASS: Status code is 200 and PASS: Check if ID is 1.

Common Test Code Templates

Here are the most useful test snippets you can copy and paste into your Postman environment:

  1. Check Response Time

Ensure your API responds fast enough for a good user experience (e.g., under 500ms).

javascript
pm.test("Response time is less than 500ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(500);
});
  1. Check for a Specific Text String

Verify if the response body contains a specific word, regardless of JSON structure.

javascript
pm.test("Body contains specific text", function () {
    pm.expect(pm.response.text()).to.include("userId");
});
  1. Validate Data Types

Ensure fields return the correct format (like strings, numbers, or arrays).

javascript
pm.test("Validate data types", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.title).to.be.a('string');
    pm.expect(jsonData.userId).to.be.a('number');
});

Running Tests in Bulk (Collection Runner)

Writing tests for one request is useful, but the real power comes from running dozens of tests at once.

  1. Hover over your collection folder in the left sidebar.
  2. Click the three dots (…) next to the folder name.
  3. Select Run collection.
  4. Click the blue Run [Collection Name] button.
  5. Postman will execute every request in sequence and display a dashboard showing which tests passed or failed.
  • Reading time:15 mins read
  • Post category:News / Popular