Postman collection organization in Rest API - Time & Space Complexity
When organizing Postman collections, it's important to understand how the time to find or run requests grows as the collection gets bigger.
We want to know how the effort changes when we add more requests or folders.
Analyze the time complexity of searching for a request in a Postman collection organized with folders and requests.
// Pseudocode for searching a request by name in a Postman collection
function findRequest(collection, name) {
for (const folder of collection.folders) {
for (const request of folder.requests) {
if (request.name === name) {
return request;
}
}
}
return null;
}
This code looks through each folder and each request inside to find a request by its name.
Look for loops or repeated steps in the code.
- Primary operation: Looping through all folders and then all requests inside each folder.
- How many times: The inner loop runs once for each request in every folder, so total requests count.
As the number of folders and requests grows, the search takes longer.
| Input Size (total requests) | Approx. Operations |
|---|---|
| 10 | 10 checks |
| 100 | 100 checks |
| 1000 | 1000 checks |
Pattern observation: The time grows directly with the number of requests; doubling requests doubles the work.
Time Complexity: O(n)
This means the time to find a request grows in a straight line with the number of requests in the collection.
[X] Wrong: "Adding folders makes searching faster because it narrows down the search."
[OK] Correct: Even with folders, if you have to check every request inside, the total work depends on all requests, so folders alone don't reduce search time.
Understanding how organizing API requests affects search time helps you design better tools and workflows, a useful skill in many software roles.
"What if we added an index or map from request names to requests? How would the time complexity change?"
Practice
Solution
Step 1: Understand the role of folders in Postman collections
Folders help group related API requests logically, making them easier to find and manage.Step 2: Identify the benefit of grouping requests
Grouping reduces clutter and helps testers quickly locate and run related requests.Final Answer:
To group related API requests for easier access and management -> Option DQuick Check:
Folders organize requests = A [OK]
- Thinking folders speed up API responses
- Confusing folders with encryption
- Assuming folders auto-generate docs
Solution
Step 1: Recall Postman UI actions for folder creation
In Postman, you add folders by right-clicking the collection and choosing 'Add Folder'.Step 2: Eliminate incorrect options
'New Request' adds a request, not a folder; editing JSON is advanced and not typical; drag and drop moves requests but doesn't create folders.Final Answer:
Right-click the collection and select 'Add Folder' -> Option BQuick Check:
Add folder via right-click = A [OK]
- Clicking 'New Request' to add a folder
- Trying to drag requests to create folders
- Editing JSON instead of using UI
Solution
Step 1: Analyze the request name and folder names
The request 'Create Order' relates to creating an order, so it fits best under the 'Orders' folder.Step 2: Match request purpose to folder
'Users' relates to user data, 'Products' to product info, so 'Orders' is the logical folder.Final Answer:
Orders -> Option AQuick Check:
Request about orders goes to Orders folder = B [OK]
- Putting 'Create Order' in 'Users' folder
- Choosing 'Products' folder incorrectly
- Selecting 'None of the above' without reason
Solution
Step 1: Identify the problem and best practice
Missing descriptions cause confusion; adding clear descriptions helps teammates understand requests.Step 2: Evaluate options for fixing the issue
Renaming collection doesn't fix request descriptions; deleting requests loses work; editing JSON externally is error-prone.Final Answer:
Add clear descriptions to each request explaining its use -> Option CQuick Check:
Descriptions clarify requests = C [OK]
- Renaming collection instead of adding descriptions
- Deleting requests unnecessarily
- Editing JSON outside Postman risking errors
Solution
Step 1: Consider organization for large collections
Nested folders help group requests by features or modules, making navigation easier.Step 2: Importance of descriptions for teamwork
Detailed descriptions explain request purpose, aiding team understanding and future maintenance.Step 3: Evaluate other options
Flat lists become cluttered; separate collections for each request are inefficient; skipping descriptions reduces clarity.Final Answer:
Use nested folders to group requests by feature and add detailed descriptions -> Option AQuick Check:
Nested folders + descriptions = maintainability [OK]
- Using one flat list for many requests
- Creating too many separate collections
- Skipping descriptions to save time
Ready to prove it?
Pass the test and this pattern moves unknown
