Use the CLI when a shell script, cron job, CI workflow, or operations runbook needs X API data without an application wrapper. It can search tweets, scrape tweets to JSON Lines, CSV, or XLSX, export follower data, upload media, post media tweets, post tweet replies, send direct messages, monitor tweets, and hand results toDocumentation Index
Fetch the complete documentation index at: https://docs.xquik.com/llms.txt
Use this file to discover all available pages before exploring further.
jq, Python, a warehouse loader, or a queue worker.
Install
PATH:
Authenticate
--api-key per command or use X_TWITTER_SCRAPER_BEARER_TOKEN for OAuth 2.1 access tokens.
Basic Example
--help at any level:
Workflow: Search Tweets to JSON Lines, CSV, or XLSX
Use this workflow when an analyst, data engineer, or growth operator needs tweets from an X search query in a JSON Lines handoff, analyst CSV file, XLSX workbook, warehouse load, CRM enrichment job, or queue. The CLI command below callsGET /x/tweets/search. It maps the same REST API query parameters to flags: --q, --limit, --cursor, --since-time, --until-time, and --query-type.
.tweets[], .has_next_page, and .next_cursor. Each tweet can include id, text, createdAt, engagement counts, bookmarkCount, isNoteTweet, author, media, quoted_tweet, and retweeted_tweet, depending on what X returns for the result.
Project .tweets[] into xquik-tweet-search.jsonl and xquik-tweet-search.csv rows with tweet_id, author_username, engagement counts, page_index, page_cursor, next_cursor, and has_next_page so scripts can resume safely or load the same records into XLSX, CRM, warehouse, or agent workflows.
--limit for a bounded request from 1 to 200. Omit it when passing --cursor in page loops.
Tweet search costs 1 credit per tweet returned. If remaining credits cannot cover a bounded --limit request, the API can return fewer tweets; if 0 paid results are affordable, it returns 402 insufficient_credits. Use --format-error json so batch jobs can branch on status and code, and retry 429 or temporary 5xx responses with backoff.
For XLSX handoff, keep xquik-tweet-search.jsonl as the source of truth and convert the same projected rows in your pipeline when account managers need a workbook.
Workflow: Follower Export to CSV, JSON, or XLSX
Use this workflow when sales, support, research, or marketing teams need an owned follower list in a CRM import, warehouse load, analyst CSV file, XLSX workbook, or resumable JSON handoff.follower_explorer requires targetUsername. The CLI flag is --target-username.
POST /extractions/estimate and returns allowed, estimatedResults, creditsRequired, creditsAvailable, and source. For follower exports, source is usually followers.
job_id, the source username, and the estimate before polling so a shell restart, queue retry, or CI rerun can resume the same follower export.
.job, .results, .hasMore, and .nextCursor. When .hasMore is true, pass .nextCursor back as --after to fetch the next saved page.
User ID or result xUserId as the CRM unique key. Keep
xquik-followers.jsonl for queue replay or warehouse loads, use
xquik-followers.json for app ingestion, xquik-followers.csv for CRM import,
and xquik-followers.xlsx for analyst handoff.
Cost: 1 credit per follower extracted or returned. Exports are free after the
extraction job exists.
Workflow: Tweet Replies to CSV, JSON, or XLSX
Use this workflow when a moderation, support, giveaway, research, or AI review job needs every reply under one tweet as a file handoff. The CLI calls the extraction endpoints: estimate first, runreply_extractor, poll the stored job, then export CSV, JSON, or XLSX.
reply_extractor requires targetTweetId. The CLI flag is --target-tweet-id.
POST /extractions/estimate and returns allowed, estimatedResults, creditsRequired, creditsAvailable, and source. For reply scraping, source is usually replyCount.
POST /extractions. Persist job_id before polling so a shell restart, queue retry, or CI rerun can resume the same extraction.
GET /extractions/{id}. The JSON response includes .job, .results, .hasMore, and .nextCursor. When .hasMore is true, save the cursor and call extractions retrieve again:
.results[] to your queue, CRM import, or warehouse load.
GET /extractions/{id}/export and writes the response bytes to --output. Use --format csv for analyst spreadsheets, --format json for pipelines, and --format xlsx for account-management workbooks. Cost: 1 credit per reply extracted or returned. Exports are free after the extraction job exists.
Workflow: Post Media Tweets, Replies, and DM Attachments
Use this workflow when an operator, support queue, or agent needs to publish a media-backed tweet, reply with media, or send one media attachment in a DM from a connected X account. Tweet and reply media posts use public media URLs directly onx:tweets create. Pass repeated --media flags for up to 4 image URLs, or pass exactly 1 MP4 video URL up to 100 MB. Do not mix video with other media. Do not upload first when you already have public media URLs.
--reply-to-tweet-id flag maps to reply_to_tweet_id, and --media maps to the public URL array on POST /x/tweets.
tweetId, success, charged, and chargedCredits. If the API returns 202 x_write_unconfirmed, store writeActionId, chargedCredits, and poll GET /x/write-actions/{id} before sending another write. Keep one JSON Lines handoff shape for both outcomes:
x:media upload when you need an uploaded media ID for a DM attachment. The CLI upload command accepts a local file through --file; --transform mediaId extracts the upload response ID for scripts.
--media-id flag maps to the REST media_ids body field. DMs accept exactly 1 uploaded media ID. Store messageId from the DM response on the support ticket, CRM record, queue job, or agent memory. Uploading media costs 10 credits, and sending the DM costs 10 credits.
Do not pass --reply-to-message-id to x:dm send; the REST endpoint rejects reply_to_message_id. Start a new DM with --user-id, --account, --text, and optional one-item --media-id instead.
Do not pass uploaded mediaId values to x:tweets create; that command uses --media with public media URLs.
Useful Commands
Search tweets or scrape tweets
Run
x-twitter-scraper x:tweets search to return tweet objects, author objects, metrics, media, has_next_page, and next_cursor.Fetch one tweet
Run
x-twitter-scraper x:tweets retrieve to return the full tweet text, author, metrics, media, quoted tweet, and retweeted tweet.Get tweet replies
Run
x-twitter-scraper x:tweets get-replies to return reply tweets plus cursor fields.Export followers
Run
x-twitter-scraper x:users retrieve-followers to return user profiles, follower counts, and cursor fields.Post a tweet or reply
Run
x-twitter-scraper x:tweets create to return tweetId, success, charged, and chargedCredits, or writeActionId when confirmation is pending.Upload media for a DM attachment
Run
x-twitter-scraper x:media upload to return mediaId for one-item DM media_ids and mediaUrl for tweet media URL handoff.Send a direct message
Run
x-twitter-scraper x:dm send to return messageId and success.--format json for scripts, --format yaml for readable operations output, and --transform with GJSON syntax when you only need one field from the response.
Error Handling
The CLI writes API errors to stderr and exits non-zero for failed requests. Use--format-error json when scripts need machine-readable errors.