Skip to main content
View as Markdown

Pagination

Lists in the Octopart API are paged in one of two ways. The arguments of an operation tell you which one it uses.

Offset paging​

Part search, part family search and reference design search take start (the offset of the first result) and limit (the page size), and return the total number of matches in hits:

query SecondPage {
supSearch(q: "buck converter", start: 10, limit: 10) {
hits
results {
part {
mpn
manufacturer {
name
}
}
}
}
}

Request the next page by adding limit to start until start reaches hits.

Operations that page this way include supSearch, supSearchMpn, supPartFamilySearch, supRefDesigns, supSolutionTemplates, supEvalKits and supSoftwareProjects.

Cursor paging​

The …Search operations of solution templates, evaluation kits and software projects return Relay connections. They take first and after (or last and before), and return nodes (or edges), pageInfo and totalCount:

query SolutionTemplates($after: String) {
supSolutionTemplateSearch(first: 20, after: $after) {
totalCount
nodes {
id
title
}
pageInfo {
hasNextPage
endCursor
}
}
}

Pass pageInfo.endCursor as after to get the next page while pageInfo.hasNextPage is true.

Operations that page this way: supSolutionTemplateSearch, supSolutionTemplateApplicationsSearch, supEvalKitSearch, supSoftwareProjectSearch and supSoftwareProjectEvalKitCompatibleSoftwareProjectSearch.

The Developer Center has more on paging through search results.


Comments​