API Check has 4 different types of variables:
- Built-In variables are initialized at the beginning of the check before any steps have run. These variables remain constant within a run but will change between runs.
- Request variables are updated after every request step.
- Custom variables are created by the user.
- Global variables that can be shared across checks.
Built-In
There are many built-in variables in API Check that can be accessed within steps. Built-In variables are initialized at the beginning of the check before any steps have run. These variables remain constant within a run but will change between runs.
Random
- random.hex - fc7eaf12b54eb220ac1758c657518dee
- random.integer - 1463500376
Date
- date.today - 2016-05-17
- date.year - 2016
- date.month - 05
- date.day - 17
Time
- time.now - 2016-10-18 13:46:02 -0400
Location
- location.region - us-east-1
- location.public_ip - 54.208.109.193
- location.name - N. Virginia
- location.name_as_param - N.-Virginia
- location.latitude - 39.0437
- location.longitude - -77.4875
- location.geolocation - {"coords":{"latitude":"39.0437","longitude":"-77.4875"}}
Check
- check.run_counter (increments by 1 every time the check is queued) - 34
- check.location_run_counter (increments by 1 every time the check is queued to a location) - 21
Request
- response.body
- response.body_size
- response.code
- response.response_time (in milliseconds)
- response.dns_time (in milliseconds)
- response.first_byte_time (in milliseconds)
Additionally response headers can be accessed via the headers namespace. For example, to access the Cache-Control header, use the headers.Cache-Control variable name surrounded by double braces.
Custom Variables
Custom variables are stored in the custom namespace. If you create a variable named url, it will be stored as custom.url and can be accessed in a step as {{custom.url}}.
Global Variables
Global Variables are variables that can be used across checks. They are stored in the env namespace. If you create a variable with a key of api-key, you can access it in a step as {{env.api-key}}. For more information about Global Variables, see our Global Variables article.