def iterate(
*,
limit: int | None = None,
offset: int | None = None,
search: str | None = None,
order: str | None = None,
timeout: float | None = None,
) -> Iterator[ProductResource]def iterate(
*,
limit: int | None = None,
offset: int | None = None,
search: str | None = None,
order: str | None = None,
timeout: float | None = None,
) -> AsyncIterator[ProductResource]An iterator that yields products one by one and requests the next page only when the current one is exhausted. Nothing is fetched until the first iteration, and breaking out of the loop ends the walk with no further requests.
The walk advances the offset by the number of rows it received, so products created or deleted while you iterate can move the window and cause a row to repeat or be skipped. Treat each page as a snapshot rather than a consistent view of the workspace.
Example
from envless import envless
for product in envless.products.iterate(order='asc'):
print(product['slug'])import asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
async for product in envless.products.iterate(order='asc'):
print(product['slug'])
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | int | No | Page size for each underlying request, capped at 100. |
offset | int | No | Row to start the walk from. |
search | str | No | Case-insensitive substring match against product name and slug. |
order | str | No | Defaults to name, which sorts A to Z. Pass asc for oldest first or desc for newest first on createdAt. |
timeout | float | No | Seconds each attempt of this call may take, the response body included, before it raises EnvlessNetworkError with is_timeout set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
An Iterator[ProductResource] that yields each product in turn.
Reads the products collection. list returns one page as a dict with items and pagination, list_all collects every page into a list, and iterate yields one item at a time, fetching the next page only when the loop reaches it. On AsyncEnvless, iterate is an async iterator for async for.
Worth knowing
- This is the only list variant that keeps memory flat, since at most one page is held at a time.
Required scopes
products:read
Underlying endpoint
GET /products
Request and response schema, every error code, and a live playground.
In TypeScript
envless.products.iterate()
The same method in @goenvless/sdk, with the same request, retries and errors.