Contents:

Training with a job guarantee: Web Developer specialty
Find out moreThe modern internet relies heavily on the use of APIs, and, in general, the backend rarely functions without programming interfaces. Despite all the convenience they provide, there is also a certain complexity: these interfaces require development of architecture and logic, creation of documentation, testing, and scaling.
Fortunately, there are many services that help simplify this process. One such tool is Postman. Although it is often considered only a tool for API testing, in fact, this platform has much broader functionality.
Postman: what is this tool and its purpose
Postman is a platform designed for developing, testing, documenting, publishing, and maintaining APIs. With its help, you can form collections of requests to any API, use various environments, set up mock servers, and write automated tests in JavaScript. In addition, Postman provides the ability to analyze and visualize request results.
The program supports many API architectures, including HTTP, REST, SOAP, GraphQL, and WebSockets. Postman is widely used by companies like Twitter, WhatsApp, and Imgur. Its intuitive graphical interface makes it easy for even a novice user to learn the platform.
Postman is available for free download from its official website. The software is available for Linux, Windows, and macOS operating systems. However, you'll need to register before you can begin using it.
How Postman Works
The key element of Postman is its workspace. The free version of the program offers three types of these spaces:
- Private is available only to its owner.
- Only those group members directly involved in its work have access to team information.
- Public means that it is open to anyone who shows interest.
The Pro version allows users to create private workspaces that can be used only by invited participants, as opposed to all team members. In turn, the Enterprise version offers partner workspaces, available not only to the team, but also to invited partners.
Let's analyze what elements are included in the Postman workspace:

The most notable part is the left sidebar. It consists of seven tabs, each of which represents a key Postman tool.
- The Collections section contains collections of API requests. Within a single collection, it is possible to group multiple requests into folders.
- APIs. In this section, you can save complete APIs, including their specifications and sets.
- Environments. In this section, environments containing variables are created and stored. From any tab in the upper right corner, where No Environment is indicated, you can switch between active environments. In addition, here you can create global variables that are available for use anywhere, regardless of the selected environment.
- Mock Servers. This platform allows you to create virtual servers that simulate the functioning of real ones. This is especially useful during testing.
- Monitors provide the ability to observe and analyze API performance: they help control performance, check server availability and correct operation at a specified time, and send notifications in the event of failures.
- Flows is a tool that allows you to configure the logic of API applications through a visual editor. As of March 2023, it is still in testing, and you must submit a request to access it.
- History. This section stores all previously sent requests. You can save them, group them into collections, and also create documentation, monitoring, and mock servers for them.
Efficient Use of Postman: A Step-by-Step Guide
Postman is a widely used tool that is actively used by testers. It can be used to generate requests to any API, regardless of whether Postman was used during their development.
The platform offers its own API, allowing any user to test the service's functionality and explore how requests work. This echo server responds to the client with the same data that was sent to it. You can view the documentation at the following link.
Let's try creating our own API request and testing its functionality.
To create a new collection, go to the Collections section and click the plus icon. The New Collection item will appear on the left side of the application.

To change the name to Test Collection, you need to click on the three dots located to the right of the New Collection item, and then in the menu that appears select the Rename option.

The collection work area contains five different tabs:
- The authorization section allows you to set the method and parameters that will be applied for each request within a given collection.
- Pre-request Script is where you can create a JavaScript program that will run before each request within a collection. Postman provides ready-made snippets for the most popular algorithms, allowing you to use them instead of writing code from scratch.
- The Tests section functions similarly to the Pre-request Script, but its code is executed after the request is sent. This component is intended for testers who are checking APIs. Ready-made code snippets are also available in this section.
- Variables. In this section, you can define a variable and assign it a specific value. You can then use this variable by referencing its name in double curly braces {{variable name}}.
- Postman provides the ability to execute requests not one by one, but in groups - entirely from a single collection or folder. Information about such runs and their test results is stored in the Runs section.
There are several methods for forming a request:
- you need to click the New button located in the upper left corner and select the appropriate request type;
- click the plus icon located on the tab bar at the top of the application;
- You need to click the three dots next to the collection name and select the «Add request» option in the menu that appears.
When choosing the first or second option, it is important to specify the collection to store the request when saving it for the first time.
Let's create a GET request to the address https://postman-echo.com and designate it as Test GET. Please note that request names can be changed, just like collection names. To complete this task:
- Let's formulate a new request.
- We'll select the GET method for this.
- Let's go to the following address: https://postman-echo.com/get/.
- In the Params section, we'll specify the test_key1 and test_key2 keys, as well as the corresponding test_value1 and test_value2 values.
- Click the Send button.

