{"templateId":"markdown","sharedDataIds":{},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Pagination","description":"Sprinklr offers robust, convenient, and simple RESTful Web service APIs to integrate data from Sprinklr to any external system.","keywords":["Sprinklr API","Sprinklr Developer Portal","OAuth 2.0","RESTful API","Social Media API","Customer Experience API","Unified-CXM","Social Listening API"]},"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":["When you're working with lists of resources in the Sprinklr API—cases, messages, accounts, profiles—you'll often encounter datasets too large to return in a single response. Pagination breaks these large datasets into manageable chunks, making your integration faster, more memory-efficient, and more user-friendly."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"why-pagination-matters","__idx":1},"children":["Why pagination matters"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Imagine requesting all customer service cases from a large enterprise. They might have tens of thousands of cases. If the API tried to return all of them at once:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["The response would be massive"]}," - Several megabytes of JSON data"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["The request would be slow"]}," - Could take 10-30 seconds or timeout entirely"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Your application would struggle"]}," - Parsing and processing that much data at once consumes memory"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["The user would wait"]}," - No results until everything loads"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pagination solves all of these problems by breaking the data into smaller \"pages\" that you can fetch and process one at a time—or in parallel if you need speed."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Think of pagination like reading a book. You don't need to read all 300 pages at once to start understanding the story. You read one page, then the next, progressively building your understanding. API pagination works the same way."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"how-sprinklr-api-pagination-works","__idx":2},"children":["How Sprinklr API pagination works"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Sprinklr API uses ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["offset-based pagination"]}," (also called \"page number pagination\"). This is the most common and straightforward pagination approach."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Here's how it works:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You specify which ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["page number"]}," you want (starting from 0)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You specify how many items per ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["page"]}," (the page size)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The API returns that page of results plus metadata telling you about the overall dataset"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Dataset: 150 cases total\nYour request: page=0, size=20\n\nAPI returns:\n- Items 1-20 (first page)\n- Metadata: \"You're on page 0 of 8 pages, 150 total items\"\n\nNext request: page=1, size=20\n- Items 21-40 (second page)\n- Metadata: \"You're on page 1 of 8 pages, 150 total items\"\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"pagination-parameters","__idx":3},"children":["Pagination parameters"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every paginated endpoint accepts these query 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":"Range/Constraints"},"children":["Range/Constraints"]},{"$$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":["page"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0 to totalPages-1"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Page number (0-indexed, first page is 0)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["size"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["20"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["1 to 100"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Number of items per page"]}]},{"$$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":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["varies"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["field,direction"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Sort field and direction (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["asc"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["desc"]},")"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"making-a-paginated-request","__idx":4},"children":["Making a paginated request"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node.js:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const fetch = require('node-fetch');\n\nasync function getCases(page = 0, size = 20, sort = 'createdTime,desc') {\n  const url = new URL('https://api-v3.sprinklr.com/api/v3/case/search');\n  url.searchParams.append('page', page);\n  url.searchParams.append('size', size);\n  url.searchParams.append('sort', sort);\n\n  const response = await fetch(url, {\n    method: 'POST',\n    headers: {\n      'Authorization': `Bearer ${accessToken}`,\n      'Key': apiKey,\n      'Content-Type': 'application/json'\n    },\n    body: JSON.stringify({\n      status: 'OPEN'\n    })\n  });\n\n  return response.json();\n}\n\n// Get first page (20 cases)\nconst firstPage = await getCases(0, 20);\nconsole.log(`Loaded ${firstPage.data.length} cases`);\nconsole.log(`Total: ${firstPage.pagination.totalElements} cases across ${firstPage.pagination.totalPages} pages`);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\nfrom urllib.parse import urlencode\n\ndef get_cases(page=0, size=20, sort='createdTime,desc'):\n    params = {\n        'page': page,\n        'size': size,\n        'sort': sort\n    }\n\n    response = requests.post(\n        f'https://api-v3.sprinklr.com/api/v3/case/search?{urlencode(params)}',\n        headers={\n            'Authorization': f'Bearer {access_token}',\n            'Key': api_key,\n            'Content-Type': 'application/json'\n        },\n        json={'status': 'OPEN'}\n    )\n\n    return response.json()\n\n# Get first page (20 cases)\nfirst_page = get_cases(0, 20)\nprint(f\"Loaded {len(first_page['data'])} cases\")\nprint(f\"Total: {first_page['pagination']['totalElements']} cases across {first_page['pagination']['totalPages']} pages\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["PHP:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\nfunction getCases($page = 0, $size = 20, $sort = 'createdTime,desc') {\n    global $accessToken, $apiKey;\n\n    $url = 'https://api-v3.sprinklr.com/api/v3/case/search?' .\n           http_build_query([\n               'page' => $page,\n               'size' => $size,\n               'sort' => $sort\n           ]);\n\n    $ch = curl_init($url);\n    curl_setopt($ch, CURLOPT_POST, true);\n    curl_setopt($ch, CURLOPT_HTTPHEADER, [\n        'Authorization: Bearer ' . $accessToken,\n        'Key: ' . $apiKey,\n        'Content-Type: application/json'\n    ]);\n    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['status' => 'OPEN']));\n    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n\n    $response = curl_exec($ch);\n    curl_close($ch);\n\n    return json_decode($response, true);\n}\n\n// Get first page (20 cases)\n$firstPage = getCases(0, 20);\necho \"Loaded \" . count($firstPage['data']) . \" cases\\n\";\necho \"Total: \" . $firstPage['pagination']['totalElements'] . \" cases across \" .\n     $firstPage['pagination']['totalPages'] . \" pages\\n\";\n?>\n","lang":"php"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Java:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"import java.net.http.*;\nimport java.net.URI;\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport java.util.Map;\n\npublic class PaginationExample {\n    private static final ObjectMapper mapper = new ObjectMapper();\n\n    public static Map<String, Object> getCases(int page, int size, String sort)\n            throws Exception {\n        String url = String.format(\n            \"https://api-v3.sprinklr.com/api/v3/case/search?page=%d&size=%d&sort=%s\",\n            page, size, sort\n        );\n\n        String requestBody = mapper.writeValueAsString(\n            Map.of(\"status\", \"OPEN\")\n        );\n\n        HttpClient client = HttpClient.newHttpClient();\n        HttpRequest request = HttpRequest.newBuilder()\n            .uri(URI.create(url))\n            .header(\"Authorization\", \"Bearer \" + accessToken)\n            .header(\"Key\", apiKey)\n            .header(\"Content-Type\", \"application/json\")\n            .POST(HttpRequest.BodyPublishers.ofString(requestBody))\n            .build();\n\n        HttpResponse<String> response = client.send(request,\n            HttpResponse.BodyHandlers.ofString());\n\n        return mapper.readValue(response.body(), Map.class);\n    }\n\n    public static void main(String[] args) throws Exception {\n        // Get first page (20 cases)\n        Map<String, Object> firstPage = getCases(0, 20, \"createdTime,desc\");\n        List<Map> data = (List<Map>) firstPage.get(\"data\");\n        Map<String, Object> pagination = (Map<String, Object>) firstPage.get(\"pagination\");\n\n        System.out.println(\"Loaded \" + data.size() + \" cases\");\n        System.out.println(\"Total: \" + pagination.get(\"totalElements\") +\n                          \" cases across \" + pagination.get(\"totalPages\") + \" pages\");\n    }\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"understanding-the-pagination-response","__idx":5},"children":["Understanding the pagination response"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every paginated response includes both your data and a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pagination"]}," object with metadata:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"success\": true,\n  \"data\": [\n    {\n      \"caseId\": \"CASE-12345\",\n      \"subject\": \"Customer inquiry about refund\",\n      \"status\": \"OPEN\",\n      \"createdTime\": \"2024-03-01T10:30:00Z\"\n    },\n    {\n      \"caseId\": \"CASE-12346\",\n      \"subject\": \"Product delivery delayed\",\n      \"status\": \"OPEN\",\n      \"createdTime\": \"2024-03-01T10:25:00Z\"\n    }\n    // ... 18 more cases\n  ],\n  \"pagination\": {\n    \"page\": 0,\n    \"size\": 20,\n    \"totalElements\": 157,\n    \"totalPages\": 8,\n    \"first\": true,\n    \"last\": false\n  }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"pagination-metadata-fields","__idx":6},"children":["Pagination metadata fields"]},{"$$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":"Field"},"children":["Field"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Example"},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["page"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Current page number (0-indexed)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0"]}," (first page)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["size"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Items per page"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["20"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["totalElements"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Total number of items across ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["all pages"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["157"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["totalPages"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Total number of pages"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["8"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["first"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["boolean"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," if this is the first page"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," on page 0"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["last"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["boolean"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," if this is the last page"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," on page 7 (for 8 pages)"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Using this metadata:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const response = await getCases(0, 20);\nconst { data, pagination } = response;\n\n// Check if there are more pages\nif (!pagination.last) {\n  console.log('There are more pages to fetch');\n  const nextPage = await getCases(pagination.page + 1, pagination.size);\n}\n\n// Calculate how many items are on this page\nconst itemsOnThisPage = data.length;\n\n// Calculate range of items being displayed\nconst startItem = pagination.page * pagination.size + 1;\nconst endItem = startItem + itemsOnThisPage - 1;\nconsole.log(`Showing items ${startItem}-${endItem} of ${pagination.totalElements}`);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"sorting-paginated-results","__idx":7},"children":["Sorting paginated results"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sort"]}," parameter to control the order of results. This is crucial for pagination because the sort order determines which items appear on which pages."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"sort-syntax","__idx":8},"children":["Sort syntax"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Format: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["field,direction"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["field"]},": The property name to sort by"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["direction"]},": ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["asc"]}," (ascending, A→Z, 0→9, oldest→newest) or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["desc"]}," (descending, Z→A, 9→0, newest→oldest)"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"common-sort-fields","__idx":9},"children":["Common sort fields"]},{"$$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":"Field"},"children":["Field"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Example Values"},"children":["Example 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":["createdTime"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["When the item was created"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["createdTime,desc"]}," (newest first)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["modifiedTime"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["When the item was last updated"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["modifiedTime,desc"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["name"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Alphabetical by name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["name,asc"]}," (A to Z)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["By status (alphabetical)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status,asc"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["priority"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["By priority level"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["priority,desc"]}," (high to low)"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"sort-examples","__idx":10},"children":["Sort examples"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Get newest cases first:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const newestFirst = await getCases(0, 20, 'createdTime,desc');\n// Returns: March 15, March 14, March 13, ...\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Get cases alphabetically by subject:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const alphabetical = await getCases(0, 20, 'subject,asc');\n// Returns: \"Account issue\", \"Billing question\", \"Complaint\", ...\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Get recently updated cases:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const recentlyUpdated = await getCases(0, 20, 'modifiedTime,desc');\n// Returns cases sorted by last modification time\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Important:"]}," Always use the same sort order when fetching multiple pages. If you change the sort order between requests, items might appear on multiple pages or be skipped entirely."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"common-pagination-patterns","__idx":11},"children":["Common pagination patterns"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"pattern-1-fetch-all-pages-sequentially","__idx":12},"children":["Pattern 1: Fetch all pages sequentially"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The most common pattern—fetch pages one at a time until you've got everything."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node.js:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function getAllCases() {\n  const allCases = [];\n  let page = 0;\n  let hasMore = true;\n\n  while (hasMore) {\n    const response = await getCases(page, 50); // 50 items per page\n\n    // Add this page's cases to our collection\n    allCases.push(...response.data);\n\n    // Check if there are more pages\n    hasMore = !response.pagination.last;\n    page++;\n\n    console.log(`Fetched page ${page}, total cases so far: ${allCases.length}`);\n  }\n\n  console.log(`Complete! Fetched ${allCases.length} cases across ${page} pages`);\n  return allCases;\n}\n\n// Usage\nconst allCases = await getAllCases();\n// Processes all cases: page 1, page 2, page 3, ... until done\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"def get_all_cases():\n    all_cases = []\n    page = 0\n    has_more = True\n\n    while has_more:\n        response = get_cases(page, 50)  # 50 items per page\n\n        # Add this page's cases\n        all_cases.extend(response['data'])\n\n        # Check if there are more pages\n        has_more = not response['pagination']['last']\n        page += 1\n\n        print(f\"Fetched page {page}, total cases so far: {len(all_cases)}\")\n\n    print(f\"Complete! Fetched {len(all_cases)} cases across {page} pages\")\n    return all_cases\n\n# Usage\nall_cases = get_all_cases()\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["When to use this:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You need all the data for analysis or reporting"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You're doing a one-time data export"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The total dataset is manageable (under 10,000 items)"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["When NOT to use this:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Very large datasets (100,000+ items) - consider streaming instead"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Real-time UI displays - use progressive loading instead"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Rate limit concerns - fetch only what you need"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"pattern-2-process-pages-progressively","__idx":13},"children":["Pattern 2: Process pages progressively"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Instead of loading everything into memory, process each page as you fetch it."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node.js:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function processAllCases(processFn) {\n  let page = 0;\n  let hasMore = true;\n  let totalProcessed = 0;\n\n  while (hasMore) {\n    const response = await getCases(page, 50);\n\n    // Process this page immediately\n    for (const case of response.data) {\n      await processFn(case);\n      totalProcessed++;\n    }\n\n    hasMore = !response.pagination.last;\n    page++;\n\n    console.log(`Processed page ${page}, ${totalProcessed} cases total`);\n  }\n\n  return totalProcessed;\n}\n\n// Usage - process each case as we fetch it\nconst processed = await processAllCases(async (caseItem) => {\n  // Do something with each case\n  await updateDatabase(caseItem);\n  await sendToQueue(caseItem);\n});\n\nconsole.log(`Processed ${processed} cases`);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"def process_all_cases(process_fn):\n    page = 0\n    has_more = True\n    total_processed = 0\n\n    while has_more:\n        response = get_cases(page, 50)\n\n        # Process this page immediately\n        for case in response['data']:\n            process_fn(case)\n            total_processed += 1\n\n        has_more = not response['pagination']['last']\n        page += 1\n\n        print(f\"Processed page {page}, {total_processed} cases total\")\n\n    return total_processed\n\n# Usage\ndef handle_case(case):\n    # Do something with each case\n    update_database(case)\n    send_to_queue(case)\n\nprocessed = process_all_cases(handle_case)\nprint(f\"Processed {processed} cases\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Benefits:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Memory efficient"]}," - Never holds entire dataset in memory"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Faster time-to-first-result"]}," - Start processing immediately"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Better for large datasets"]}," - Can handle millions of records"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Easier error recovery"]}," - If it fails on page 42, you've already processed pages 1-41"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"pattern-3-fetch-a-specific-page","__idx":14},"children":["Pattern 3: Fetch a specific page"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Sometimes you just need one page—like for a UI with page navigation."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node.js:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function getCasesForDisplay(pageNumber = 0, pageSize = 20) {\n  const response = await getCases(pageNumber, pageSize);\n\n  return {\n    cases: response.data,\n    pagination: {\n      currentPage: response.pagination.page + 1, // Convert to 1-indexed for display\n      totalPages: response.pagination.totalPages,\n      totalItems: response.pagination.totalElements,\n      hasNext: !response.pagination.last,\n      hasPrevious: !response.pagination.first\n    }\n  };\n}\n\n// Usage in a UI\nconst displayData = await getCasesForDisplay(2, 20); // Page 3 (0-indexed: 2)\n\nconsole.log(`Page ${displayData.pagination.currentPage} of ${displayData.pagination.totalPages}`);\nconsole.log(`Showing ${displayData.cases.length} cases`);\n\nif (displayData.pagination.hasNext) {\n  console.log('Next button enabled');\n}\nif (displayData.pagination.hasPrevious) {\n  console.log('Previous button enabled');\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"pattern-4-parallel-page-fetching","__idx":15},"children":["Pattern 4: Parallel page fetching"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Fetch multiple pages at once for faster data retrieval."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node.js:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function getPageRange(startPage, endPage, pageSize = 20) {\n  // Create array of page numbers: [0, 1, 2, 3, 4]\n  const pages = Array.from(\n    { length: endPage - startPage + 1 },\n    (_, i) => startPage + i\n  );\n\n  // Fetch all pages in parallel\n  const responses = await Promise.all(\n    pages.map(page => getCases(page, pageSize))\n  );\n\n  // Combine all results\n  const allCases = responses.flatMap(response => response.data);\n\n  return allCases;\n}\n\n// Usage - fetch pages 0-4 in parallel (5 pages = 100 cases if size=20)\nconst cases = await getPageRange(0, 4, 20);\nconsole.log(`Fetched ${cases.length} cases in parallel`);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["⚠️ Important considerations:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Rate limits"]},": Parallel requests count against your rate limit. Don't fetch 100 pages at once."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Memory"]},": All pages load into memory simultaneously"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Order"]},": Results come back in any order—sort after fetching if order matters"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Good practice:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// Fetch 5 pages in parallel (reasonable)\nconst batch1 = await getPageRange(0, 4, 20);\n\n// Wait a moment, then fetch next batch\nawait new Promise(resolve => setTimeout(resolve, 1000));\nconst batch2 = await getPageRange(5, 9, 20);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"pattern-5-infinite-scroll--lazy-loading","__idx":16},"children":["Pattern 5: Infinite scroll / lazy loading"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Load pages as the user scrolls or requests more data."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node.js class for infinite scroll:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"class InfiniteScroll {\n  constructor(fetchFn, pageSize = 20) {\n    this.fetchFn = fetchFn;\n    this.pageSize = pageSize;\n    this.currentPage = 0;\n    this.allItems = [];\n    this.hasMore = true;\n    this.loading = false;\n    this.totalItems = 0;\n  }\n\n  async loadMore() {\n    // Prevent multiple simultaneous loads\n    if (this.loading || !this.hasMore) {\n      return [];\n    }\n\n    this.loading = true;\n\n    try {\n      const response = await this.fetchFn(this.currentPage, this.pageSize);\n\n      // Add new items\n      this.allItems.push(...response.data);\n\n      // Update state\n      this.hasMore = !response.pagination.last;\n      this.totalItems = response.pagination.totalElements;\n      this.currentPage++;\n\n      console.log(`Loaded page ${this.currentPage}, showing ${this.allItems.length} of ${this.totalItems} total`);\n\n      return response.data; // Return just the new items\n    } finally {\n      this.loading = false;\n    }\n  }\n\n  getAllItems() {\n    return this.allItems;\n  }\n\n  reset() {\n    this.currentPage = 0;\n    this.allItems = [];\n    this.hasMore = true;\n    this.totalItems = 0;\n  }\n}\n\n// Usage in a web app\nconst scroll = new InfiniteScroll(getCases, 20);\n\n// Initial load\nconst firstBatch = await scroll.loadMore();\ndisplayCases(firstBatch);\n\n// User scrolls down\ndocument.addEventListener('scroll', async () => {\n  const scrolledToBottom =\n    window.innerHeight + window.scrollY >= document.body.offsetHeight - 100;\n\n  if (scrolledToBottom && !scroll.loading) {\n    const newItems = await scroll.loadMore();\n    appendCases(newItems);\n  }\n});\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"choosing-the-right-page-size","__idx":17},"children":["Choosing the right page size"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Page size affects performance, memory usage, and user experience."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"page-size-trade-offs","__idx":18},"children":["Page size trade-offs"]},{"$$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":"Page Size"},"children":["Page Size"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Pros"},"children":["Pros"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Cons"},"children":["Cons"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Best For"},"children":["Best For"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Small (10-20)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["- Fast response times",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- Low memory usage",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- Quick time-to-first-render"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["- More API requests",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- More overhead",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- Higher rate limit usage"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["UI pagination, mobile apps"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Medium (20-50)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["- Balanced performance",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- Reasonable memory",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- Fewer requests"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["- Slightly slower responses"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Most use cases, dashboards"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Large (50-100)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["- Fewer requests",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- Lower rate limit usage",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- Efficient for batch processing"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["- Slower responses",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- More memory usage",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"- Longer wait for first result"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Batch processing, exports"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"recommended-page-sizes-by-use-case","__idx":19},"children":["Recommended page sizes by use case"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// UI pagination (user clicking through pages)\nconst uiCases = await getCases(page, 20);\n\n// Infinite scroll (loading as user scrolls)\nconst scrollCases = await getCases(page, 30);\n\n// Background processing (analyzing all cases)\nconst batchCases = await getCases(page, 100);\n\n// Mobile app (limited bandwidth)\nconst mobileCases = await getCases(page, 15);\n\n// Real-time dashboard (frequent updates)\nconst dashboardCases = await getCases(page, 25);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Performance comparison:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Fetching 1,000 cases:\n\nPage size 10:  100 requests, ~30 seconds\nPage size 20:   50 requests, ~15 seconds ✅ Good for UI\nPage size 50:   20 requests,  ~6 seconds ✅ Good for batch\nPage size 100:  10 requests,  ~4 seconds ✅ Fastest, but largest responses\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"handling-edge-cases","__idx":20},"children":["Handling edge cases"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"empty-results","__idx":21},"children":["Empty results"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Always check if a page has any data:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function getCasesWithEmptyCheck(page, size) {\n  const response = await getCases(page, size);\n\n  if (!response.data || response.data.length === 0) {\n    if (page === 0) {\n      console.log('No cases found at all');\n    } else {\n      console.log('Reached end of results');\n    }\n    return { isEmpty: true, data: [] };\n  }\n\n  return { isEmpty: false, data: response.data };\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"page-out-of-range","__idx":22},"children":["Page out of range"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Handle requests for pages that don't exist:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function getSafePage(page, size) {\n  const response = await getCases(page, size);\n\n  // Check if requested page is beyond available pages\n  if (page >= response.pagination.totalPages) {\n    console.warn(`Requested page ${page} but only ${response.pagination.totalPages} pages exist`);\n    // Return last valid page instead\n    return getCases(response.pagination.totalPages - 1, size);\n  }\n\n  return response;\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"data-changes-during-pagination","__idx":23},"children":["Data changes during pagination"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The dataset might change while you're fetching pages:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Problem:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// Fetch page 0 at 10:00 AM - 50 cases returned\nconst page1 = await getCases(0, 50);\n\n// New cases are created at 10:01 AM\n\n// Fetch page 1 at 10:02 AM - you might skip or duplicate items!\nconst page2 = await getCases(1, 50);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Solutions:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use timestamps to filter:"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const startTime = new Date().toISOString();\n\n// All requests use the same timestamp filter\nconst page1 = await getCases(0, 50, { createdBefore: startTime });\nconst page2 = await getCases(1, 50, { createdBefore: startTime });\n// This ensures a consistent snapshot of data\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":2},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use cursor-based pagination for real-time data"]}," (covered in advanced section)"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Fetch quickly to minimize window for changes:"]}]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// Fetch pages rapidly in parallel\nconst pages = await Promise.all([\n  getCases(0, 50),\n  getCases(1, 50),\n  getCases(2, 50)\n]);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"advanced-cursor-based-pagination","__idx":24},"children":["Advanced: Cursor-based pagination"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For datasets that change frequently, cursor-based pagination is more reliable than offset-based."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"how-cursor-pagination-works","__idx":25},"children":["How cursor pagination works"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Instead of page numbers, you use a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["cursor"]}," (a pointer to a specific item). The API returns the next cursor with each response."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Request 1: GET /cases?size=20\nResponse:  Items 1-20, nextCursor=\"abc123\"\n\nRequest 2: GET /cases?size=20&cursor=abc123\nResponse:  Items 21-40, nextCursor=\"def456\"\n\nRequest 3: GET /cases?size=20&cursor=def456\nResponse:  Items 41-60, nextCursor=\"ghi789\"\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Benefits over offset pagination:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["No duplicate items"]}," even if data changes during pagination"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["No skipped items"]}," even if items are added/deleted"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["More efficient"]}," for databases to process"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Drawbacks:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Can't jump to arbitrary pages"]}," (no \"go to page 5\")"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Can't calculate total pages upfront"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"implementing-cursor-pagination","__idx":26},"children":["Implementing cursor pagination"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function iterateWithCursor(fetchFn, pageSize = 50) {\n  let cursor = null;\n  const allItems = [];\n\n  do {\n    const result = await fetchFn(cursor, pageSize);\n\n    allItems.push(...result.items);\n    cursor = result.nextCursor;\n\n    console.log(`Fetched ${result.items.length} items, total so far: ${allItems.length}`);\n  } while (cursor !== null);\n\n  return allItems;\n}\n\n// Usage\nconst allCases = await iterateWithCursor(async (cursor, size) => {\n  const params = new URLSearchParams({ size });\n  if (cursor) params.append('cursor', cursor);\n\n  const response = await fetch(\n    `https://api-v3.sprinklr.com/api/v3/case/search?${params}`,\n    {\n      method: 'POST',\n      headers: {\n        'Authorization': `Bearer ${accessToken}`,\n        'Key': apiKey,\n        'Content-Type': 'application/json'\n      },\n      body: JSON.stringify({ status: 'OPEN' })\n    }\n  );\n\n  const data = await response.json();\n\n  return {\n    items: data.data,\n    nextCursor: data.pagination?.nextCursor || null\n  };\n});\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"caching-paginated-results","__idx":27},"children":["Caching paginated results"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Caching can dramatically improve performance for frequently accessed pages."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"smart-pagination-cache","__idx":28},"children":["Smart pagination cache"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"class PaginationCache {\n  constructor(ttl = 300000) { // 5 minutes default\n    this.cache = new Map();\n    this.ttl = ttl;\n  }\n\n  generateKey(page, size, sort, filters) {\n    return `${page}:${size}:${sort}:${JSON.stringify(filters)}`;\n  }\n\n  set(page, size, sort, filters, data) {\n    const key = this.generateKey(page, size, sort, filters);\n    this.cache.set(key, {\n      data,\n      timestamp: Date.now()\n    });\n  }\n\n  get(page, size, sort, filters) {\n    const key = this.generateKey(page, size, sort, filters);\n    const cached = this.cache.get(key);\n\n    if (!cached) return null;\n\n    // Check if expired\n    if (Date.now() - cached.timestamp > this.ttl) {\n      this.cache.delete(key);\n      return null;\n    }\n\n    return cached.data;\n  }\n\n  clear() {\n    this.cache.clear();\n  }\n\n  // Clear cache for specific filters (e.g., when data changes)\n  clearMatching(filters) {\n    const filterStr = JSON.stringify(filters);\n    for (const [key, _] of this.cache) {\n      if (key.includes(filterStr)) {\n        this.cache.delete(key);\n      }\n    }\n  }\n}\n\n// Usage\nconst cache = new PaginationCache(300000); // 5 minutes\n\nasync function getCasesWithCache(page, size, filters = {}) {\n  const sort = 'createdTime,desc';\n\n  // Check cache first\n  const cached = cache.get(page, size, sort, filters);\n  if (cached) {\n    console.log('Cache hit!');\n    return cached;\n  }\n\n  // Fetch from API\n  console.log('Cache miss, fetching from API...');\n  const response = await getCases(page, size);\n\n  // Cache the result\n  cache.set(page, size, sort, filters, response);\n\n  return response;\n}\n\n// When a case is updated, clear relevant cache entries\nfunction onCaseUpdated(caseId) {\n  cache.clearMatching({ status: 'OPEN' });\n  console.log('Cleared cache for OPEN cases');\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"error-handling-in-pagination","__idx":29},"children":["Error handling in pagination"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Robust error handling is essential for pagination since you're making multiple requests."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function getAllCasesWithErrorHandling() {\n  const allCases = [];\n  let page = 0;\n  let hasMore = true;\n  const maxRetries = 3;\n\n  while (hasMore) {\n    let attempt = 0;\n    let success = false;\n    let response;\n\n    // Retry logic for each page\n    while (attempt < maxRetries && !success) {\n      try {\n        response = await getCases(page, 50);\n        success = true;\n      } catch (error) {\n        attempt++;\n        console.error(`Error fetching page ${page}, attempt ${attempt}:`, error.message);\n\n        if (attempt >= maxRetries) {\n          throw new Error(`Failed to fetch page ${page} after ${maxRetries} attempts`);\n        }\n\n        // Exponential backoff\n        const waitTime = Math.pow(2, attempt) * 1000;\n        console.log(`Waiting ${waitTime}ms before retry...`);\n        await new Promise(resolve => setTimeout(resolve, waitTime));\n      }\n    }\n\n    if (!response.success) {\n      console.error(`Page ${page} returned success=false`);\n      break;\n    }\n\n    allCases.push(...response.data);\n    hasMore = !response.pagination.last;\n    page++;\n  }\n\n  return {\n    cases: allCases,\n    completedPages: page,\n    complete: !hasMore\n  };\n}\n\n// Usage\ntry {\n  const result = await getAllCasesWithErrorHandling();\n\n  if (result.complete) {\n    console.log(`Successfully fetched all ${result.cases.length} cases`);\n  } else {\n    console.warn(`Partial fetch: got ${result.cases.length} cases from ${result.completedPages} pages`);\n  }\n} catch (error) {\n  console.error('Pagination failed completely:', error);\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"performance-optimization-tips","__idx":30},"children":["Performance optimization tips"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"1-fetch-only-the-fields-you-need","__idx":31},"children":["1. Fetch only the fields you need"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If the API supports field selection, specify only required fields to reduce response size:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const response = await fetch(\n  'https://api-v3.sprinklr.com/api/v3/case/search?page=0&size=50&fields=caseId,subject,status',\n  {\n    method: 'POST',\n    headers: {\n      'Authorization': `Bearer ${accessToken}`,\n      'Key': apiKey,\n      'Content-Type': 'application/json'\n    },\n    body: JSON.stringify({ status: 'OPEN' })\n  }\n);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"2-use-appropriate-page-sizes-based-on-data-volume","__idx":32},"children":["2. Use appropriate page sizes based on data volume"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// Estimate total time for different strategies\nfunction estimateFetchTime(totalItems, pageSize, requestTime = 300) {\n  const totalPages = Math.ceil(totalItems / pageSize);\n  const totalTime = totalPages * requestTime;\n  return {\n    totalPages,\n    totalTime: `${(totalTime / 1000).toFixed(1)} seconds`,\n    requestsPerMinute: Math.ceil((totalPages / totalTime) * 60000)\n  };\n}\n\n// Compare strategies for 5000 items\nconsole.log('Page size 20:', estimateFetchTime(5000, 20));  // 250 pages, 75 seconds\nconsole.log('Page size 50:', estimateFetchTime(5000, 50));  // 100 pages, 30 seconds\nconsole.log('Page size 100:', estimateFetchTime(5000, 100)); // 50 pages, 15 seconds\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"3-parallel-fetching-with-rate-limit-awareness","__idx":33},"children":["3. Parallel fetching with rate limit awareness"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function fetchPagesInParallel(totalPages, pageSize, concurrency = 3) {\n  const allResults = [];\n\n  // Process pages in batches to respect rate limits\n  for (let batch = 0; batch < Math.ceil(totalPages / concurrency); batch++) {\n    const startPage = batch * concurrency;\n    const endPage = Math.min(startPage + concurrency, totalPages);\n\n    const batchPromises = [];\n    for (let page = startPage; page < endPage; page++) {\n      batchPromises.push(getCases(page, pageSize));\n    }\n\n    const batchResults = await Promise.all(batchPromises);\n    allResults.push(...batchResults);\n\n    console.log(`Fetched batch ${batch + 1}, pages ${startPage}-${endPage - 1}`);\n\n    // Small delay between batches\n    if (endPage < totalPages) {\n      await new Promise(resolve => setTimeout(resolve, 100));\n    }\n  }\n\n  return allResults.flatMap(r => r.data);\n}\n\n// Fetch 30 pages, 3 at a time\nconst cases = await fetchPagesInParallel(30, 50, 3);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"troubleshooting-pagination-issues","__idx":34},"children":["Troubleshooting pagination issues"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"issue-missing-or-duplicate-items","__idx":35},"children":["Issue: Missing or duplicate items"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Symptoms:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Items appear twice in your results"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Items are missing when you fetch all pages"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Total count doesn't match expected number"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Causes:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Data changing between page fetches"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Inconsistent sort order between requests"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Starting page number from 1 instead of 0"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Solutions:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ✅ Always use 0-indexed pages\nconst correctPage = await getCases(0, 20); // First page\n\n// ❌ Don't use 1-indexed\nconst wrongPage = await getCases(1, 20); // This is the SECOND page!\n\n// ✅ Use consistent sort order\nconst page1 = await getCases(0, 20, 'createdTime,desc');\nconst page2 = await getCases(1, 20, 'createdTime,desc'); // Same sort!\n\n// ✅ Use timestamp filters for consistent snapshots\nconst timestamp = new Date().toISOString();\nconst page1 = await getCases(0, 20, { createdBefore: timestamp });\nconst page2 = await getCases(1, 20, { createdBefore: timestamp });\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"issue-slow-pagination-performance","__idx":36},"children":["Issue: Slow pagination performance"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Symptoms:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Taking too long to fetch all pages"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Requests timing out"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Memory issues with large datasets"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Solutions:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// 1. Increase page size to reduce total requests\nconst largerPages = await getCases(page, 100); // Max size\n\n// 2. Use parallel fetching (but respect rate limits)\nconst parallel = await Promise.all([\n  getCases(0, 50),\n  getCases(1, 50),\n  getCases(2, 50)\n]);\n\n// 3. Process progressively instead of loading all at once\nawait processAllCases(async (caseItem) => {\n  // Process each case immediately\n  await handleCase(caseItem);\n});\n\n// 4. Use appropriate caching\ncache.set(page, size, sort, filters, response);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"issue-page-count-changes-during-iteration","__idx":37},"children":["Issue: Page count changes during iteration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Symptoms:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["totalPages"]}," is different on each request"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Can't reach the last page"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Infinite loop in pagination"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Causes:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Items being added/deleted during pagination"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Filters changing between requests"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Solutions:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// Use last flag instead of totalPages\nasync function getAllCasesSafely() {\n  const allCases = [];\n  let page = 0;\n  let hasMore = true;\n  const maxPages = 1000; // Safety limit\n\n  while (hasMore && page < maxPages) {\n    const response = await getCases(page, 50);\n    allCases.push(...response.data);\n\n    // Use 'last' flag, not totalPages\n    hasMore = !response.pagination.last;\n    page++;\n  }\n\n  if (page >= maxPages) {\n    console.warn('Hit max page limit, there may be more data');\n  }\n\n  return allCases;\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"next-steps","__idx":38},"children":["Next steps"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Now that you understand pagination, explore these related topics:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/api-basics"},"children":["API Basics"]}]}," - Learn about batch operations and other core API patterns"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/rate-limiting"},"children":["Rate Limiting"]}]}," - Optimize pagination performance with rate limit strategies"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/error-handling"},"children":["Error Handling"]}]}," - Handle pagination errors gracefully"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/best-practices"},"children":["Best Practices"]}]}," - Production-ready patterns for API integrations"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"need-help","__idx":39},"children":["Need help?"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you're experiencing pagination issues:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Verify your page numbers"]}," - Remember, pages start at 0, not 1"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Check your sort order"]}," - Inconsistent sorting causes duplicate/missing items"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Review response metadata"]}," - The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pagination"]}," object tells you what's happening"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Monitor performance"]}," - Track fetch times and adjust page sizes"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Support resources:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Technical support: ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://support.sprinklr.com"},"children":["support.sprinklr.com"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["API documentation: This guide and related docs"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Community forums: Share pagination patterns with other developers"]}]}]},"headings":[{"value":"Pagination","id":"pagination","depth":1},{"value":"Why pagination matters","id":"why-pagination-matters","depth":2},{"value":"How Sprinklr API pagination works","id":"how-sprinklr-api-pagination-works","depth":2},{"value":"Pagination parameters","id":"pagination-parameters","depth":2},{"value":"Making a paginated request","id":"making-a-paginated-request","depth":3},{"value":"Understanding the pagination response","id":"understanding-the-pagination-response","depth":2},{"value":"Pagination metadata fields","id":"pagination-metadata-fields","depth":3},{"value":"Sorting paginated results","id":"sorting-paginated-results","depth":2},{"value":"Sort syntax","id":"sort-syntax","depth":3},{"value":"Common sort fields","id":"common-sort-fields","depth":3},{"value":"Sort examples","id":"sort-examples","depth":3},{"value":"Common pagination patterns","id":"common-pagination-patterns","depth":2},{"value":"Pattern 1: Fetch all pages sequentially","id":"pattern-1-fetch-all-pages-sequentially","depth":3},{"value":"Pattern 2: Process pages progressively","id":"pattern-2-process-pages-progressively","depth":3},{"value":"Pattern 3: Fetch a specific page","id":"pattern-3-fetch-a-specific-page","depth":3},{"value":"Pattern 4: Parallel page fetching","id":"pattern-4-parallel-page-fetching","depth":3},{"value":"Pattern 5: Infinite scroll / lazy loading","id":"pattern-5-infinite-scroll--lazy-loading","depth":3},{"value":"Choosing the right page size","id":"choosing-the-right-page-size","depth":2},{"value":"Page size trade-offs","id":"page-size-trade-offs","depth":3},{"value":"Recommended page sizes by use case","id":"recommended-page-sizes-by-use-case","depth":3},{"value":"Handling edge cases","id":"handling-edge-cases","depth":2},{"value":"Empty results","id":"empty-results","depth":3},{"value":"Page out of range","id":"page-out-of-range","depth":3},{"value":"Data changes during pagination","id":"data-changes-during-pagination","depth":3},{"value":"Advanced: Cursor-based pagination","id":"advanced-cursor-based-pagination","depth":2},{"value":"How cursor pagination works","id":"how-cursor-pagination-works","depth":3},{"value":"Implementing cursor pagination","id":"implementing-cursor-pagination","depth":3},{"value":"Caching paginated results","id":"caching-paginated-results","depth":2},{"value":"Smart pagination cache","id":"smart-pagination-cache","depth":3},{"value":"Error handling in pagination","id":"error-handling-in-pagination","depth":2},{"value":"Performance optimization tips","id":"performance-optimization-tips","depth":2},{"value":"1. Fetch only the fields you need","id":"1-fetch-only-the-fields-you-need","depth":3},{"value":"2. Use appropriate page sizes based on data volume","id":"2-use-appropriate-page-sizes-based-on-data-volume","depth":3},{"value":"3. Parallel fetching with rate limit awareness","id":"3-parallel-fetching-with-rate-limit-awareness","depth":3},{"value":"Troubleshooting pagination issues","id":"troubleshooting-pagination-issues","depth":2},{"value":"Issue: Missing or duplicate items","id":"issue-missing-or-duplicate-items","depth":3},{"value":"Issue: Slow pagination performance","id":"issue-slow-pagination-performance","depth":3},{"value":"Issue: Page count changes during iteration","id":"issue-page-count-changes-during-iteration","depth":3},{"value":"Next steps","id":"next-steps","depth":2},{"value":"Need help?","id":"need-help","depth":2}],"frontmatter":{"seo":{"title":"Pagination"}},"lastModified":"2026-10-27T09:16:56.933Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/pagination","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}