Pagination
List endpoints are page-based. The server caps per_page
at 100 and always returns the total row count so
iterators can stop cleanly. SDKs expose both the raw page and a
lazy iterator.
Page shape
Every paginated list returns this envelope:
json
{
"country": "es",
"total": 8677, // true match count from COUNT(*)
"page": 1, // 1-indexed
"per_page": 50, // up to 100
"results": [ ... ]
}
Iterate, don't paginate manually
In every language, the SDK ships a lazy iterator that fetches the next page only when the current one is exhausted. Use it by default — you stop getting surprised by off-by-one boundaries and you can early-exit without caring about cleanup.
# Every Spanish "ley orgánica", fetched one page at a time.
for law in client.laws.iter("es", law_type="ley_organica", per_page=100):
process(law)
# Stop after 500 matches for a search.
for law in client.laws.search_iter("es", q="datos", limit=500):
process(law)
// Async iterator — fetches the next page lazily.
for await (const law of client.laws.iter("es", { lawType: "ley_organica", perPage: 100 })) {
process(law);
}
// Stop after 500 matches.
for await (const law of client.laws.searchIter("es", "datos", { limit: 500 })) {
process(law);
}
iter := client.Laws().Iter(ctx, "es", &legalize.LawsListOptions{
LawType: []string{"ley_organica"},
PerPage: legalize.Int(100),
})
for {
law, ok, err := iter.Next(ctx)
if err != nil { return err }
if !ok { break }
process(law)
}
When you want the raw page
If you need the envelope itself — the total count for
a progress bar, or deterministic page numbers for
caching — call laws.list(country, page=N, per_page=M)
directly. Same with webhooks.deliveries(endpoint_id, page=N).
What's paginated. Only
laws.list and
laws.search. reforms.list returns a
bounded array for a single law (usually < 30). Webhook
deliveries are paginated but short-lived (default window 30 days).