The echo server sent us a JSON document containing the headers and parameters we passed it (Postman adds some headers automatically).
After you receive the response, you will be able to separately review the cookies, headers, and any test results, if any. In addition, Postman provides information about the response status, the time it took to receive it, and the size of the returned file.
In Postman, as in collections, you can specify the method, authorization parameters, as well as pre-request scripts and tests in requests.
By default, authorization is inherited from the collection, but it can be changed within a specific request. As for scripts, they are executed in full—both those common to the entire collection and those created specifically for this request.
Now let's create a simple test for our GET request that will check the response code. If we receive a code of 200, which means the request was successfully completed, the test will be considered successful.
Now let's open the Tests tab and in the right column, find a snippet labeled "Status code: Code is 200." Click on it, and the script will appear.

Let's repeat our request. In the response section, on the «Test Results» tab, We will see the test report: the status is PASS, which means it was completed successfully.

Now let's create two more tests, but not within a separate request, but within a single collection. The first test will check for the presence of the string test_value2 in the response, and the second will look for the string string_you_want_to_search.
Now let's go to the Test Collection section and open the Tests tab. Select the snippet called Response body: Contains string and double-click it. In the first part of the code, replace the string string_you_want_to_search with test_value2, and leave everything unchanged in the second. Don't forget to save your changes so that the new tests take effect for the request.

Now let's send a similar GET request to the echo server. It should pass the first test since we used test_value2 as one of the parameters, but it will fail the second test. Let's check the result.

Everything happened exactly as we expected. The request ran both its individual tests and tests from the shared collection, and one of them failed. However, the collection tests were executed first, before the request tests themselves.
The order of execution of scripts located in different parts of the collection is as follows:
- The collection-related scripts are run first.
- After that, you can create scripts in the folder, since they can also be placed there.
- Then come the scripts for executing requests.
This approach applies to all code, both in the Tests section and in Pre-request Scripts.
Variables, like tests, exist at different levels in Postman and can be created in different places:
- Global variables cover all elements of the workspace. They can be created in the Environments tab, in the Globals area.
- Collection variables are created within a specific collection and function only within it.
- Environment variables are set in the Environments section. To use them in queries, you must directly associate the query with the corresponding environment.
- Local variables function in the context of scripts that are activated in response to incoming queries.
- Data variables appear when using Collection Runner, a tool that allows you to simultaneously execute all scripts located in a collection or its folder.
The narrower the scope of a variable, its priority increases. This means that if a global and a local variable have the same name, the value of the local variable will be used.
To create a new environment called Test Environment, you should use the same process as when creating a collection, but this time you need to go to the Environment tab.

Let's declare a variable named test_variable and assign it a value of test_value3. Don't forget to save the changes in the current environment.

Next, we'll switch to the test collection and activate the desired environment by selecting it in the upper right corner of the interface. All variables from the selected environment are now available within this collection.

Let's modernize the second script in the collection tests. To do this, replace the line «string_you_want_to_search» to the snippet that receives the environment variable. In this snippet, we'll change variable_key to the name of the test_variable variable. After making the changes, don't forget to save the result.
Therefore, the second script will check for a match in the server response not with the specific string_you_want_to_search, but with the contents of the test_variable.

Now let's look at the GET request and add a new parameter. The key of this parameter will be test_key3, and its value will be the contents of the test_variable variable. To denote the variable, we enclose its name in double curly braces {{}}. After that, we save the changes and send the request.

As we can see, all tests have been successfully completed. This indicates that the value of our variable is correctly retrieved both from the request parameters and during testing.

To summarize
Postman is a universal A tool that covers all stages of the API lifecycle. However, it has gained particular popularity among testers due to its extensive set of capabilities for working with API requests. This application not only allows you to create and configure requests but also organize them into collections and folders. Additionally, it supports various environments with custom variables, as well as writing automated tests.
Postman offers various paid plans, but for getting started, personal projects, or API testing, the free version is sufficient.
You'll find a wealth of fascinating information about programming and coding in our Telegram channel. Join us!
Read also:
- Challenges QA Engineers Face: What Challenges Do Testers Face?
- Test: Determine Which of the Presented Programming Languages Are Esoteric and Which Are Not.
- An API, or application programming interface, is a set of rules and protocols that allows different software applications to interact with each other. It serves as a bridge that facilitates the exchange of data and functionality between systems.
APIs work on the basis of requests and responses. When one application, for example, sends a request to another through an API, it uses a specific format to specify what information or action it needs. This can be done, for example, using HTTP requests such as GET, POST, PUT, and DELETE.
The response from the API usually comes in a format understood by the applications, most often JSON or XML. Thus, the API allows developers to integrate various functions and data into their applications without delving into the implementation details or internal mechanisms of other systems.
Ultimately, the API significantly simplifies the development process, allowing you to create more complex and functional solutions by combining existing services and tools.

