To get the next page, send nextCursor back. When it comes back null, you have reached
the end.
Cursors are opaque. They are base64 of an internal keyset, and the contents are not a
contract — decoding one and constructing your own will break without warning. Pass back
exactly what you were given.
limit is clamped, not rejected
Valid range is 1–200, default 50. Out-of-range values are clamped rather than
refused, and the value actually applied comes back in page.limit. Read it there rather than
assuming you got what you asked for.
Search is a POST, and costs double
POST …/search carries filters in the body. It counts as two requests against your
rate limit, because it is the expensive one.Collection GETs — GET /bundles, GET /webhook-endpoints — are forward-only by design:
they return no estimatedTotal and no prevCursor. That is not a gap.
estimatedTotal is an estimate, and only search returns it. Don’t drive a “page N of M”
control off it; drive paging off nextCursor.
Sorting
Prefix a field with - for descending, bare for ascending.
In a search body: a sort array.
On a GET: comma-joined — ?sort=-listingDate,price
Sortable fields are per-endpoint. An unsupported field is a 400 rather than being
ignored, so you find out immediately.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"InStockRx API","description":"Partner API for the InStockRx pharmacy marketplace.","colors":{"primary":"#EA6318","light":"#F58A4B","dark":"#B54B12"},"logo":{"light":"/logo/light.svg","dark":"/logo/dark.svg","href":"https://www.instockrx.com"},"favicon":"/favicon.svg","api":{"playground":{"display":"interactive"},"examples":{"languages":["bash","javascript","python"]}},"navbar":{"links":[{"href":"mailto:info@instockrx.com","label":"Support"}],"primary":{"type":"button","label":"Get sandbox access","href":"https://sandbox.instockrx.com"}},"footer":{"socials":{"website":"https://www.instockrx.com"}},"integrations":{"telemetry":{"enabled":false}},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"hasAudioNarration":false,"customDomains":[],"gitSource":{"type":"github","owner":"local","repo":"local","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":"local","isBase":true},"buildId":"local","clientVersion":"0.0.4342"},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[],"googleFontsInlined":false,"isLoggedInCli":false,"mintExport":{}},"customCss":[]}
{"page":{"pagePath":"v2/guides/pagination","slug":"/v2/guides/pagination","pageMetadata":{"title":"Searching and paging","description":"Opaque cursors, why search is a POST, and how sorting works.","href":"/v2/guides/pagination"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Opaque cursors, why search is a POST, and how sorting works.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`v2 has no offset paging anywhere. Every list is cursor-paged, and rich filtering goes in a\n`,_jsx(_components.code,{children:`POST …/search`}),` body rather than a long query string.`]}),`\n`,_jsx(Heading,{level:`2`,id:`cursors`,children:`Cursors`}),`\n`,_jsxs(_components.p,{children:[`A page response carries a `,_jsx(_components.code,{children:`page`}),` object:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`9`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`9`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [ `}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:`…`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"page\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"limit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`50`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"nextCursor\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"eyJsaXN0aW5nRGF0ZSI6IjIwMjYtMTAtMDEi…\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"prevCursor\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"estimatedTotal\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`412`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`To get the next page, send `,_jsx(_components.code,{children:`nextCursor`}),` back. When it comes back `,_jsx(_components.code,{children:`null`}),`, you have reached\nthe end.`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Cursors are opaque.`}),` They are base64 of an internal keyset, and the contents are not a\ncontract — decoding one and constructing your own will break without warning. Pass back\nexactly what you were given.`]})}),`\n`,_jsxs(Heading,{level:`2`,id:`limit-is-clamped-not-rejected`,children:[_jsx(_components.code,{children:`limit`}),` is clamped, not rejected`]}),`\n`,_jsxs(_components.p,{children:[`Valid range is `,_jsx(_components.strong,{children:`1–200`}),`, default `,_jsx(_components.strong,{children:`50`}),`. Out-of-range values are clamped rather than\nrefused, and the value actually applied comes back in `,_jsx(_components.code,{children:`page.limit`}),`. Read it there rather than\nassuming you got what you asked for.`]}),`\n`,_jsx(Heading,{level:`2`,id:`search-is-a-post-and-costs-double`,children:`Search is a POST, and costs double`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`POST …/search`}),` carries filters in the body. It counts as `,_jsx(_components.strong,{children:`two requests`}),` against your\n`,_jsx(_components.a,{href:`/v2/reference/rate-limits`,children:`rate limit`}),`, because it is the expensive one.`]}),`\n`,_jsxs(_components.p,{children:[`Collection `,_jsx(_components.code,{children:`GET`}),`s — `,_jsx(_components.code,{children:`GET /bundles`}),`, `,_jsx(_components.code,{children:`GET /webhook-endpoints`}),` — are forward-only by design:\nthey return no `,_jsx(_components.code,{children:`estimatedTotal`}),` and no `,_jsx(_components.code,{children:`prevCursor`}),`. That is not a gap.`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`estimatedTotal`}),` is an estimate, and only search returns it. Don’t drive a “page N of M”\ncontrol off it; drive paging off `,_jsx(_components.code,{children:`nextCursor`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`sorting`,children:`Sorting`}),`\n`,_jsxs(_components.p,{children:[`Prefix a field with `,_jsx(_components.code,{children:`-`}),` for descending, bare for ascending.`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`In a search body: a `,_jsx(_components.code,{children:`sort`}),` array.`]}),`\n`,_jsxs(_components.li,{children:[`On a `,_jsx(_components.code,{children:`GET`}),`: comma-joined — `,_jsx(_components.code,{children:`?sort=-listingDate,price`})]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Sortable fields are per-endpoint.`}),` An unsupported field is a `,_jsx(_components.code,{children:`400`}),` rather than being\nignored, so you find out immediately.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Searching and paging","description":"Opaque cursors, why search is a POST, and how sorting works.","href":"/v2/guides/pagination"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Cursors","slug":"cursors","depth":2,"children":[]},{"title":"limit is clamped, not rejected","slug":"limit-is-clamped-not-rejected","depth":2,"children":[]},{"title":"Search is a POST, and costs double","slug":"search-is-a-post-and-costs-double","depth":2,"children":[]},{"title":"Sorting","slug":"sorting","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"localhost","siteName":"InStockRx API","title":"Searching and paging - InStockRx API","navMaps":{"firstHrefInVersion":{"v2":{"href":"/v2/guides/pagination","matchLevel":0},"v1":{"href":"/guides/authentication","matchLevel":2}},"firstHrefInLanguage":{}},"originalFileLocation":"v2/guides/pagination.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Opaque cursors, why search is a POST, and how sorting works.\">\u003cmeta data-mint-head name=\"application-name\" content=\"InStockRx API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/favicons/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/favicons/favicon-32x32.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/favicons/favicon-16x16.png\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicons/favicon.ico\">\u003cmeta data-mint-head property=\"og:title\" content=\"Searching and paging - InStockRx API\">\u003cmeta data-mint-head property=\"og:description\" content=\"Opaque cursors, why search is a POST, and how sorting works.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"InStockRx API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://local./v2/guides/pagination\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Searching and paging - InStockRx API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Opaque cursors, why search is a POST, and how sorting works.\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/favicons/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"InStockRx API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#EA6318\">\u003clink data-mint-head rel=\"canonical\" href=\"https://local./v2/guides/pagination\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/v2/guides/pagination.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"InStockRx API\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"InStockRx API\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/v2/guides/pagination.md","siteName":"InStockRx API","nav":{"versions":[{"version":"v2","tabs":[{"tab":"Documentation","groups":[{"group":"Get started","pages":[{"title":"InStockRx API v2","href":"/v2/introduction"},{"title":"Sandbox onboarding","href":"/v2/sandbox"},{"title":"Production access","href":"/v2/production-access"},{"title":"Quickstart","href":"/v2/quickstart"}]},{"group":"Guides","pages":[{"title":"Authentication","href":"/v2/guides/authentication"},{"title":"Environments","description":"Sandbox and production, and what differs between them.","href":"/v2/guides/environments"},{"title":"Searching and paging","href":"/v2/guides/pagination"},{"title":"Concurrent updates","description":"ETags, If-Match, and how to avoid overwriting someone else's change.","href":"/v2/guides/concurrency"},{"title":"Safe retries","href":"/v2/guides/idempotency"},{"title":"Webhooks","href":"/v2/guides/webhooks"},{"title":"Migrating from v1","href":"/v2/guides/migrating-from-v1"}]},{"group":"Reference","pages":[{"title":"Scopes","href":"/v2/reference/scopes"},{"title":"Errors","href":"/v2/reference/errors"},{"title":"Rate limits","href":"/v2/reference/rate-limits"},{"title":"What v2 can't do yet","href":"/v2/reference/limitations"}]}]},{"tab":"API reference","pages":[{"title":"API reference","href":"/v2/api-reference/overview"}]}]},{"version":"v1","pages":[{"title":"v1","href":"/guides/authentication"}]}]},"basePath":"","title":"Searching and paging - InStockRx API","buildId":"b8b92e8dc392","dynamics":[],"chunks":[]}