On List endpoints
Page through a collection with maxPageSize and nextPageToken.
Every list endpoint is paginated. One request returns at most one page, and the
response carries a nextPageToken you pass back as the pageToken query
parameter to fetch the next one.
Page size is set with maxPageSize. Each endpoint has its own default and
maximum:
| Endpoint | Default | Maximum |
|---|---|---|
GET /orders | 50 | 50 |
GET /couriers | 100 | 100 |
GET /pickupLocations | 100 | 100 |
A maxPageSize above the maximum is rejected with 400 Bad Request rather
than silently clamped.
Walking a whole collection looks like this:
- Request the first page. Orders come back newest first.
curl "https://api.spoke.com/connect/v1/orders?maxPageSize=50" \
-H "Authorization: Bearer <api-key>"- The response carries a cursor when more results exist:
{
"orders": [],
"nextPageToken": "MTc3ODUwODUwMnxXM2tKcHpRbTlxNExWMkJkSDdzTnVU"
}- Pass it as
pageToken, keeping every other query parameter identical to the first request:
curl "https://api.spoke.com/connect/v1/orders?maxPageSize=50&pageToken=MTc3ODUwODUwMnxXM2tKcHpRbTlxNExWMkJkSDdzTnVU" \
-H "Authorization: Bearer <api-key>"- Repeat until
nextPageTokencomes backnull. That is the only signal that the collection is exhausted.
A short page is not the last page. Every list endpoint filters its page
after reading it: GET /orders drops deleted and demo orders, and
GET /couriers drops connections whose courier no longer exists. A page can
therefore come back with fewer items than maxPageSize, or with none at all,
while nextPageToken is still set. Stop when nextPageToken is null, never
when a page looks short.
Tokens are opaque, and only the token a list endpoint handed you is meaningful
to it. Do not parse one, build one, or carry one across walks. GET /orders
rejects a malformed token with 400 Bad Request. The other list endpoints
resume from whatever position the token decodes to, so a hand-made one returns
the wrong slice rather than an error.
GET /orders also accepts an exact-match filter on the order's
packageInfo.externalId, written either as filter[externalId]= or
filter.externalId=. External ids are not unique-constrained, so a value you
have reused returns every order carrying it.
Was this page helpful?