On List endpoints
When using list endpoints, you have the ability to combine various query options to locate the desired results. Some endpoints even offer specific filter options to aid in this search.
All the list endpoints employ pagination. This means that a single request might
only return a part of the entire set of resources you're aiming to retrieve. To
move through the subsequent pages, the Spoke API provides a nextPageToken
field in the response of every list endpoint query.
It's crucial to understand that when a nextPageToken is returned, it indicates
that more data is available. For every subsequent request, this token should be
added as the pageToken query parameter. And, importantly, all the original
query parameters used in the first request must also be included.
Here's a step-by-step example to elucidate this:
- Suppose you initiate a request to list your plans:
curl "https://api.spoke.com/public/v0.2b/plans?filter.startsGte=2023-05-01" -u yourApiKey:- The Spoke API might return a response like:
{
// other attributes
"nextPageToken": "I53Jr5Eu2qK9omh0iA8q"
}- To retrieve the next page of data, use the returned
nextPageTokenas thepageTokenquery parameter, and ensure all initial query parameters remain the same:
curl "https://api.spoke.com/public/v0.2b/plans?filter.startsGte=2023-05-01&pageToken=I53Jr5Eu2qK9omh0iA8q" -u yourApiKey:- Repeat step 3 for all subsequent pages, updating the
pageTokenparameter with the latestnextPageTokenvalue returned untilnextPageTokenisnullin the response.
Spoke also accepts limiting the maximum number of results per page by using
the maxPageSize query parameter, but notice that each individual endpoint has
a maximum value you can set this to.