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
for await (const variable of envless.variables.iterate('api', 'production')) {
console.log(variable.name, variable.updatedAt)
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | string | Yes | Project slug the environment belongs to. |
environment | string | Yes | Environment slug to read variables from. |
options.limit | number | No | Page size for each underlying request, clamped to 100. |
options.offset | number | No | Offset the walk starts from, defaults to 0. |
options.product | string | No | Product slug, needed when the project slug is not unique in the workspace. |
options.signal | AbortSignal | No | Cancels 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
listAllfor 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.