API testing – API Environment

API testing

This part had many people wrote tutorials, but there are some parts missing, so I rewrote it. Today I will share with you what is API environment

Introduction about API environment

The main function of Environment is a place to save “variables” like “variables” in the code so that we can reuse it in many places.


– Quickly switch between Dev and Product environments without re-creating new requests because of having to change URLs again.

– Help save the value of the API response first to fill in the API later. (This part is combined with the Pre-request and Tests sections, which will be introduced in the next articles).

– Do not have to modify the value of the parameters too many times.

In Postman, it will be divided into 2 types of Environments: Local and Global

  • Local: The scope of influence is only available when choosing the right Environments.
  • Global: Scope affects all projects included in Postman, but if there are 2 variables with the same name in Local and Global, it will be preferred to get Local.

The location of Environment in the postman framework.

Create API enviroment

Step 1: Open Manage Environments

Step 2: Add a new Environment

Step 3: Enter the name of the Enviroment, the name and value of the variable. Here, I take an example with a url variable whose value is

The checkbox shows that: whether the variable is active or not. In the above example: I am active url variable and can use this variable in Demo-dev environment.

Get the value of the variables in request

Just write in the syntax {{variable_name}}: for example: {{url}}

As in the picture:

  • position 1: Where to switch between Environments
  • position 2: How to get variable value. Getting it right will be orange, hovering the mouse will display the value of the variable.
  • position 3: If the variable name is red it means that the variable is not present in the Environment, this usually happens when switching between environments of different projects, or having the variable inactive.

How to view the values ​​of variables in an API environment

Method 1: re-enter Manage Environment like Add Environment

Method 2. Click on the eye icon

If you want to edit the information of the Environment, you can click the Edit button to edit it.

What can be done with API enviroment?

Postman provides simple functions for an Environment such as: import – export, duplicate, add, edit, delete.

So, that’s it. Thank you for reading.

To read more articles about API testing , please go this link

Leave a Reply

Your email address will not be published. Required fields are marked *

API testing

Test runner – API testing

Test runner – According to the previous post, you already know how to create simple tests for each API, but a project has too many APIs and too many different tasks, each task is a collection of several APIs how must be solved. Along with that is the management method that you think is applicable […]

API testing

How to test API

After reading “test API with Postman” series, you should be able to grasp the basic knowledge of the API and the functions Postman provides. But how to arrange tests and write Testcases for API still seems not very clear, so today I will write a post about how to test API properly. Reminder of knowledge […]

API testing

API testing – API documentation

Postman, in addition to providing an API testing tool, also helps us to make API documentation extremely professional and easy. This API document can be shared by both the team and the client. Usually, the API is usually written by Dev on google sheets, but at a certain stage of development, the dev will be […]