Lazy streaming over paginated Marqeta list endpoints.
Fetches the next page only when the stream consumer exhausts the current one. No prefetching or buffering occurs.
Examples
# Stream all users (auto-paginates)
Marqeta.Stream.stream(&Marqeta.Users.list/1, %{count: 100})
|> Stream.filter(& &1["status"] == "ACTIVE")
|> Enum.to_list()
# Take only the first 50 items
Marqeta.Stream.stream(fn p -> Marqeta.Cards.list_by_user("tok", p) end)
|> Enum.take(50)
# Collect all pages into one list
{:ok, all} = Marqeta.Stream.all(&Marqeta.Users.list/1)
Summary
Functions
Collects all pages into a single list synchronously.
Returns a lazy Enumerable that auto-paginates using list_fn.
Functions
Collects all pages into a single list synchronously.
Returns {:ok, [item]} or {:error, error}.
Prefer stream/3 for large datasets.
Returns a lazy Enumerable that auto-paginates using list_fn.
list_fn must be a 1-arity function accepting a params map and returning
{:ok, page} or {:error, error}.
Options
:raise_on_error— raiseMarqeta.Errorinstead of stopping the stream silently on error. Default:false.