Postman Variables

Photo by Kristina Tripkovic on Unsplash
  • Global
  • Collection
  • Environment
  • Data
  • Local
  • Session

Scope

Here is how the scope of Postman Variable looks like but you might not find Session Variables in the below diagram which I have answered at the last section.

Postman Variable Scope

Global Variables

The word global means it is accessible everywhere & its no rocket science for any programmer 🧑‍💻

  • Use it when you really want values to be shared across multiple collections.
  • It can be overridden by Environment, Collection, Data & Local variables.
  • You should only use them sparingly meaning try to avoid using it.
  • Values can be modified using the scripts.
  • Clear or Remove variables when not needed.

Collection Variables

  • Tied to the collection and cannot be shared across multiple collections.
  • It can be overridden by Environment, Data & Local variables.
  • Values can be modified using the scripts.
Choose Variables tab from Collection

Environment Variables

As the name suggest incase if you have multiple environments like local, development, testing and production it can have different URLs.

  • Use it when you want to things to be specific to the environment like URLs etc...
  • It can be overridden by Data & Local variables.
  • Avoid mixing Global & Collection variables.
  • Values can be modified using the scripts.

Data Variables

The Data Variables comes into picture when running collections with Newman or the Collection Runner.

  • Scope exists only during the execution of an iteration.
  • Can only be set via a CSV or JSON Format file.
  • It can override Global, Collection & Environment variables.

Local Variables

  • It can be override all other scopes temporarily, during the execution of a request or collection /monitor run.
  • Local variables don’t persist between sessions.

Session Variables

By this time you might have got familiar with Global & Environment variables in it while editing you might have noticed INITIAL VALUE & CURRENT VALUE

Summary

Few tips to consider

  • Try to have minimal variables.
  • Try to not to make it collide/mix with other scope variables.
  • Remove unnecessary variables when no longer needed.
  • Don’t store sensitive information in Initial Value.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shiljo Paulson

Shiljo Paulson

Full stack Developer, good at OOPs, .Net, C#, JavaScript, HTML, CSS, SQL