Variables

envless.variables.iterate()

Stream variables one page at a time

ts
iterate(project: string, environment: string, options?: ScopedListOptions): AsyncGenerator<VariableResource, void, undefined>

Returns an async generator that yields variables one at a time and fetches the next page only when the current one is exhausted. Nothing is requested until you start consuming it, so calling this without a for await does no work.

Breaking out of the loop ends the walk and no further requests are made. The generator advances offset by the number of items it actually received, so a concurrent write between pages can shift rows and make the walk skip or repeat one. When you need a consistent picture, read with listAll and send every row to apply as the baseline, which turns a concurrent change into a 409 instead of a silent skip.

Example

ts
for await (const variable of envless.variables.iterate('api', 'production')) {
    console.log(variable.name, variable.updatedAt)
}

Parameters

ParameterTypeRequiredDescription
projectstringYesProject slug the environment belongs to.
environmentstringYesEnvironment slug to read variables from.
options.limitnumberNoPage size for each underlying request, clamped to 100.
options.offsetnumberNoOffset the walk starts from, defaults to 0.
options.productstringNoProduct slug, needed when the project slug is not unique in the workspace.
options.signalAbortSignalNoCancels the in-flight page request and ends the walk.

Returns

AsyncGenerator<VariableResource, void, undefined> yielding one variable per iteration.

Reads the variables collection. list returns one page as { items, pagination }, listAll collects every page into an array, and iterate streams one item at a time without buffering the whole set.

Worth knowing

  • Memory stays flat at one page, which is the reason to pick this over listAll for large environments.

Required scopes

variables:read

Underlying endpoint

GET /projects/{slug}/environments/{environmentSlug}/variables

Request and response schema, every error code, and a live playground.

In Python

envless.variables.iterate()

The same method in envless-sdk, the Python SDK, with the same request, retries and errors.

In Ruby

Envless.variables.iterate

The same method in envless-sdk, the Ruby gem, with the same request, retries and errors.

In PHP

$envless->variables->iterate()

The same method in envless/sdk, the PHP SDK, with the same request, retries and errors.