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
- āClick Collections in the sidebar
- āClick + or New Collection
- āName it (e.g., "User API Tests")
- āAdd requests by clicking the ... menu ā Add Request
- ā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