DEV Community

Cover image for Variables in Postman
Dilpreet Johal
Dilpreet Johal

Posted on

Variables in Postman

In this post, we will go over Postman Variables and look into different types of variable scope that are available in Postman and how we can use them with Postman Collection.

What are Postman Variables?

Variables are like boxes where you can store data and reuse them when needed. For example, you can store data related to your requests like your baseURL or API key or maybe some test data that you are using for your requests like username and password. You can store all these values in Variable and give it a name that you can reuse throughout Postman.

Postman Variables Scope

Postman has different scopes that allow or block the usage of a variable in a particular context. For example, if you have 2 collections and you don’t want other collections to use your variable you can give it a Collection scope to add Collection level scope restriction on it.

  • Global variables – available throughout the workspace and can be accessed between environments, collections, requests, and test scripts.
  • Collection variables – available throughout the requests in a collection
  • Environment variables – set of variables stored for each environment, for example, local development vs testing or production.
  • Local variables – temporary variables, only available for a single request or collection run and are no longer available when the run is complete.
  • Data variables – import variables from external files (CSV & JSON), can be used when running collections via Newman or the Collection Runner.

Check out the video below to learn more about Postman Collections –


To learn about API Test Automation using JavaScript, check out my free tutorial series here –

JavaScript API Test Automation Tutorial Series


I hope this video helped you out, let me know if you have any questions in the comments below!

Happy testing!

...

📧 Subscribe to my mailing list to get access to more content like this
👍 Follow @automationbro on Twitter for the latest updates

Top comments (0)