Pagination in Axiom API
Learn how to paginate query results with the Axiom edge query API.
Use the edge APL query endpoint to retrieve events one page at a time. Axiom recommends timestamp-based pagination. Cursor-based pagination is in public preview and can distinguish events that share a timestamp.
Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to ingest data to the dataset you have created.
Timestamp-based pagination
Sort by _time and use limit to set the page size. For example, this request returns up to 100 events, newest first:
To fetch the next page, use the last event’s _time as the new boundary:
| Sort order | Change for the next request |
|---|---|
sort by _time desc | Set endTime to the last event’s timestamp. Keep startTime unchanged. |
sort by _time asc | Set startTime to the last event’s timestamp. Keep endTime unchanged. |
The boundary is inclusive. Deduplicate repeated events in your client. Moving the boundary by a nanosecond can skip events that share that timestamp. If a full page shares a timestamp, use a cursor to continue through those events.
Cursor-based pagination
Use a non-aggregated query with a single sort on _time, such as the query above. Keep the query, page size, and time range fixed across requests.
- Send the first request without a cursor.
- Read the boundary cursor from the response. For descending order, use
status.minCursor. For ascending order, usestatus.maxCursor. - Send the same request with that value in the JSON body’s
cursorfield. By default the next page excludes the boundary event. SetincludeCursortotrueif you want to repeat it. - Continue until a page contains fewer events than the requested page size.