</>

Technology

Postman

Difficulty

Beginner

Interview Question

What are Collections in Postman and what is their purpose?

Answer

Postman Collections

A Collection in Postman is a group of saved API requests organized into folders. Think of it as a project folder for your API tests.

Purpose of Collections

1. Organization

Group related API requests logically:

CODE
šŸ“ User API Collection
  šŸ“ Auth
    → POST /login
    → POST /logout
  šŸ“ Users
    → GET /users
    → POST /users
    → GET /users/{id}
    → PUT /users/{id}
    → DELETE /users/{id}

2. Collaboration

  • āœ“Export and share collections as JSON files
  • āœ“Publish collections to your Postman workspace for team access
  • āœ“Version-control collections in Git

3. Automated Testing with Collection Runner

Run all requests in a collection in sequence:

  • āœ“Set number of iterations
  • āœ“Use CSV/JSON data files for data-driven testing
  • āœ“View pass/fail results for each test

4. Newman Integration (CI/CD)

Run collections from the command line:

Bash
newman run my-collection.json -e production.json --reporters cli,html

5. Documentation

Postman auto-generates API documentation from your collection with descriptions, examples, and response samples.

Creating a Collection

  1. āœ“Click Collections in the sidebar
  2. āœ“Click + or New Collection
  3. āœ“Name it (e.g., "User API Tests")
  4. āœ“Add requests by clicking the ... menu → Add Request
  5. āœ“Save each request to the collection

Collection Variables

Collections can have their own variables:

CODE
{{base_url}} = https://api.example.com
{{api_version}} = v1
ā–øUse in requests: {{base_url}}/{{api_version}}/users

Follow AutomateQA

Related Topics