Network Variables
This document details the various variables available for use within network requests and configurations.
Understanding Network Variables
Network variables are placeholders that are dynamically replaced with actual values when a request is processed. This allows for flexible and dynamic configuration of your network interactions.
Common Variable Types
The following are common types of variables you can utilize:
- Environment Variables: Access values from the runtime environment (e.g., API keys, server addresses).
- User-Defined Variables: Custom variables you define in your project settings or request configurations.
- Contextual Variables: Variables that provide information about the current request or session (e.g., user ID, timestamp).
Variable Syntax
Variables are typically enclosed in double curly braces {{ }}
. The exact syntax might vary slightly depending on the context, but the general format is consistent.
Example: Using an Environment Variable
GET https://api.example.com/data?api_key={{env.API_KEY}}
Example: Using a User-Defined Variable
POST https://api.example.com/users
{
"username": "{{user.name}}",
"email": "{{user.email}}"
}
Available Variables
Environment Variables (env.*
)
These variables are read directly from the environment where the application is running.
Name | Description | Example |
---|---|---|
env.NODE_ENV |
The current Node.js environment (e.g., development , production ). |
production |
env.API_KEY |
Your application's primary API key. | abcdef123456 |
env.SERVICE_URL |
The base URL for the backend service. | https://api.example.com |
User Variables (user.*
)
These variables are typically defined in user profiles or authentication contexts.
Name | Description | Example |
---|---|---|
user.id |
The unique identifier for the current user. | user_xyz789 |
user.name |
The display name of the current user. | Jane Doe |
user.email |
The email address of the current user. | jane.doe@example.com |
Context Variables (context.*
)
These variables provide information relevant to the current operation or request.
Name | Description | Example |
---|---|---|
context.timestamp |
The current Unix timestamp in milliseconds. | 1678886400000 |
context.request_id |
A unique identifier for the current request. | req_abcde12345 |
Customizing Variables
You can often define custom variables within your request configurations or global settings. Refer to the specific documentation for your network client or framework for details on how to define and manage custom variables.