Skip to main content
Xpoz supports bulk data export to CSV for any search or paginated query. Instead of iterating through hundreds of pages, export the entire result set as a single downloadable file hosted on S3.

How it works

  1. Set the response mode to CSV
  2. The server runs the query asynchronously and writes results to S3
  3. You receive an S3 download URL when the export completes
  4. Download the CSV file for analysis, reporting, or archival
CSV exports can contain up to 500,000 rows. For larger datasets, use date range filters to split your export into smaller batches.

SDK usage

Direct CSV mode

Set responseType: ResponseType.Csv to initiate a CSV export directly:
import { XpozClient, ResponseType } from '@xpoz/xpoz';

const client = new XpozClient({ apiKey: 'your-api-key' });
await client.connect();

const results = await client.twitter.searchPosts('bitcoin', {
  startDate: '2025-01-01',
  responseType: ResponseType.Csv,
});

// Poll the export operation and get the download URL
const downloadUrl = await results.exportCsv();
console.log('Download:', downloadUrl);

await client.close();

Export from a paginated result

Start with paging mode, review the first page, then export if needed:
const results = await client.twitter.searchPosts('AI', {
  startDate: '2025-01-01',
  responseType: ResponseType.Paging,
});

console.log(`${results.pagination.totalRows} total results`);

// Decide to export after seeing the count
if (results.pagination.totalRows > 1000) {
  const csvUrl = await results.exportCsv();
  console.log('Exported to:', csvUrl);
}

CSV file format

The exported CSV file includes:
  • Header row with column names matching the API field names
  • UTF-8 encoding for international characters
  • Standard CSV escaping (quoted fields for values containing commas or newlines)
  • All available fields unless you specified fields in the original query
Use the fields parameter in your query to control which columns appear in the CSV. This reduces file size and speeds up the export.

Methods supporting CSV export

PlatformMethodSDK (TS)SDK (Python)
TwitterSearch poststwitter.searchPosts()twitter.search_posts()
TwitterPosts by authortwitter.getPostsByAuthor()twitter.get_posts_by_author()
TwitterUsers by keywordstwitter.getUsersByKeywords()twitter.get_users_by_keywords()
InstagramSearch postsinstagram.searchPosts()instagram.search_posts()
InstagramPosts by userinstagram.getPostsByUser()instagram.get_posts_by_user()
InstagramUsers by keywordsinstagram.getUsersByKeywords()instagram.get_users_by_keywords()
RedditSearch postsreddit.searchPosts()reddit.search_posts()
TikTokSearch poststiktok.searchPosts()tiktok.search_posts()
TikTokPosts by usertiktok.getPostsByUser()tiktok.get_posts_by_user()
TikTokUsers by keywordstiktok.getUsersByKeywords()tiktok.get_users_by_keywords()
TikTokPosts by hashtagstiktok.getPostsByHashtags()tiktok.get_posts_by_hashtags()
TikTokUsers by hashtagstiktok.getUsersByHashtags()tiktok.get_users_by_hashtags()

Use cases

  • Data analysis: Import into pandas, Excel, or Google Sheets for in-depth analysis
  • Reporting: Generate periodic reports on brand mentions, sentiment, or engagement
  • Archival: Store snapshots of social media data for compliance or research
  • ML training: Build training datasets for sentiment analysis, topic classification, or trend prediction
  • Cross-platform comparison: Export data from multiple platforms and join in your analytics tool

Next steps

Response Modes

Compare fast, paging, and CSV modes

Best Practices

Optimize queries and exports for performance