Lesson 42 of 158 – Postman Collections
42%

Postman Collections

A Postman Collection is a group of API requests saved together in Postman. Collections help developers organize and manage multiple API requests for the same project.

Note: Collections are very useful when building a REST API for a React Native application because a complete mobile application may use many API endpoints.

1. What is a Postman Collection?

A Postman Collection is a container that stores multiple API requests in one organized place.

For example, a Student Management API may have requests for:

  • Get students
  • Add student
  • Update student
  • Delete student
  • Search student

2. Why Use Collections?

Collections make API testing easier because related requests can be kept together.

Benefits include:

  • Better organization
  • Easy access to requests
  • Easy API testing
  • Reusable requests
  • Better project management

3. Collection for a Project

A project can have its own Postman Collection.

For example:

Student Management API

All student-related API requests can be stored inside this collection.

4. Create a Collection

In Postman, you can create a collection from the Collections section.

Basic steps:

  1. Open Postman.
  2. Open the Collections section.
  3. Create a new collection.
  4. Enter a collection name.
  5. Save the collection.

5. Name the Collection

Give the collection a meaningful name.

Example:

Student Management API

A clear name makes it easier to identify the collection later.

6. Add a Request to a Collection

After creating a collection, API requests can be saved inside it.

For example, a GET request:

GET
http://localhost/api/students.php

This request can be saved inside the Student Management API collection.

7. Save a GET Request

Suppose we have a GET request for retrieving students.

GET /api/students.php

Save the request inside the appropriate collection.

The request can then be reused whenever student data needs to be tested.

8. Save a POST Request

A POST request for adding a student can also be stored in the same collection.

POST /api/students.php

The request can contain JSON data such as:

{
    "name": "Rahul",
    "course": "ADCA"
}

9. Save a PUT Request

A PUT request for updating a student can also be added to the collection.

PUT /api/students.php?id=10

This keeps the update request together with the other student API requests.

10. Save a PATCH Request

A PATCH request can also be stored in the collection.

PATCH /api/students.php?id=10

This can be used to test partial updates.

11. Save a DELETE Request

A DELETE request can be saved in the same collection.

DELETE /api/students.php?id=10

Now the collection contains requests for the main CRUD operations.

12. CRUD Collection

A collection can contain all CRUD requests for an API.

Student Management API
│
├── GET Students
├── GET Student
├── POST Student
├── PUT Student
├── PATCH Student
└── DELETE Student

13. Collection Folders

Collections can be organized using folders.

For example:

Student Management API
│
├── Authentication
├── Students
├── Courses
└── Users

Folders make large collections easier to manage.

14. Authentication Folder

Authentication-related requests can be grouped inside an Authentication folder.

Examples:

  • Register
  • Login
  • Logout
  • Refresh Token
Authentication
├── Register
├── Login
└── Logout

15. Students Folder

Student-related requests can be stored inside a Students folder.

Students
├── Get Students
├── Get Student
├── Add Student
├── Update Student
└── Delete Student

This structure makes the collection easier to understand.

16. Rename a Request

Give each request a meaningful name.

Instead of:

Request 1

Use:

Get All Students

Meaningful names make API testing easier.

17. Collection Request URL

Each saved request contains its API URL.

http://localhost/api/students.php

When the request is opened later, the saved URL can be used again.

18. Collection Request Headers

Headers can also be saved with a request.

Content-Type: application/json
Accept: application/json

This allows the request to be reused with the same header configuration.

19. Collection Request Body

POST, PUT, and PATCH requests can save their request body inside the request.

{
    "name": "Rahul Kumar",
    "course": "ADCA"
}

This makes repeated API testing easier.

20. Reusing a Saved Request

One major benefit of a collection is that saved requests can be reused.

Instead of creating the same request again, open it from the collection, modify the required values, and send it.

21. Collection for API Testing

A collection can act as a complete set of API requests for testing a project.

API Project
     ↓
Postman Collection
     ↓
Multiple Requests
     ↓
API Testing

This is useful when an API contains many endpoints.

22. Collection for React Native Backend

Suppose we are building a React Native Student Management application.

The backend may contain:

  • Registration API
  • Login API
  • Student List API
  • Student Details API
  • Add Student API
  • Update Student API
  • Delete Student API

All these requests can be stored in one Postman collection.

23. Organizing a Mobile App Collection

Student Mobile App API
│
├── Authentication
│   ├── Register
│   ├── Login
│   └── Logout
│
├── Students
│   ├── List Students
│   ├── Student Details
│   ├── Add Student
│   ├── Update Student
│   └── Delete Student
│
└── Profile
    └── Get Profile

24. Collection and Team Work

Collections can also help teams organize and share API request definitions.

A backend developer can prepare API requests while a mobile developer can use those requests to understand and test the API endpoints.

The exact sharing and collaboration features depend on the Postman setup being used.

25. Collection Naming Best Practices

Use clear and meaningful names.

  • Student Management API
  • Library Management API
  • Online Course API
  • E-Commerce API

Avoid unclear names such as Test1 or New Collection for production projects.

26. Common Collection Mistakes

  • Using unclear collection names
  • Keeping unrelated APIs together
  • Not organizing requests into folders
  • Using unclear request names
  • Duplicating the same requests unnecessarily
  • Not maintaining request URLs

27. Collection Testing Checklist

Before using a collection, check:

  1. Collection name is clear.
  2. Requests are organized.
  3. Request names are meaningful.
  4. URLs are correct.
  5. Methods are correct.
  6. Headers are correct.
  7. Request bodies are valid.
  8. Authentication details are configured when required.

28. Complete Student API Collection

Student Management API
│
├── Authentication
│   ├── Register
│   └── Login
│
├── Students
│   ├── Get All Students
│   ├── Get Student
│   ├── Add Student
│   ├── Update Student
│   ├── Patch Student
│   └── Delete Student
│
└── Profile
    └── Get Profile

This collection can contain the main API requests required by a student management mobile application.

29. Collection and React Native Development

A Postman collection can be used during React Native development to test the backend before writing or debugging the mobile application's API integration.

Postman Collection
       ↓
Test REST API
       ↓
Verify JSON Response
       ↓
React Native Integration
       ↓
Mobile Application

This helps separate backend API testing from mobile UI development.

30. Postman Collections Summary

A Postman Collection is a useful way to organize multiple API requests. Requests can be grouped into folders for authentication, students, users, products, or other project features. Collections make API testing and reusing requests much easier.

Collection
    ↓
Folders
    ↓
API Requests
    ↓
GET / POST / PUT / PATCH / DELETE
    ↓
REST API Testing

📌 Key Points

  • A Postman Collection stores multiple API requests.
  • Collections help organize API testing.
  • Requests can be grouped into folders.
  • GET, POST, PUT, PATCH, and DELETE requests can be stored in collections.
  • Request URLs can be saved for reuse.
  • Headers and request bodies can be saved with requests.
  • Meaningful request names make collections easier to understand.
  • Collections are useful for large API projects.
  • Collections can help organize APIs used by React Native applications.
  • A well-organized collection makes API testing easier.

🧠 Quick Quiz

Question: What is a Postman Collection mainly used for?