Skip to navigation

Pagination and sorting

Pagination

Every list query (for example grants or disclosures) accepts page and limit arguments and returns a collection plus metadata.

query GrantsPage {
grants(page: 2, limit: 50) {
collection { id grantNumber }
metadata { currentPage totalPages totalCount hasNextPage nextPage }
}
}
  • page starts at 1. Omitting it, or passing 0, returns the first page.
  • limit defaults to 20. The maximum is 500, and larger values return 500 records.

To read every record, request page: 1, then keep requesting metadata.nextPage until hasNextPage is false.

Sorting

List queries accept sortField and sortDirection.

query DisclosuresByNumber {
disclosures(sortField: "disclosure_number", sortDirection: ASC) {
collection { id disclosureNumber title }
}
}
  • sortField takes a field name in snake_case. Each query supports its own set of fields, listed on the sortField argument in the API Reference. Any other value returns an error with extensions.status 400 and the list of allowed fields.
  • sortDirection is ASC or DESC.
  • Most queries default to created_at, newest first. contacts defaults to full_name A–Z, and organizations and products default to name A–Z.