Products

Envless.products.iterate

Stream products one at a time

def iterate(
  limit: nil,
  offset: nil,
  search: nil,
  order: nil,
  timeout: nil,
  &block
)

An Enumerator 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

ruby
require "envless/sdk"

Envless.products.iterate(order: "asc") do |product|
  puts product[:slug]
end

Parameters

ParameterTypeRequiredDescription
limit:IntegerNoPage size for each underlying request, capped at 100.
offset:IntegerNoRow to start the walk from.
search:String | SymbolNoCase-insensitive substring match against product name and slug.
order:"name" | "asc" | "desc"NoDefaults to name, which sorts A to Z. Pass asc for oldest first or desc for newest first on createdAt.
timeout:Integer | Float | RationalNoSeconds each attempt of this call may take, redirects and the response body included, before it raises Envless::NetworkError with timeout? set. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

An Enumerator[product_resource, nil] that yields each product in turn.

Reads the products collection. list returns one page as an Envless::Page with items and pagination, list_all collects every page into an array, and iterate yields one item at a time to a block, fetching the next page only when it gets there. Without a block, iterate returns an Enumerator.

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.