Pagination
Cursor-based pagination: request parameters, response format, examples, and auto-pagination patterns.
Overview
List endpoints use cursor-based pagination for consistent, stable iteration over large result sets. Cursors are opaque tokens that encode position; they remain valid for a limited time. Use cursor and limit parameters to control pagination.
Request parameters
Pass cursor to fetch the next page (omit for the first page). Use limit to control page size (default and max vary by endpoint; typical default is 20, max 100). Cursors are returned in the previous response; do not construct or modify them.
Response format
Responses include data (array of items), has_more (boolean indicating more pages), and next_cursor (opaque token for the next request when has_more is true). When has_more is false, next_cursor may be absent.
Example
# First page
curl -H "Authorization: Bearer $API_KEY" \
"https://api.dmtr.ai/v1/positions?limit=20"
# Next page (use next_cursor from previous response)
curl -H "Authorization: Bearer $API_KEY" \
"https://api.dmtr.ai/v1/positions?limit=20&cursor=eyJpZCI6IjEyMyJ9"Auto-pagination patterns
To fetch all pages, loop: send request, append data to your collection, check has_more; if true, set cursor to next_cursor and repeat. Implement a maximum iteration count to avoid infinite loops. Handle rate limits and errors within the loop; consider resumable patterns for large exports.
# First page
curl -H "Authorization: Bearer $API_KEY" \
"https://api.dmtr.ai/v1/positions?limit=20"
# Next page (use next_cursor from response)
curl -H "Authorization: Bearer $API_KEY" \
"https://api.dmtr.ai/v1/positions?limit=20&cursor=eyJpZCI6IjEyMyJ9"