{"slug":"twitter-data-export","title":"twitter-data-export","summary":"Export Twitter/X data to CSV for analysis using Xpoz. Search by keywords, author, date range, and download complete datasets (up to 500K rows). Use when asked to \"export tweets\", \"download Twitter data\", \"get tweets as CSV\", \"Twitter dataset\", or \"bulk tweet download\".","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-14T21:09:18.135956Z","repo":{"url":"https://github.com/XPOZpublic/xpoz-agent-skills","stars":15,"forks":3,"license":"MIT","updatedAt":"2026-09-09T13:52:40Z"},"bodyHtml":"<hr>\n<h2>name: twitter-data-export\nversion: 2026-02-24\ndescription: Export Twitter/X data to CSV for analysis using Xpoz. Search by keywords, author, date range, and download complete datasets (up to 500K rows). Use when asked to \"export tweets\", \"download Twitter data\", \"get tweets as CSV\", \"Twitter dataset\", or \"bulk tweet download\".</h2>\n<h1>Twitter Data Export</h1>\n<h2>Overview</h2>\n<p>Search and export Twitter/X data to CSV files for analysis. Supports keyword search, author-based search, date filtering, and bulk exports up to 500K rows — no Twitter API keys required.</p>\n<h2>When to Use</h2>\n<p>Activate when the user asks:</p>\n<ul>\n<li>\"Export tweets about [TOPIC] to CSV\"</li>\n<li>\"Download all tweets from @[USER]\"</li>\n<li>\"Get Twitter data for [KEYWORD] from last month\"</li>\n<li>\"I need a dataset of tweets about [TOPIC]\"</li>\n<li>\"Bulk download tweets matching [QUERY]\"</li>\n<li>\"Twitter data export\"</li>\n</ul>\n<h2>Setup &amp; Authentication</h2>\n<p>Before fetching data, ensure Xpoz access is configured. Follow these checks in order.</p>\n<h3>Check 1: Already authenticated?</h3>\n<p><strong>If you have MCP tools</strong>, try calling any Xpoz tool (e.g., <code>checkAccessKeyStatus</code>). If it works → skip to Step 1.</p>\n<p><strong>If you have the SDK</strong>, try:</p>\n<pre><code>from xpoz import XpozClient\nclient = XpozClient()  # reads XPOZ_API_KEY env var\n</code></pre>\n<p>If this succeeds without error → skip to Step 1.</p>\n<p>If neither works, you need to authenticate. Get a free access key (below).</p>\n<hr>\n<h3>Recommended: a free access key</h3>\n<p>Real analyses need a real key: <a href=\"https://xpoz.ai/get-token\">get a free access key</a> (free tier, up to 75K results, no credit card). SDK and CLI users set it as <code>XPOZ_API_KEY</code>; MCP connections sign in with the same account via OAuth on first tool call (paths below).</p>\n<hr>\n<h3>Path A: MCP via mcporter (OpenClaw agents)</h3>\n<p>If <code>mcporter</code> is available:</p>\n<pre><code>mcporter call xpoz.checkAccessKeyStatus\n</code></pre>\n<p>If <code>hasAccessKey: true</code> → ready. If not:</p>\n<pre><code>mcporter config add xpoz https://mcp.xpoz.ai/mcp --auth oauth\n</code></pre>\n<p>Then authenticate — generate the OAuth URL and send it to the user:</p>\n<p><strong>Step 1: Generate authorization URL</strong></p>\n<pre><code>import secrets, hashlib, base64, urllib.parse, json, urllib.request, os\n\nverifier = secrets.token_urlsafe(64)\nchallenge = base64.urlsafe_b64encode(hashlib.sha256(verifier.encode()).digest()).rstrip(b'=').decode()\nstate = secrets.token_urlsafe(32)\n\n# Dynamic client registration\nreg_req = urllib.request.Request(\n    'https://mcp.xpoz.ai/oauth/register',\n    data=json.dumps({\n        'client_name': 'Agent Skills',\n        'redirect_uris': ['https://www.xpoz.ai/oauth/openclaw'],\n        'grant_types': ['authorization_code'],\n        'response_types': ['code'],\n        'token_endpoint_auth_method': 'none',\n    }).encode(),\n    headers={'Content-Type': 'application/json'},\n)\nreg_resp = json.loads(urllib.request.urlopen(reg_req).read())\n\nparams = urllib.parse.urlencode({\n    'response_type': 'code',\n    'client_id': reg_resp['client_id'],\n    'code_challenge': challenge,\n    'code_challenge_method': 'S256',\n    'redirect_uri': 'https://www.xpoz.ai/oauth/openclaw',\n    'state': state,\n    'scope': 'mcp:tools',\n    'resource': 'https://mcp.xpoz.ai/',\n})\n\nauth_url = 'https://mcp.xpoz.ai/oauth/authorize?' + params\n\n# Save state for token exchange\nos.makedirs(os.path.expanduser('~/.cache/xpoz-oauth'), exist_ok=True)\nwith open(os.path.expanduser('~/.cache/xpoz-oauth/state.json'), 'w') as f:\n    json.dump({'verifier': verifier, 'state': state, 'client_id': reg_resp['client_id'],\n               'redirect_uri': 'https://www.xpoz.ai/oauth/openclaw'}, f)\n\nprint(auth_url)\n</code></pre>\n<p><strong>Step 2: Send the URL to the user</strong></p>\n<p>Tell them:</p>\n<blockquote>\n<p>\"I need to connect to Xpoz for social media data. Please open this link and sign in:</p>\n<p>[auth_url]</p>\n<p>After authorizing, you'll see a code. Paste it back to me here.\"</p>\n</blockquote>\n<p><strong>Step 3: WAIT for the user to reply with the code.</strong> Do not proceed until they respond.</p>\n<p><strong>Step 4: Exchange the code for a token</strong></p>\n<p>Once the user provides the code (either a raw code or a URL containing <code>?code=...</code>), extract the code and exchange it:</p>\n<pre><code>import json, urllib.request, urllib.parse, subprocess, os\n\nwith open(os.path.expanduser('~/.cache/xpoz-oauth/state.json')) as f:\n    oauth = json.load(f)\n\ncode = \"THE_CODE_FROM_USER\"  # Extract from user's reply\n\ndata = urllib.parse.urlencode({\n    'grant_type': 'authorization_code',\n    'code': code,\n    'redirect_uri': oauth['redirect_uri'],\n    'client_id': oauth['client_id'],\n    'code_verifier': oauth['verifier'],\n}).encode()\n\nreq = urllib.request.Request(\n    'https://mcp.xpoz.ai/oauth/token',\n    data=data,\n    headers={'Content-Type': 'application/x-www-form-urlencoded'},\n)\nresp = json.loads(urllib.request.urlopen(req).read())\ntoken = resp['access_token']\n\n# Configure mcporter with the token (token is never printed)\nsubprocess.run(['mcporter', 'config', 'remove', 'xpoz'], capture_output=True)\nsubprocess.run(['mcporter', 'config', 'add', 'xpoz', 'https://mcp.xpoz.ai/mcp',\n                '--header', f'Authorization=Bearer {token}'], check=True)\n\n# Clean up\nos.remove(os.path.expanduser('~/.cache/xpoz-oauth/state.json'))\nprint(\"Xpoz configured successfully\")\n</code></pre>\n<p><strong>Step 5: Verify</strong> with <code>mcporter call xpoz.checkAccessKeyStatus</code> → should return <code>hasAccessKey: true</code>.</p>\n<hr>\n<h3>Path B: MCP via Claude Code</h3>\n<p>For Claude Code users without mcporter:</p>\n<pre><code>claude mcp add --transport http xpoz https://mcp.xpoz.ai/mcp\n</code></pre>\n<p>Claude Code handles OAuth automatically on first tool call — the user just needs to authorize in their browser when prompted.</p>\n<hr>\n<h3>Path C: SDK (Python or TypeScript)</h3>\n<p>Ask the user:</p>\n<blockquote>\n<p>\"I need a Xpoz API key to access social media data. Please go to <a href=\"https://xpoz.ai/get-token\">https://xpoz.ai/get-token</a> (it's free, no credit card needed) and paste the key back to me.\"</p>\n</blockquote>\n<p><strong>WAIT for the user to reply with the key.</strong> Then:</p>\n<p><strong>Python:</strong></p>\n<pre><code>pip install xpoz\n</code></pre>\n<pre><code>from xpoz import XpozClient\nclient = XpozClient(\"THE_KEY_FROM_USER\")\n</code></pre>\n<p><strong>TypeScript:</strong></p>\n<pre><code>npm install @xpoz/xpoz\n</code></pre>\n<pre><code>import { XpozClient } from \"@xpoz/xpoz\";\nconst client = new XpozClient({ apiKey: \"THE_KEY_FROM_USER\" });\nawait client.connect();\n</code></pre>\n<p>Or set the environment variable and use the default constructor:</p>\n<pre><code>export XPOZ_API_KEY=THE_KEY_FROM_USER\n</code></pre>\n<hr>\n<h3>Auth Errors</h3>\n<table>\n<thead>\n<tr>\n<th>Problem</th>\n<th>Solution</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>MCP: \"Unauthorized\"</td>\n<td>Re-run the OAuth flow above</td>\n</tr>\n<tr>\n<td>SDK: <code>AuthenticationError</code></td>\n<td>Verify key at <a href=\"https://xpoz.ai/settings\">xpoz.ai/settings</a></td>\n</tr>\n<tr>\n<td>Token exchange fails</td>\n<td>Ask user to re-authorize — codes are single-use</td>\n</tr>\n</tbody>\n</table>\n<h2>Step-by-Step Instructions</h2>\n<h3>Step 1: Parse the Request</h3>\n<p>Extract:</p>\n<ul>\n<li><strong>Query</strong>: keywords, hashtags, or phrases to search</li>\n<li><strong>Author</strong> (optional): specific Twitter username</li>\n<li><strong>Date range</strong> (default: last 30 days)</li>\n<li><strong>Fields</strong> the user cares about (default: full export)</li>\n</ul>\n<p>Build the query using boolean operators:</p>\n<ul>\n<li>Exact phrase: <code>\"machine learning\"</code></li>\n<li>OR: <code>\"AI\" OR \"artificial intelligence\"</code></li>\n<li>AND: <code>\"Tesla\" AND \"earnings\"</code></li>\n<li>NOT: <code>\"crypto\" NOT \"scam\"</code></li>\n<li>Combined: <code>(\"deep learning\" OR \"neural network\") AND python</code></li>\n</ul>\n<h3>Step 2: Search and Export</h3>\n<h4>Via MCP</h4>\n<p><strong>Search by keywords:</strong></p>\n<pre><code>Call getTwitterPostsByKeywords:\n  query: \"&lt;query&gt;\"\n  fields: [\"id\", \"text\", \"authorUsername\", \"authorId\", \"createdAtDate\", \"likeCount\", \"retweetCount\", \"quoteCount\", \"impressionCount\", \"language\"]\n  startDate: \"&lt;YYYY-MM-DD&gt;\"\n  endDate: \"&lt;YYYY-MM-DD&gt;\"\n  language: \"en\" (optional)\n</code></pre>\n<p><strong>Search by author:</strong></p>\n<pre><code>Call getTwitterPostsByAuthor:\n  identifier: \"&lt;username&gt;\"\n  identifierType: \"username\"\n  fields: [\"id\", \"text\", \"createdAtDate\", \"likeCount\", \"retweetCount\", \"quoteCount\", \"impressionCount\"]\n  startDate: \"&lt;YYYY-MM-DD&gt;\"\n  endDate: \"&lt;YYYY-MM-DD&gt;\"\n</code></pre>\n<p><strong>CRITICAL: Async Pattern</strong> — calls return an <code>operationId</code>. Call <code>checkOperationStatus</code> with that ID and poll until \"completed\" (up to 8 retries, ~5 seconds apart).</p>\n<p><strong>CSV Export (two options):</strong></p>\n<ol>\n<li>Pass <code>responseType=\"csv\"</code> in the original call to get a CSV download directly</li>\n<li>Or use the <code>dataDumpExportOperationId</code> from the response — call <code>checkOperationStatus</code> with it to get an S3 download URL for the complete dataset</li>\n</ol>\n<h4>Via Python SDK</h4>\n<pre><code>from xpoz import XpozClient\n\nclient = XpozClient()  # Uses XPOZ_API_KEY env var\n\n# Search by keywords\nresults = client.twitter.search_posts(\n    '\"artificial intelligence\" AND ethics',\n    start_date=\"2026-01-01\",\n    end_date=\"2026-02-23\",\n    language=\"en\",\n    fields=[\"id\", \"text\", \"author_username\", \"created_at_date\", \"like_count\", \"retweet_count\", \"impression_count\"]\n)\n\nprint(f\"Found {results.pagination.total_rows:,} tweets\")\n\n# Export entire result set to CSV (up to 500K rows)\ncsv_url = results.export_csv()\nprint(f\"Download CSV: {csv_url}\")\n\n# Or search by author\nauthor_results = client.twitter.get_posts_by_author(\n    \"elonmusk\",\n    start_date=\"2026-01-01\",\n    fields=[\"id\", \"text\", \"created_at_date\", \"like_count\", \"retweet_count\"]\n)\nauthor_csv = author_results.export_csv()\n\nclient.close()\n</code></pre>\n<p><strong>Download and analyze locally:</strong></p>\n<pre><code>import pandas as pd\nimport subprocess\n\n# Download the CSV\nsubprocess.run([\"curl\", \"-L\", \"-o\", \"tweets.csv\", csv_url])\n\n# Load and analyze\ndf = pd.read_csv(\"tweets.csv\")\nprint(f\"Total tweets: {len(df)}\")\nprint(f\"Date range: {df['created_at_date'].min()} to {df['created_at_date'].max()}\")\nprint(f\"Average likes: {df['like_count'].mean():.1f}\")\nprint(f\"Top authors:\\n{df['author_username'].value_counts().head(10)}\")\n</code></pre>\n<h4>Via TypeScript SDK</h4>\n<pre><code>import { XpozClient } from \"@xpoz/xpoz\";\n\nconst client = new XpozClient();\nawait client.connect();\n\nconst results = await client.twitter.searchPosts('\"artificial intelligence\" AND ethics', {\n  startDate: \"2026-01-01\",\n  endDate: \"2026-02-23\",\n  language: \"en\",\n  fields: [\"id\", \"text\", \"authorUsername\", \"createdAtDate\", \"likeCount\", \"retweetCount\"],\n});\n\nconsole.log(`Found ${results.pagination.totalRows.toLocaleString()} tweets`);\n\n// Export to CSV\nconst csvUrl = await results.exportCsv();\nconsole.log(`Download: ${csvUrl}`);\n\nawait client.close();\n</code></pre>\n<h3>Step 3: Present Results</h3>\n<p>After export, provide the user with:</p>\n<ol>\n<li><strong>Summary stats</strong>: total rows, date range, top authors, avg engagement</li>\n<li><strong>CSV download link</strong> (from <code>export_csv()</code> / <code>exportCsv()</code>)</li>\n<li><strong>Sample data</strong>: show first 5-10 rows as a table</li>\n<li><strong>Suggested analysis</strong>: what they might want to do with the data</li>\n</ol>\n<pre><code>## Export Complete: [QUERY]\n\n**Rows exported:** 12,456\n**Period:** Jan 1 – Feb 23, 2026\n**Download:** [CSV link]\n\n### Sample Data\n| Date | Author | Text (truncated) | Likes | RTs |\n|------|--------|-------------------|-------|-----|\n| ... | ... | ... | ... | ... |\n\n### Quick Stats\n- Avg likes per tweet: 45.2\n- Most active author: @user (234 tweets)\n- Peak day: Feb 14, 2026 (1,203 tweets)\n\n### Suggested Next Steps\n- Load into pandas/Excel for deeper analysis\n- Filter by engagement (like_count &gt; 100) for high-impact posts\n- Group by date for trend analysis\n</code></pre>\n<h2>Available Fields</h2>\n<table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>id</code></td>\n<td>Tweet ID</td>\n</tr>\n<tr>\n<td><code>text</code></td>\n<td>Full tweet text</td>\n</tr>\n<tr>\n<td><code>authorUsername</code></td>\n<td>Author's username</td>\n</tr>\n<tr>\n<td><code>authorId</code></td>\n<td>Author's numeric ID</td>\n</tr>\n<tr>\n<td><code>createdAtDate</code></td>\n<td>Post date (YYYY-MM-DD)</td>\n</tr>\n<tr>\n<td><code>likeCount</code></td>\n<td>Number of likes</td>\n</tr>\n<tr>\n<td><code>retweetCount</code></td>\n<td>Number of retweets</td>\n</tr>\n<tr>\n<td><code>quoteCount</code></td>\n<td>Number of quote tweets</td>\n</tr>\n<tr>\n<td><code>impressionCount</code></td>\n<td>Number of impressions</td>\n</tr>\n<tr>\n<td><code>replyCount</code></td>\n<td>Number of replies</td>\n</tr>\n<tr>\n<td><code>language</code></td>\n<td>Detected language</td>\n</tr>\n<tr>\n<td><code>isRetweet</code></td>\n<td>Whether it's a retweet</td>\n</tr>\n<tr>\n<td><code>isReply</code></td>\n<td>Whether it's a reply</td>\n</tr>\n</tbody>\n</table>\n<h2>Example Prompts</h2>\n<ul>\n<li>\"Export all tweets mentioning 'Claude Code' from the last 2 weeks to CSV\"</li>\n<li>\"Download @OpenAI's tweets from January 2026\"</li>\n<li>\"Get a dataset of tweets about 'MCP server' OR 'model context protocol'\"</li>\n<li>\"Export tweets about the Super Bowl with more than 100 likes\"</li>\n</ul>\n<h2>Notes</h2>\n<ul>\n<li>Maximum export size: ~500K rows per CSV</li>\n<li>Date range: up to 60-day rolling windows</li>\n<li>Free access key: up to 75K results at <a href=\"https://xpoz.ai?utm_source=github&amp;utm_medium=agent-skills&amp;utm_campaign=twitter-data-export\">xpoz.ai</a> (no credit card); real runs need it</li>\n<li>Pro: $20/month for 1M results</li>\n<li>No Twitter API keys needed — Xpoz handles all data access</li>\n</ul>\n","files":[{"path":"SKILL.md","sizeBytes":12084,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-14T21:09:39.902411Z","sha256":"53BA8D78A6B1B75CC22E1667DC5C710E652A653025A2AD3F879571B68A316A6A","sizeBytes":4935},"review":null,"source":{"repositoryUrl":"https://github.com/XPOZpublic/xpoz-agent-skills","path":"skills/twitter-data-export","license":"MIT","commit":"d18bc4b4b44f73c644da771fb3408b569481fd99","subtreeSha":"859624CCD4B1940CA2AD98B7F1B93C3C94167F89E0B3FA53F512CD62AC5564E7","lastSyncedAt":"2026-09-19T13:50:20.313802Z"},"reviewedAt":"2026-09-14T21:11:14.634359Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/XPOZpublic/xpoz-agent-skills/tree/main/skills/twitter-data-export"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install xpozpublic-xpoz-agent-skills@llmmart"},{"target":"git","command":"git clone https://github.com/XPOZpublic/xpoz-agent-skills.git"}]}