Skip to content
On this page

Environments

Environments allow you to reuse special variables across your entire collection. You might store a long URL in an environment and reuse it in every request. Environments are also handy if you have different deployments, like production and staging. With environments you do not have to change the request every time you want to use a different deployment target. Yaade provides a sophisticated environment interpolation system. To create a new environment click ••• > Environment next to the desired collection.

Environment Variables

Environments consist of multiple environment variables. Each variable has a key and a value. When sending a request, keys in your request are interpolated to the corresponding value.

To reference a specific environment variable in your request, simply put ${key} anywhere in your request. Variables can be used in any part of your request, e.g. URL, headers, query parameters or the body.

For example, if you use an environment that has the following variables:

KeyValue
hosthttps://example.com
path/test

Now if you have an URL of the form ${host}${path} it will resolve to https://example.com/test when sending your request.

Environment variables are also recursively resolved, which makes it possible to reference variables in other variables. Let's extend the example above:

KeyValue
url${host}${path}

Now you can set your URL to ${url} and it will again resolve to https://example.com/test.

TIP

Environment Variables use JavaScript Template literals under the hood. To find out what other cool things you can do with them, check out the MDN docs.

Special Operators

It is possible to interpolate some special operators for example to generate random data. To use a special operation, simply use it inside an interpolation like ${$r.integer(0,10)}.

Say your URL is something like https://example.com/${$r.integer(0,10)} when sending this request the operation will be executed and the result would be https://example.com/9.

WARNING

Special operators are executed on every request. So the interpolated data of your request may change every time you send the request.

You can also use special operators in your environment variables.

KeyValue
url${$r.uuid4()}

Available Operators

Below is a list of available operators.

random-js

We support random-js by referencing $r. You can read the full random-js docs here. Below are some useful commands taken from their documentation.

  • $r.integer(min, max): Produce an integer within the inclusive range [min, max]. min can be at its minimum -9007199254740992 (2 ** 53). max can be at its maximum 9007199254740992 (2 ** 53). The special number -0 is never returned.
  • $r.real(min, max, inclusive): Produce a floating point number within the range [min, max) or [min, max]. Uses 53 bits of randomness.
  • $r.die(sideCount): Same as r.integer(1, sideCount)
  • $r.uuid4(): Produce a Universally Unique Identifier Version 4.
  • $r.string(length): Produce a random string using numbers, uppercase and lowercase letters, _, and - of length length.
  • $r.string(length, pool): Produce a random string using the provided string pool as the possible characters to choose from of length length.
  • $r.hex(length) or r.hex(length, false): Produce a random string comprised of numbers or the characters abcdef of length length.
  • $r.hex(length, true): Produce a random string comprised of numbers or the characters ABCDEF of length length.
  • $r.date(start, end): Produce a random Date within the inclusive range of [start, end]. start and end must both be Dates.

Luxon

The Luxon DateTime object can be referenced via $t. Check out the Luxon example page for detailed examples. Below are some useful commands taken from their documentation.

  • $t.utc().toISO()
  • $t.now().plus({minutes: 15, seconds: 8})

Env

Inside an interpolation operation you can access other variables from this environment by referencing $env. This is useful when you want to conditionally set variables or use them in other computations. Say we have the following environment:

KeyValue
authbearer
bearerPrefixBearer

${$env.auth === "bearer" ? $env.bearerPrefix : "Basic"} results in Bearer.

Proxies

A proxy executes the actual request. Yaade currently supports the browser extension (Extension) and the server inside the docker container (server) as proxies.

Extension

The default proxy is your browser extension. This proxy allows you to execute requests to your machine's localhost. Note that the extension has to be installed and configured in order to send requests to it. If the extension is not installed or wrongly configured, an error message will pop up when trying to send a request.

To enable this proxy, select Extension in your environment.

Server

The server proxy is the docker container that Yaade is running in. This proxy allows you to use secrets. Read the section for secrets for more details.

To enable this proxy, select Server in your environment.

Secrets

Secrets provide a mechanism to store sensitive information even more securely. After a secret is created, it can never be read again by a client. It is stored safely inside Yaade's database. Because of this, secrets are interpolated by the server and can therefore only be used if your proxy is set to Server.

Analogous to environment variables, secrets can be used anywhere in your request by adding $S{key} (note the S after the $-sign).

WARNING

Secrets do not use template literals, so they do not have the functionality of variables. Only simple interpolation is supported.

To understand how secrets can be used, take the following example.

Variables

KeyValue
accessKeysome-key

Secrets

KeyValue
secretKeyxxx

Now if you would have a header Authorization with the value

${accessKey}:$S{secretKey}

the client would interpolate it to

some-key:$S{secretKey}

and the server would in turn interpolate it to

some-key:xxx

before sending the request.

Imprint