Skip to main content

PaginatedResult

Methods that return large datasets use server-side pagination (100 items per page). These return a PaginatedResult<T> with built-in navigation helpers.
const results = await client.twitter.searchPosts("AI");

// Access current page data
results.data;                         // TwitterPost[] — current page items
results.pagination.totalRows;         // total matching rows
results.pagination.totalPages;        // total pages
results.pagination.pageNumber;        // current page number
results.pagination.pageSize;          // items per page (100)
results.pagination.resultsCount;      // items on current page
results.hasNextPage();                // boolean
const results = await client.twitter.searchPosts("AI");

// Fetch the next page
if (results.hasNextPage()) {
  const page2 = await results.nextPage();
  console.log(page2.data); // next 100 items
}

// Jump to a specific page
const page5 = await results.getPage(5);

Exporting to CSV

Any paginated result can be exported to CSV. This triggers a server-side export and returns a download URL:
const results = await client.twitter.searchPosts("AI");
const csvUrl = await results.exportCsv();
console.log(csvUrl); // URL to download the CSV file

Response Types

Search and query methods support a responseType option that controls how results are returned. Import the ResponseType enum:
import { XpozClient, ResponseType } from "@xpoz/xpoz";
ModeEnum ValueBehaviorBest For
FastResponseType.FastReturns up to 300 results immediately, no async pollingQuick queries, UI previews
PagingResponseType.PagingAsync paginated query with full dataset accessFull analysis, large datasets
CSVResponseType.CsvAsync bulk export, returns download URL via exportCsv()Data exports

Fast Mode (default)

Returns results immediately without polling. Use limit to constrain the number of results (max 300):
const results = await client.twitter.searchPosts("bitcoin", {
  startDate: "2025-01-01",
  responseType: ResponseType.Fast,
  limit: 50,
});
console.log(results.data.length); // up to 50 results, returned immediately
Fast mode skips async operation polling, making it significantly faster for small result sets. Use it when you need a quick preview or only need a limited number of results.

Paging Mode

Returns paginated results with full totalRows, totalPages, and navigation helpers:
const results = await client.twitter.searchPosts("bitcoin", {
  startDate: "2025-01-01",
  responseType: ResponseType.Paging,
});
console.log(results.pagination.totalRows);  // total matching rows

if (results.hasNextPage()) {
  const page2 = await results.nextPage();
}

CSV Mode

Initiates an async export. Call exportCsv() on the result to poll the export operation and get a download URL:
const results = await client.twitter.searchPosts("bitcoin", {
  startDate: "2025-01-01",
  responseType: ResponseType.Csv,
});
const downloadUrl = await results.exportCsv();
console.log(downloadUrl); // URL to download the CSV file

Methods Supporting Response Types

The following methods accept both responseType and limit:
  • twitter.getPostsByAuthor(), twitter.searchPosts(), twitter.getUsersByKeywords()
  • instagram.getPostsByUser(), instagram.searchPosts(), instagram.getUsersByKeywords()
  • reddit.searchPosts()
  • tiktok.getPostsByUser(), tiktok.searchPosts(), tiktok.getUsersByKeywords(), tiktok.getPostsByHashtags(), tiktok.getUsersByHashtags()
These methods accept limit only (no responseType):
  • twitter.searchUsers(), instagram.searchUsers(), reddit.searchUsers(), reddit.searchSubreddits(), tiktok.searchUsers()
For the equivalent pagination patterns in Python, see Python SDK Pagination. The Python SDK uses ResponseType.FAST, ResponseType.PAGING, and ResponseType.CSV (uppercase enum values) and snake_case field names.