{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/en-US/apis/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["code-group"]},"type":"markdown"},"seo":{"title":"Pagination","description":"Documentação oficial da API da plataforma de crédito embarcado Dinie. Integre produtos de crédito diretamente na sua aplicação.","siteUrl":"https://docs.dinie.com","lang":"pt-BR","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"pagination","__idx":0},"children":["Pagination"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["All list endpoints use ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["forward-only, cursor-based pagination"]},". This approach is reliable for large volumes of data and handles concurrent inserts well -- unlike offset-based pagination, you will never see duplicate or missing records."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"how-it-works","__idx":1},"children":["How It Works"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every list response includes a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data"]}," array and a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["has_more"]}," boolean:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"data\": [\n    { \"id\": \"cust_aaa111\", \"name\": \"Alice\" },\n    { \"id\": \"cust_bbb222\", \"name\": \"Bob\" },\n    { \"id\": \"cust_ccc333\", \"name\": \"Carlos\" }\n  ],\n  \"has_more\": true\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["has_more"]}," is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},", pass the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}," of the last item"]}," as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["starting_after"]}," to fetch the next page."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"parameters","__idx":2},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter"},"children":["Parameter"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Default"},"children":["Default"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["starting_after"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["--"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Prefixed ID of the last item from the previous page. Returns items after this one."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["limit"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["25"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Number of items to return. Min: 1, Max: 100."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"basic-example","__idx":3},"children":["Basic Example"]},{"$$mdtype":"Tag","name":"CodeGroup","attributes":{"mode":"tabs"},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","data-title":"Node.js","header":{"title":"Node.js","controls":{"copy":{}}},"source":"let hasMore = true;\nlet startingAfter: string | undefined;\n\nwhile (hasMore) {\n  const page = await dinie.customers.list({\n    limit: 25,\n    starting_after: startingAfter,\n  });\n\n  for (const customer of page.data) {\n    console.log(customer.id, customer.name);\n  }\n\n  hasMore = page.has_more;\n  if (page.data.length > 0) {\n    startingAfter = page.data[page.data.length - 1].id;\n  }\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","data-title":"Ruby","header":{"title":"Ruby","controls":{"copy":{}}},"source":"has_more = true\nstarting_after = nil\n\nwhile has_more\n  page = dinie.customers.list(limit: 25, starting_after: starting_after)\n\n  page.data.each { |customer| puts \"#{customer.id} #{customer.name}\" }\n\n  has_more = page.has_more\n  starting_after = page.data.last&.id\nend\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","data-title":"Python","header":{"title":"Python","controls":{"copy":{}}},"source":"has_more = True\nstarting_after = None\n\nwhile has_more:\n    page = dinie.customers.list(limit=25, starting_after=starting_after)\n\n    for customer in page.data:\n        print(customer.id, customer.name)\n\n    has_more = page.has_more\n    if page.data:\n        starting_after = page.data[-1].id\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"cURL","header":{"title":"cURL","controls":{"copy":{}}},"source":"curl \"https://sandbox.api.dinie.com.br/v3/customers?limit=2\" \\\n  -H \"Authorization: Bearer dinie_at_...\"\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"data\": [\n    { \"id\": \"cust_aaa111\", \"name\": \"Alice\" },\n    { \"id\": \"cust_bbb222\", \"name\": \"Bob\" }\n  ],\n  \"has_more\": true\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Next page -- pass the last ID:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl \"https://sandbox.api.dinie.com.br/v3/customers?limit=2&starting_after=cust_bbb222\" \\\n  -H \"Authorization: Bearer dinie_at_...\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"data\": [\n    { \"id\": \"cust_ccc333\", \"name\": \"Carlos\" }\n  ],\n  \"has_more\": false\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"auto-pagination-with-sdks","__idx":4},"children":["Auto-Pagination with SDKs"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDKs provide auto-pagination iterators that manage the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["starting_after"]}," cursor for you. This is the recommended approach for iterating over all items in a collection."]},{"$$mdtype":"Tag","name":"CodeGroup","attributes":{"mode":"tabs"},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","data-title":"Node.js","header":{"title":"Node.js","controls":{"copy":{}}},"source":"for await (const customer of dinie.customers.list({ limit: 100 })) {\n  console.log(customer.id, customer.name);\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","data-title":"Ruby","header":{"title":"Ruby","controls":{"copy":{}}},"source":"dinie.customers.list(limit: 100).auto_paging_each do |customer|\n  puts \"#{customer.id} #{customer.name}\"\nend\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","data-title":"Python","header":{"title":"Python","controls":{"copy":{}}},"source":"for customer in dinie.customers.list(limit=100).auto_paging_iter():\n    print(customer.id, customer.name)\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tip:"]}," Auto-pagination makes sequential requests under the hood, fetching the next page only when you consume all items from the current page. Set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["limit: 100"]}," to minimize the number of HTTP requests."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"sorting","__idx":5},"children":["Sorting"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Some endpoints support sorting with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sort"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["order"]}," parameters:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl \"https://sandbox.api.dinie.com.br/v3/customers?sort=created_at&order=asc&limit=25\" \\\n  -H \"Authorization: Bearer dinie_at_...\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter"},"children":["Parameter"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Default"},"children":["Default"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Values"},"children":["Values"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sort"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["created_at"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Depends on the endpoint (see the endpoint documentation)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["order"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["desc"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["asc"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["desc"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pagination always traverses the current sort order. When you use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["starting_after"]},", the API returns items that come after the specified ID in the selected sort order."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"empty-results","__idx":6},"children":["Empty Results"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["An empty collection returns an empty ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data"]}," array:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"data\": [],\n  \"has_more\": false\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Info:"]}," Endpoints with naturally small collections (webhook endpoints, API credentials) still use the standard ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{ \"data\": [...], \"has_more\": false }"]}," envelope for consistency."]}]}]},"headings":[{"value":"Pagination","id":"pagination","depth":1},{"value":"How It Works","id":"how-it-works","depth":2},{"value":"Parameters","id":"parameters","depth":2},{"value":"Basic Example","id":"basic-example","depth":2},{"value":"Auto-Pagination with SDKs","id":"auto-pagination-with-sdks","depth":2},{"value":"Sorting","id":"sorting","depth":2},{"value":"Empty Results","id":"empty-results","depth":2}],"frontmatter":{"seo":{"title":"Pagination"}},"lastModified":"2026-03-15T13:30:00.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/en-us/apis/concepts/pagination","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}