Using Variables
How to use variables in your endpoints.
In this guide, we'll show you how to use variables in your endpoints.
Introduction
Before we begin, make sure you have:
- An active account on FluxyAPI.
- A project created (see Create your first project).
- A variable you would like to use (from any supported source, including storage).
Using Variables
You can see the variable library in our Variable Library doc or click the </> icon to view available variables.
Using Strings In Endpoints
Using strings is extremely simple. First, make sure your variable actually resolves to a string. You can check this by clicking the </> icon to go to the variable library.
Next up, to reference your string in a response block for example, you simply write {VAR_variable_name}, this will then be substituted automatically for the value, like FluxyAPI is great!.
Using Numbers In Endpoints
Using numbers is extremely simple. First, make sure your variable actually resolves to a number. You can check this by clicking the </> icon to go to the variable library.
Next up, to reference your number in a response block for example, you simply write {VAR_variable_name}, this will then be substituted automatically for the value, like 123.
Using Arrays In Endpoints
Using arrays in endpoints isn't too hard. First, make sure your variable actually resolves to an array. You can check this by clicking the </> icon to go to the variable library. There are two main ways to use arrays:
- The first way is using
{VAR_variable_name}, this will substitute for the array in this format:
["Value1", "Value2", "Value3", "Value4", ...]- The second way is to get a specific value using
{VAR_variable_name[index]}, here replace index with the index of the value you want to get. It will substitute for the value like this:Value1. - Example:
{VAR_variable_name[0]}returns:
"Value1"Using Objects in Endpoints
Referring to objects is straightforward. First, make sure your variable actually resolves to an object. You can check this by clicking the </> icon to go to the variable library.
Below are common access patterns and a full example to make this clear.
{
"myObject": {
"user": {
"id": 123,
"name": "Alice",
"email": "[email protected]",
"roles": ["admin", "editor"]
},
"features": {
"beta": true,
"quota": 1000
}
}
}- Insert the whole object:
{VAR_myObject}will substitute the full JSON object. - Access a nested value:
{VAR_myObject.user.name}→Alice. - Access an array element inside the object:
{VAR_myObject.user.roles[0]}→admin. - Bracket notation (for keys with punctuation or dynamic keys):
{VAR_myObject['features'].quota}→1000.
Example: using object values in a JSON response block
{
"message": "Hello, {VAR_myObject.user.name}!",
"isBetaUser": {VAR_myObject.features.beta},
"roles": {VAR_myObject.user.roles},
"rawObject": {VAR_myObject}
}Notes:
- Missing keys will result in empty substitutions — validate keys where needed.
- When inserting whole objects/arrays the substitution preserves JSON structure, so ensure surrounding syntax remains valid.
Variables are case-sensitive. {VAR_myObject.user.name} is different from
{VAR_myObject.User.name}
Note
If you've got any questions or encounter any issues, feel free to join our Discord server, and we'll try to fix any issues you may face!
