Skip to content

Postman Basics for API Testing

DodaTech Updated 2026-06-28 2 min read

In this tutorial, you will learn about Postman Basics for API Testing. We cover key concepts, practical examples, and best practices to help you master this topic.

Postman is a popular API development and testing tool that lets you send HTTP requests, inspect responses, organize requests into collections, and automate tests with JavaScript scripts. It supports REST, Graphql, and Websocket protocols.

What You'll Learn

  • Postman interface: sidebar, request Builder, response viewer
  • Sending GET, POST, PUT, DELETE requests
  • Environment and variable management
  • Response inspection and validation
  • Collection organization

Why It Matters

Postman reduces API development time by providing an intuitive interface for crafting requests and inspecting responses. It bridges manual testing with automated test suites through collections and scripts.

Real-World Use

Stripe provides Postman collections for their API. GitHub publishes official Postman collections. Most SaaS companies offer Postman collections for developer onboarding.

flowchart LR
    Postman[Postman App] --> Builder[Request Builder]
    Postman --> Collections[Collections]
    Postman --> Environments[Environments]
    Postman --> Runner[Collection Runner]
    Builder --> Method[HTTP Method]
    Builder --> URL[URL / Path]
    Builder --> Headers[Headers]
    Builder --> Body[Request Body]
    Builder --> Auth[Authorization]

Teacher Mindset

Postman is your first tool for exploring an API. Build requests, inspect responses, and save successful requests to collections. Use environments to switch between development, staging, and production.

Code Examples

// Example 1: Postman test script (JavaScript)
pm.test('Status code is 200', () => {
    pm.response.to.have.status(200);
});

pm.test('Response has users array', () => {
    const jsonData = pm.response.json();
    pm.expect(jsonData).to.be.an('array');
    pm.expect(jsonData[0]).to.have.property('id');
    pm.expect(jsonData[0]).to.have.property('name');
});
// Example 2: Setting environment variables from response
const jsonData = pm.response.json();
pm.environment.set('user_id', jsonData.id);
pm.environment.set('user_token', jsonData.token);

console.log(`Created user: ${jsonData.name}`);
// Example 3: Pre-request script for dynamic data
const uuid = require('uuid');
pm.variables.set('request_id', uuid.v4());
pm.variables.set('timestamp', new Date().toISOString());

Common Mistakes

  • Hardcoding URLs and tokens instead of using variables
  • Not organizing requests into collections
  • Ignoring Postman test scripts for validation
  • Sharing collections without removing sensitive data
  • Not using environments for different deployments

Practice

  1. Send a GET request to a public API and inspect the response.
  2. Create a POST request with JSON body and headers.
  3. Set up a development environment with base URL variable.
  4. Write a test script that checks response status and body.
  5. Challenge: Create a collection with CRUD requests for a resource and chain them using variables.

FAQ

Is Postman free?

Postman has a free tier with core features. Paid plans add team collaboration, monitoring, and API documentation.

Can I use Postman for GraphQL?

Yes. Postman supports GraphQL queries, mutations, and subscriptions with the GraphQL body type.

How do I share Postman collections?

Export collections as JSON files or use Postman's cloud sync for team sharing.

Can I automate Postman tests?

Yes. Use Newman, Postman's CLI tool, to run collections in CI/CD pipelines.

What is the difference between variables and environments?

Variables are key-value pairs. Environments are named sets of variables for different contexts (dev, staging, prod).

Mini Project

Create a Postman collection for a simple todo API. Include requests for listing, creating, updating, and deleting todos. Use environment variables for the base URL. Add test scripts that verify responses.

What's Next

Next, you will learn about creating and organizing Postman collections for structured testing.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro