Skip to content
Open Prescient AI
API concepts

How the after argument and the pageInfo object of the Prescient GraphQL API split a large result into pages of 5,000 rows.

The modeledMetrics and reportedMetrics queries return their rows in pages. One page has 5,000 rows at most, and you cannot change the page size. The channelNames and models queries return the full list in one response.

Each paged response has a PageInfo object with two fields.

  • hasNextPage tells you if there is one more page.
  • endCursor is the value that you send as the after argument to get that page.

Send the first request with no after argument. While hasNextPage is true, send the same query again with after set to the endCursor of the last response.

Query
query ReportedMetrics($after: BigInt) {
reportedMetrics(startDate: "2026-01-01", endDate: "2026-01-31", after: $after) {
data {
reportedDate
campaignId
spend
}
pageInfo {
endCursor
hasNextPage
}
}
}
Variables for the second page
{
"after": "5000"
}

The cursor in this example is an example. Use the value from your response.

  • Send the cursor as you received it. Do not build a cursor and do not change one.
  • Send the cursor as a string. A cursor can be a number that is too large for a JavaScript number, and a JSON parser can change such a number.
  • Keep each other argument the same from page to page. A cursor is for one query with one set of arguments.
  • Use a cursor only with the query that returned it. A modeledMetrics cursor does not work with reportedMetrics.

Stop when hasNextPage is false.

  • When a page has no rows, endCursor is null.
  • For reportedMetrics, hasNextPage is true each time a page is full. If the number of rows is an exact multiple of 5,000, the last request returns no rows and hasNextPage is false. Your code must accept an empty page.

The schema does not define the order of the rows, so do not rely on it. channelNames and models also have no defined order. Sort the rows in your own code if you need an order.