Skip to content

Commit 2eff152

Browse files
authored
chore: add coll variable and priority list (#307)
1 parent 4667cf0 commit 2eff152

File tree

1 file changed

+69
-59
lines changed

1 file changed

+69
-59
lines changed

documentation/features/variables.mdx

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,96 +4,106 @@ title: Variables
44
description: Dynamic placeholders for your API interactions.
55
---
66

7-
Hoppscotch provides you the ability to create and use variable throughout the app. This helps you reuse values throughout Hoppscotch just by invoking the variable name.
7+
Hoppscotch provides you the ability to create and use variable throughout the app. This helps you reuse values throughout Hoppscotch just by invoking the variable name.
88

99
Hoppscotch considers an objects within an angular brackets as a variable `<<variable>>`
1010

1111
## Variable Scopes
1212

1313
Hoppscotch provides you different variables scopes, allowing you to use different scopes for different contexts.
1414

15-
1. **Global Variables:** can be accessed throughout Hoppscotch and has the broadest scope of all variables.
15+
1. **Global Variables:** can be accessed throughout Hoppscotch and has the broadest scope of all variables.
1616
2. **Environment Variables:** allow your variables to be scoped to an environment. Environment variables are useful when you have the same set of variables for two environments such as production and staging.
1717
3. **Request Variables:** are scoped to just an individual request, request variables are useful when you want to use variables in your URL path or when you want to embed a variable URL.
1818
4. **Predefined Variables:** are automatically generated at runtime and can be accessed globally throughout Hoppscotch using the `$` symbol, such as `$guid` or `$timestamp`.
19+
5. **Collection Variables:** are scoped to individual collection and child folders, perfect for sharing base URLs, tokens and defaults across a set of requests without leaking to other workspaces.
1920

20-
The scope of each variable can be identified from the color of the variable name
21+
The scope of each variable can be identified from the color of the variable name. If a variable with same name exist it is resolved in the order of priority.
2122

22-
| Variable Scope | Color |
23-
| --- | --- |
24-
| Global | Blue |
25-
| Environment | Green |
26-
| Request | Orange |
27-
| Predefined | Yellow |
28-
| Non resolvable | Red |
23+
| Variable Scope | Color | Priority |
24+
| -------------- | ----- | -------- |
25+
| Request | 🟠 | 1 |
26+
| Collection | 🟣 | 2 |
27+
| Predefined | 🟡 | 3 |
28+
| Environment | 🟢 | 4 |
29+
| Global | 🔵 | 5 |
30+
| Non resolvable | 🔴 | - |
2931

3032
## Types of Variables
3133

32-
1. **A regular variable**: allows users to reference the variable throughout Hoppscotch, and anyone can see the value associated with the variable.
33-
In a workspace, regular environment variable-value pairs will be synced to the server, making them available to all workspace members.
34-
However, you have the option to choose whether to sync a regular variable value present in your personal workspace
35-
2. **A secret variable:** enables users to specify secrets and reference the values as variables. The values of secret variables in any workspace will never be synced to the server or shared with any workspace members.
36-
It is expected that in a collaborative workspace the user will populate the value of the variable at runtime.
37-
All secret variable values in Hoppscotch will be masked using asterisks (***). Secret Variables cannot be scoped to a request and can only be scoped in an environment or globally
34+
1. **A regular variable**: allows users to reference the variable throughout Hoppscotch, and anyone can see the value associated with the variable.
35+
In a workspace, regular environment variable-value pairs will be synced to the server, making them available to all workspace members.
36+
However, you have the option to choose whether to sync a regular variable value present in your personal workspace
37+
2. **A secret variable:** enables users to specify secrets and reference the values as variables. The values of secret variables in any workspace will never be synced to the server or shared with any workspace members.
38+
It is expected that in a collaborative workspace the user will populate the value of the variable at runtime.
39+
All secret variable values in Hoppscotch will be masked using asterisks (\*\*\*). Secret Variables cannot be scoped to a request and can only be scoped in an environment or globally
3840

39-
<Note> Secret variables values will not be exported when an environment is exported.</Note>
41+
<Note>
42+
{" "}
43+
Secret variables values will not be exported when an environment is exported.
44+
</Note>
4045

41-
3. **A predefined variable:** is automatically generated at runtime and provides dynamic, context-specific data. Predefined variables are available throughout your requests and responses and are useful for incorporating system-level information or dynamic values into your API interactions without manual configuration.
42-
All predefined variables are accessible throughout Hoppscotch and can be retrieved using the `$` symbol. Below is the list of predefined variables whose values are dynamically generated during the request or collection run:
46+
3. **A predefined variable:** is automatically generated at runtime and provides dynamic, context-specific data. Predefined variables are available throughout your requests and responses and are useful for incorporating system-level information or dynamic values into your API interactions without manual configuration.
47+
All predefined variables are accessible throughout Hoppscotch and can be retrieved using the `$` symbol. Below is the list of predefined variables whose values are dynamically generated during the request or collection run:
4348

44-
>| **Variable Name** | **Description** | **Example** |
45-
>| ----------------- | --------------------------------------------------------------------------------------------- | --------------------------------------- |
46-
>| `$guid` | A v4 style unique (GUID) identifier for each request. | `123e4567-e89b-12d3-a456-426614174000` |
47-
>| `$timestamp` | The current UNIX timestamp in seconds | `1693047645` |
48-
>| `$isoTimestamp` | The current date and time in ISO-8601 format at zero UTC (also known as "Zulu time" or UTC-0) | `2024-09-25T00:00:00.000Z` |
49-
>| `$randomUUID` | A random 36-character UUID. | `6929bb52-3ab2-448a-9796-d6480ecad36b` |
49+
> | **Variable Name** | **Description** | **Example** |
50+
> | ----------------- | --------------------------------------------------------------------------------------------- | -------------------------------------- |
51+
> | `$guid` | A v4 style unique (GUID) identifier for each request. | `123e4567-e89b-12d3-a456-426614174000` |
52+
> | `$timestamp` | The current UNIX timestamp in seconds | `1693047645` |
53+
> | `$isoTimestamp` | The current date and time in ISO-8601 format at zero UTC (also known as "Zulu time" or UTC-0) | `2024-09-25T00:00:00.000Z` |
54+
> | `$randomUUID` | A random 36-character UUID. | `6929bb52-3ab2-448a-9796-d6480ecad36b` |
5055
>
5156
> ### <ins>Numbers, Text, and Colors</ins>
5257
>
53-
>| **Variable Name** | **Description** | **Example** |
54-
>| --------------------- | ------------------------------------------------------------------------ | ----------------------- |
55-
>| `$randomAlphaNumeric` | A random alpha-numeric character. | `A9X1Z3` |
56-
>| `$randomBoolean` | A random boolean value. | `true` , `false` |
57-
>| `$randomInt` | A random integer value between 0 and 1000. | `29` , `432` , `786` |
58-
>| `$randomColor` | A random color amongst **red, green, blue, yellow, purple, and orange.** | `yellow` |
59-
>| `$randomHexColor` | A random hex value. | `#f2a729` |
60-
>| `$randomAbbreviation` | A random abbreviation. | `SQL` , `JSON` , `HTML` |
58+
> | **Variable Name** | **Description** | **Example** |
59+
> | --------------------- | ------------------------------------------------------------------------ | ----------------------- |
60+
> | `$randomAlphaNumeric` | A random alpha-numeric character. | `A9X1Z3` |
61+
> | `$randomBoolean` | A random boolean value. | `true` , `false` |
62+
> | `$randomInt` | A random integer value between 0 and 1000. | `29` , `432` , `786` |
63+
> | `$randomColor` | A random color amongst **red, green, blue, yellow, purple, and orange.** | `yellow` |
64+
> | `$randomHexColor` | A random hex value. | `#f2a729` |
65+
> | `$randomAbbreviation` | A random abbreviation. | `SQL` , `JSON` , `HTML` |
6166
>
6267
> ### <ins>Internet and IP addresses</ins>
6368
>
64-
>| **Variable Name** | **Description** | **Example** |
65-
>| ---------------------- | ---------------------------------------------------- | ---------------------------------------- |
66-
>| `$randomIP` | A random IPv4 address | `192.168.0.101` |
67-
>| `$randomIPV6` | A random IPv6 address | `2001:0db8:85a3:0000:0000:8a2e:0370:7334`|
68-
>| `$randomMACAddress` | A random MAC address. | `00:1B:44:11:3A:B7` |
69-
>| `$randomPassword` | A random 15-character alpha-numeric password. | `H8w72Sx93KlqA1b` |
70-
>| `$randomLocale` | A random two-letter language code (ISO 639-1). | `en`, `fr`, `es` |
71-
>| `$randomUserAgent` | A random user agent. | `Mozilla/5.0 (Windows NT 10.0; Win64)` |
72-
>| `$randomProtocol` | A random internet protocol. | `https`, `ftp` |
73-
>| `$randomSemver` | A random semantic version number. | `1.2.3` |
69+
> | **Variable Name** | **Description** | **Example** |
70+
> | ------------------- | ---------------------------------------------- | ----------------------------------------- |
71+
> | `$randomIP` | A random IPv4 address | `192.168.0.101` |
72+
> | `$randomIPV6` | A random IPv6 address | `2001:0db8:85a3:0000:0000:8a2e:0370:7334` |
73+
> | `$randomMACAddress` | A random MAC address. | `00:1B:44:11:3A:B7` |
74+
> | `$randomPassword` | A random 15-character alpha-numeric password. | `H8w72Sx93KlqA1b` |
75+
> | `$randomLocale` | A random two-letter language code (ISO 639-1). | `en`, `fr`, `es` |
76+
> | `$randomUserAgent` | A random user agent. | `Mozilla/5.0 (Windows NT 10.0; Win64)` |
77+
> | `$randomProtocol` | A random internet protocol. | `https`, `ftp` |
78+
> | `$randomSemver` | A random semantic version number. | `1.2.3` |
7479
>
7580
> ### <ins>Names</ins>
7681
>
77-
>| **Variable Name** | **Description** | **Example** |
78-
>| ---------------------- | ---------------------------------------------------- | ---------------------------------------- |
79-
>| `$randomFirstName` | A random first name. | `Ethan` , `Chandler`, `John` |
80-
>| `$randomLastName` | A random last name. | `Schaden` , `Schneider` , `Doe` |
81-
>| `$randomFullName` | A random Full name. | `Ethan Schaden` , `Chandler Schneider` , `John Doe` |
82-
>| `$randomNamePrefix` | A random name prefix. | `Dr.` , `Miss.` , `Prof.` |
83-
>| `$randomNameSuffix` | A random name suffix. | `MD` , `PhD` , `Jr.` |
82+
> | **Variable Name** | **Description** | **Example** |
83+
> | ------------------- | --------------------- | --------------------------------------------------- |
84+
> | `$randomFirstName` | A random first name. | `Ethan` , `Chandler`, `John` |
85+
> | `$randomLastName` | A random last name. | `Schaden` , `Schneider` , `Doe` |
86+
> | `$randomFullName` | A random Full name. | `Ethan Schaden` , `Chandler Schneider` , `John Doe` |
87+
> | `$randomNamePrefix` | A random name prefix. | `Dr.` , `Miss.` , `Prof.` |
88+
> | `$randomNameSuffix` | A random name suffix. | `MD` , `PhD` , `Jr.` |
8489
>
8590
> ### <ins>Addresses and Profession</ins>
8691
>
87-
>| **Variable Name** | **Description** | **Example** |
88-
>| ---------------------- | ---------------------------------------------------- | ---------------------------------------- |
89-
>| `$randomCity` | A random city name. | `New York` , `Houston` , `Philadelphia` |
90-
>| `$randomJobArea` | A random job area. | `Intranet` , `Development` , `Testing` |
91-
>| `$randomJobDescriptor` | A random job descriptor. | `Corporate` , `Lead` , `Principal` |
92-
>| `$randomJobTitle` | A random job title. | `Global Branding Officer` , `Productivity Analyst` |
93-
>| `$randomJobType` | A random job type. | `Manager` , `Coordinator` , `Director` |
92+
> | **Variable Name** | **Description** | **Example** |
93+
> | ---------------------- | ------------------------ | -------------------------------------------------- |
94+
> | `$randomCity` | A random city name. | `New York` , `Houston` , `Philadelphia` |
95+
> | `$randomJobArea` | A random job area. | `Intranet` , `Development` , `Testing` |
96+
> | `$randomJobDescriptor` | A random job descriptor. | `Corporate` , `Lead` , `Principal` |
97+
> | `$randomJobTitle` | A random job title. | `Global Branding Officer` , `Productivity Analyst` |
98+
> | `$randomJobType` | A random job type. | `Manager` , `Coordinator` , `Director` |
9499
95100
<CardGroup cols={1}>
96-
<Card title="Environments" iconType="light" icon="circle-arrow-right" href="/documentation/features/environments">
101+
<Card
102+
title="Environments"
103+
iconType="light"
104+
icon="circle-arrow-right"
105+
href="/documentation/features/environments"
106+
>
97107
Choose the environment that aligns best with your development workflow.
98108
</Card>
99-
</CardGroup>
109+
</CardGroup>

0 commit comments

Comments
 (0)