Overview
In Apidog, a variable serves as a dynamic placeholder for values that can be utilized across multiple API requests and scripts. When executing a request or script, Apidog references the current value of the variable. By grouping variables into environments, you can easily adapt your testing setup to different work scenarios.
Getting Started with Variables
Here's a quick guide to creating and using variables in Apidog:
Click the
Save
button.Open the "Find pet by ID" endpoint, and switch to the
Run
tab.locate the path parameter "PetId", and add
{{my_variable}}
as the value.Move your cursor over the variable name to view its current value and scope.
Click the Environments dropdown besides the
≡
icon, and switch to Local Mock
environment.Click
Send
to execute the request.You will find the response displayed in the lower half of the interface. By switching to the "Actual Request" tab, you can view the request that was actually sent, with variables replaced by their respective actual values.
:::highlight purple
For a deeper understanding of variables in Apidog, go to Using variables.
:::
Create and switch environments
The term "environment" is commonly used in development teams, distinguishing between "development environment," "testing environment," "production environment," and so on. Each environment encompasses one or a set of servers. When the client is in a particular environment, all requests are sent to the servers in that environment. Upon switching environments, requests are directed to a different set of servers.
Learn more about environments and services .