Open In App

What are collections in Postman, and how to use them?

Last Updated : 26 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Postman is an Application Programming Interface (API) tool that streamlines the lifecycle of API development and testing efficiently. It can be used to develop, design, document, and test APIs.

Prerequisites

  • Basic HTTP concepts
  • Knowledge of REST API

What are collections in Postman?

Postman provides the ability to group several API requests into a logical arrangement called Collections. This not only allows developers to save and reuse API requests but also to share them among team members. Collections are one of those features that we can use for documentation, running the Tests, writing Pre-Request Scripts, and all. These all things are bundled up into the collections. Based on collections, we can create Mock Servers to show the behavior of API.

Advantages of Collections

  • Easy APIs import and export: A collection can be imported or exported. Thus it can save time for transferring the requests.
  • Request categorization: Requests can be grouped into folders and collections for easy access.
  • Passing data among requests: Scripts can be used to pass data between API requests.
  • Running collections/folders: You can run individual requests or folders or collections as a whole in the Postman.
  • API documentation: Postman provides you with an option to add a name and description to your request, folder, and collections.
  • Building Test suits: Test scripts can be added to requests, and integration test suites can be built.
  • Time-saving: Setting any variable for collections will automatically apply the same to the folders generated under the collection and requests; thus, it saves time.

Steps to create and use a Collection

Step 1: Click on the + Icon present in the Postman application in the Collections tab.

z178

The Collections tab on the left sidebar shows all the collections that have been created.

  • An Authorization method can be specified for all the requests in the collection in the Authorization tab.
  • Pre-request scripts can be added to run a script before executing each request.
  • Tests can be included which executes after every request.
  • Variables necessary for the collection can be specified in the Variables tab.

Step 2: When you hover, on the name of your collection, 3 dots will appear. Click on those 3 dots, and then click on “Add new request”

z159

Step 3: Now You can simply paste the API in the space provided and select the API type you are requesting from the dropdown like GET,POST, PUT, DELETE etc. Output will be shown in the body with the status code.

API Used:

https://jsonplaceholder.typicode.com/posts/?userId=1

Output:

Recording-2023-12-08-at-122427


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads