Pagination
Every list endpoint returns one page at a time: data, the page’s items, and next_cursor, the key to the next page.
Paging through a list
Section titled “Paging through a list”- Send the request with the filters you want, and optionally
limit: 1 to 200 items, 50 by default. - Read
data. - If
next_cursoris a string, send the same request again withcursorset to it. If it’snull, that was the last page.
curl -H "Authorization: Bearer $MA_API_KEY" "$MA_API/v1/providers?limit=2"{ "data": [ {"slug": "amazon", "name": "Amazon", "country_of_origin": "US", "jurisdiction": "US"}, {"slug": "anthropic", "name": "Anthropic", "country_of_origin": "US", "jurisdiction": "US"} ], "next_cursor": "eyJhZnRlciI6ImFudGhyb3BpYyIsImYiOiJmNmI1YWE5NTMxNTgxZmZmIn0"}(From the listProviders example, trimmed.) The next page:
curl -H "Authorization: Bearer $MA_API_KEY" \ "$MA_API/v1/providers?limit=2&cursor=eyJhZnRlciI6ImFudGhyb3BpYyIsImYiOiJmNmI1YWE5NTMxNTgxZmZmIn0"Rules for cursors
Section titled “Rules for cursors”- Opaque. Pass it back unchanged. Don’t build or parse one.
- Tied to its request. A cursor belongs to the endpoint and the filters it came from. On catalog and event lists, a cursor sent with different filters is
400 invalid_parameter, as is a malformed one. You can changelimitbetween pages. - Not secret. It holds the last item’s position and a hash of the filters, nothing about your account.
| Endpoint | Order |
|---|---|
| Providers, platforms, models, versions, offerings | by slug |
/v1/availability |
by offering slug, then region |
/v1/events |
oldest first, by event ID |
| API keys, webhook endpoints, subscriptions, deliveries | newest first |
Catalog lists are read from one consistent snapshot per page. Data can change between pages (sources load during the day), so a long walk through a catalog list may see an entry change while you page.
Polling events with after
Section titled “Polling events with after”/v1/events is oldest first, and new events always sort after existing ones, so it can be replayed in order. Events written while you page come at the end, never in the middle.
On the last page next_cursor is null, so you can’t use it to wait for new events. Use after instead: pass the id of the last event you processed, and you get the events after it.
curl -H "Authorization: Bearer $MA_API_KEY" \ "$MA_API/v1/events?after=01KB5Z6T8QY0M7J3V2C9W4D1EN"Store the last id you processed, and poll with it. The Watch the models you use tutorial has a complete loop.
Limits on one request
Section titled “Limits on one request”| What | Limit |
|---|---|
limit |
1 to 200 (default 50). Outside that range is 400 invalid_parameter. |
models, slug |
up to 100 comma-separated entries |