0
0
PostmanConceptBeginner · 3 min read

What Is Collection in Postman: Definition and Usage

A collection in Postman is a group of saved API requests organized together for easy access and management. It helps testers run, share, and automate multiple API calls in one place.
⚙️

How It Works

Think of a collection in Postman like a folder where you keep all your related API requests. Instead of running each request separately, you group them so you can run or test them together. This is similar to having a playlist of songs instead of playing one song at a time.

Each request in the collection can have its own settings like headers, parameters, and scripts. When you run the collection, Postman executes each request in order, making it easy to test workflows or sequences of API calls. This saves time and keeps your work organized.

💻

Example

This example shows how to create a simple collection with two API requests and run them using Postman’s scripting feature.

javascript
pm.test('Status code is 200', () => {
  pm.response.to.have.status(200);
});

// Collection has two requests:
// 1. GET https://jsonplaceholder.typicode.com/posts/1
// 2. GET https://jsonplaceholder.typicode.com/users/1

// Running the collection will execute both requests and run tests on each response.
Output
Both requests return status code 200, so tests pass successfully.
🎯

When to Use

Use collections when you want to organize multiple API requests that belong to the same project or feature. They are perfect for:

  • Testing a series of API endpoints in one go.
  • Sharing API requests with teammates easily.
  • Automating tests by running collections in Postman or CI/CD pipelines.
  • Documenting your API workflows clearly.

For example, if you are testing an e-commerce API, you can create a collection with requests for login, product search, add to cart, and checkout. Running the collection tests the entire user flow.

Key Points

  • A collection groups related API requests for better organization.
  • It allows running multiple requests sequentially or with scripts.
  • Collections support tests, pre-request scripts, and variables.
  • They help share and automate API testing workflows.

Key Takeaways

A collection in Postman is a saved group of API requests organized for easy testing and sharing.
Collections let you run multiple API calls together, saving time and improving workflow.
Use collections to automate tests, share APIs with teammates, and document your API usage.
Each request in a collection can have its own tests and scripts to validate responses.
Collections are essential for managing complex API testing scenarios efficiently.