xurl — A curl-style CLI for the X API
Central question this article answers: What is xurl, and how do I use it end-to-end to authenticate, call endpoints, stream data, receive webhooks, and upload media with the X API?
Direct answer: xurl is a curl-like command-line tool that wraps X API interactions: it supports OAuth 2.0 (PKCE), OAuth 1.0a, application bearer tokens, multiple OAuth2 accounts, persistent token storage, streaming responses, temporary webhook helpers (with ngrok), and chunked media upload flows. This article explains what xurl does, how to install and configure it, and shows practical scenarios and copy-paste command examples drawn from the provided README.
Quick start — what this guide contains
Core question: What will I learn from this article?
Direct answer: You will get a concise overview of xurl’s features, step-by-step installation and authentication commands, examples for making requests, handling streaming endpoints, setting up temporary webhooks, uploading media (including chunked uploads), token storage details, and ready-to-run workflows for common tasks.
Summary: Each major section begins with a one-sentence answer to the reader’s likely question, followed by implementation details, usage examples, and an application scenario.
Features — What can xurl do?
Central question: What are xurl’s main capabilities and when should I use each?
Direct answer: xurl supports app bearer token authentication, OAuth 2.0 user-context (PKCE), OAuth 1.0a, multiple OAuth2 accounts, persistent token storage in ~/.xurl
, customizable HTTP requests, automatic streaming detection for known endpoints, temporary webhook helpers (with ngrok), and chunked media upload (INIT → APPEND → FINALIZE → STATUS).
Summary: This section lists key features and pairs each with a concrete application scenario and operational example.
Feature list (with scenarios and examples)
-
OAuth 2.0 PKCE / user-context
-
Scenario: You need to perform actions on behalf of a human user (post tweets, access private user data).
-
Operational example: Set redirect URI to
http://localhost:8080/callback
, exportCLIENT_ID
andCLIENT_SECRET
, then run:export CLIENT_ID=your_client_id export CLIENT_SECRET=your_client_secret xurl auth oauth2
-
-
OAuth 1.0a
-
Scenario: An existing integration or legacy script requires OAuth 1.0a credentials.
-
Operational example: Provide consumer key/secret and access token/token secret:
xurl auth oauth1 --consumer-key KEY --consumer-secret SECRET --access-token TOKEN --token-secret SECRET
-
-
Application bearer token (app auth)
-
Scenario: You want to run app-level API calls that require only a bearer token.
-
Operational example:
xurl auth app --bearer-token BEARER_TOKEN
-
-
Multiple OAuth2 accounts
-
Scenario: You manage multiple test accounts and switch identities during development.
-
Operational example: Use
--username
to select a saved OAuth2 account:xurl --username johndoe /2/users/me
-
-
Persistent token storage
-
Scenario: Avoid re-authenticating every session; reuse stored tokens securely. -
Operational detail: Tokens are stored in ~/.xurl
.
-
-
Custom HTTP requests
-
Scenario: Send arbitrary GET/POST/PUT/PATCH requests with headers and JSON payloads.
-
Operational example:
xurl -X POST /2/tweets -d '{"text":"Hello world!"}' xurl -H "Content-Type: application/json" /2/tweets
-
-
Streaming response detection and forced streaming
-
Scenario: Consume
/2/tweets/search/stream
or similar endpoints in real time. -
Operational example:
xurl /2/tweets/search/stream # Or force streaming on any endpoint xurl -s /2/users/me
-
-
Temporary webhook helpers (ngrok integration)
-
Scenario: Local development needs to receive real API callbacks.
-
Operational example: Start a webhook helper which will use ngrok to expose a local endpoint:
xurl webhook start -p 8081 -o webhook_events.log
-
-
Chunked media upload (INIT → APPEND → FINALIZE → STATUS)
-
Scenario: Upload large video files in segments and then attach them to tweets.
-
Operational example:
# INIT xurl -X POST '/2/media/upload?command=INIT&total_bytes=FILE_SIZE&media_type=video/mp4&media_catefory=tweet_video' # APPEND (segment 0) xurl -X POST -F path/to/file.mp4 '/2/media/upload?command=APPEND&media_id=MEDIA_ID&segment_index=0' # FINALIZE xurl -X POST '/2/media/upload?command=FINALIZE&media_id=MEDIA_ID' # STATUS xurl '/2/media/upload?command=STATUS&media_id=MEDIA_ID'
-
Author’s reflection: Supporting multiple auth modes, automatic streaming recognition, and chunked upload in one CLI isolates many operational concerns that typically live across scripts and helper tools. The README exposes these capabilities clearly and provides commands that can be combined into repeatable workflows.
Installation — How do I install xurl?
Central question: How do I install xurl on my machine?
Direct answer: Install xurl with the single-line installer provided in the README:
curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | sudo bash
Summary: Run the one-line script, then verify the tool is on your PATH and test authentication status with xurl auth status
.
Installation steps and verification
-
Run the installer from the README:
curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | sudo bash
-
Verify the executable is available in your PATH (the install script places the binary accordingly).
-
Confirm basic operation:
xurl auth status
This command reports the current authentication status.
Application scenario: For a developer onboarding a new workstation, running the single install command gives a consistent executable and a quick way to validate the tool before configuring credentials.
Author’s reflection: The single-line installer is convenient for rapid setup; the README encourages immediate verification with xurl auth status
which is a sensible safety step to ensure credentials or token files are not silently missing.
Authentication — Which authentication modes are supported and how do I use them?
Central question: Which authentication modes does xurl support, and how do I perform each authentication?
Direct answer: xurl supports application-level bearer tokens, OAuth 2.0 user-context (PKCE-style flow via redirect to http://localhost:8080/callback
), and OAuth 1.0a. Use xurl auth app
, xurl auth oauth2
, or xurl auth oauth1
respectively; set credentials in environment variables or flags as shown in examples.
Summary: This section gives exact commands and the required prerequisites for each authentication method.
Prerequisites
-
A developer application in the X developer portal is required for OAuth flows and app tokens.
-
For OAuth 2.0 user-context, set the redirect URI to:
http://localhost:8080/callback
App (bearer token) authentication
-
Command:
xurl auth app --bearer-token BEARER_TOKEN
-
Use case: When you only need app-level access and have a bearer token available.
OAuth 2.0 user-context (PKCE-like flow)
-
Steps from the README:
-
Create an app in the X developer portal.
-
Set the redirect URI to:
http://localhost:8080/callback
(This allows the local CLI to receive the authorization callback.)
-
Export credentials:
export CLIENT_ID=your_client_id export CLIENT_SECRET=your_client_secret
-
Run the interactive flow:
xurl auth oauth2
-
-
Application scenario: Use this flow to obtain user-scoped tokens so the CLI can perform actions like posting tweets on behalf of that user.
Author’s reflection: Using a fixed localhost callback simplifies local development and the CLI flow — it sacrifices nothing for dev-time convenience and makes scripting the exchange straightforward.
OAuth 1.0a
-
Command:
xurl auth oauth1 --consumer-key KEY --consumer-secret SECRET --access-token TOKEN --token-secret SECRET
-
Application scenario: Keep OAuth1 support available for integrations that are still using legacy flows or tokens.
Token storage and security
-
Persistent storage location:
~/.xurl
-
Tokens and account metadata are stored under this path for reuse.
-
-
Operational guidance (from README): Back up or migrate the
~/.xurl
directory if you need to move credentials between machines.
Author’s reflection: Storing tokens in a standard location makes automation and recovery simpler; it also reminds you to control filesystem permissions and backups carefully.
Authentication management — How do I view and clear credentials?
Central question: How can I inspect, list, or remove stored authentication tokens?
Direct answer: Use xurl auth status
to view current status and xurl auth clear
with flags like --all
, --oauth1
, --oauth2-username USERNAME
, or --bearer
to remove tokens selectively.
Summary: Commands exist to check and clean authentication material; use them to avoid stale credentials and for test cleanup.
Common commands
-
View current authentication:
xurl auth status
-
Clear all stored tokens:
xurl auth clear --all
-
Clear OAuth 1.0a tokens:
xurl auth clear --oauth1
-
Clear a specific OAuth2 user:
xurl auth clear --oauth2-username USERNAME
-
Clear bearer token:
xurl auth clear --bearer
Application scenario: After finishing local testing with multiple accounts, run xurl auth clear --all
to remove credentials and avoid accidental use in CI or shared machines.
Making requests — How do I call X API endpoints with xurl?
Central question: How do I make GET, POST and custom HTTP requests with xurl, and how do I control headers, body, and authentication?
Direct answer: Place the API path after xurl
, use -X
to set the method, -d
to provide JSON body, -H
to add headers, and --auth
/--username
to control which credentials are used.
Summary: The README includes typical command patterns for basic GETs, JSON POSTs, custom headers, and specifying authentication.
Examples
-
Simple GET:
xurl /2/users/me
-
POST with JSON body:
xurl -X POST /2/tweets -d '{"text":"Hello world!"}'
-
Add custom header:
xurl -H "Content-Type: application/json" /2/tweets
-
Specify authentication type:
xurl --auth oauth2 /2/users/me xurl --auth oauth1 /2/tweets xurl --auth app /2/users/me
-
Specify saved OAuth2 account:
xurl --username johndoe /2/users/me
Application scenario: When automating a test that posts a tweet and then fetches the posting user, use xurl
with --auth oauth2
for the user-scoped token, send the POST with -d
, and then call /2/users/me
to verify the identity.
Author’s reflection: Treat xurl as a focused, scripted curl
for the X API: the interface mirrors typical CLI patterns so you can quickly swap from curl scripts to xurl with minimal changes.
Streaming responses — How does xurl handle streaming endpoints?
Central question: How does xurl detect and manage streaming endpoints, and how can I force streaming behavior?
Direct answer: xurl automatically recognizes a set of known stream endpoints (like /2/tweets/search/stream
) and enters stream mode; you can force streaming with -s
or --stream
.
Summary: Automatic detection simplifies consuming long-lived connections; forced streaming is available for custom use.
Known streaming endpoints
The README lists the following as stream endpoints that xurl will automatically treat as streams:
-
/2/tweets/search/stream
-
/2/tweets/sample/stream
-
/2/tweets/sample10/stream
-
/2/tweets/firehose/strea/lang/en
-
/2/tweets/firehose/stream/lang/ja
-
/2/tweets/firehose/stream/lang/ko
-
/2/tweets/firehose/stream/lang/pt
Commands
-
Automatic streaming:
xurl /2/tweets/search/stream
-
Force streaming:
xurl -s /2/users/me
Application scenario: For a monitoring tool that consumes the search stream in real time, simply call xurl /2/tweets/search/stream
and pipe output into your processor or file.
Author’s reflection: Automatic stream detection reduces boilerplate for developers. Being able to force streaming gives additional flexibility for experimental or custom endpoints.
Temporary webhook setup — How do I receive callbacks during local development?
Central question: How can I expose a local webhook endpoint and register it with the X API for testing?
Direct answer: Use xurl webhook start
to run a local webhook helper that uses ngrok to expose a public URL; register that URL with the API via an app-authenticated POST and observe incoming events in the specified output file.
Summary: The README documents a small workflow that integrates ngrok and the CLI to receive webhooks on localhost.
Step-by-step (as in README)
-
Start the local webhook helper (optionally specifying port and output log file):
xurl webhook start # or with port and output file xurl webhook start -p 8081 -o webhook_events.log
If ngrok authtoken is not already configured via
NGROK_AUTHTOKEN
, xurl will prompt for it or expect it to be set via environment variables. -
The helper produces a public ngrok URL (for example
https://your-unique-id.ngrok-free.app/webhook
) — copy that value. -
Register the webhook with app credentials:
xurl --auth app /2/webhooks -d '{"url": "<your ngrok url>"}' -X POST
-
Inspect received events in the output file (if
-o
was used) or in terminal output.
Application scenario: While building webhook handler logic locally, a developer can use xurl webhook start
to avoid deploying a staging server and iterate quickly on webhook parsing code.
Author’s reflection: Bundling ngrok into the webhook helper shortens the edit-test loop dramatically; it’s a practical design for developers who prefer local-first debugging.
Media upload — How do I upload images and large video files?
Central question: How can I upload media using xurl, and what is the chunked upload flow for large files?
Direct answer: For simple uploads use xurl media upload path/to/file
; for large files use the chunked upload flow: INIT → APPEND → FINALIZE → STATUS, issuing the corresponding xurl
commands with command
query params.
Summary: The README provides both a simplified upload command and the explicit chunked steps for robust large file handling.
Simplified upload
-
Command:
xurl media upload path/to/file.mp4
-
Custom media type and category:
xurl media upload --media-type image/jpeg --category tweet_image path/to/image.jpg
-
Check status:
xurl media status MEDIA_ID xurl media status --wait MEDIA_ID
Chunked upload flow
-
INIT — register total bytes, media type, and category:
xurl -X POST '/2/media/upload?command=INIT&total_bytes=FILE_SIZE&media_type=video/mp4&media_catefory=tweet_video'
Note: The README shows
media_catefory
as the parameter name. -
APPEND — upload a segment:
xurl -X POST -F path/to/file.mp4 '/2/media/upload?command=APPEND&media_id=MEDIA_ID&segment_index=0'
-
FINALIZE — mark the upload as complete:
xurl -X POST '/2/media/upload?command=FINALIZE&media_id=MEDIA_ID'
-
STATUS — poll for processing completion:
xurl '/2/media/upload?command=STATUS&media_id=MEDIA_ID'
Use case: post a tweet with uploaded media
-
Upload the media (via simplified or chunked flow), obtain
MEDIA_ID
. -
Post a tweet including the
MEDIA_ID
:xurl -X POST /2/tweets -d '{"text":"Check this out","media":{"media_ids":["MEDIA_ID"]}}'
Author’s reflection: Exposing chunked upload steps in the CLI makes automated media pipelines easier to debug and control; the README’s explicit INIT/APPEND/FINALIZE/STATUS sequence is the right primitive for engineering workflows.
Token storage — Where are tokens saved and how do I manage them?
Central question: Where does xurl store tokens, and what should I know about managing that storage?
Direct answer: Tokens are persisted in the user home directory under ~/.xurl
; copy that directory to migrate or back up tokens and use xurl auth clear
to remove credentials when needed.
Summary: Knowing token location helps with backups, migrations, and cleanup.
Practical notes
-
Path: ~/.xurl
-
To backup: copy the ~/.xurl
folder to a secure location. -
To clean: use xurl auth clear
variants.
Author’s reflection: A single known location balances convenience and operational transparency, but it signals the need to secure that directory (filesystem permissions, restricted backups).
Common workflows — Practical end-to-end examples
Central question: How do I assemble the commands into realistic workflows for everyday tasks?
Direct answer: The README provides three worked flows: (A) post a tweet with media, (B) receive webhook events locally via ngrok, and (C) listen to a streaming search endpoint. Each flow is given as sequential commands that can be run verbatim.
Summary: Use these three example flows as templates for scripting or CI jobs.
Workflow A — Post a tweet with an image
-
Authenticate as a user:
export CLIENT_ID=your_client_id export CLIENT_SECRET=your_client_secret xurl auth oauth2
-
Upload the image:
xurl media upload --media-type image/jpeg --category tweet_image path/to/image.jpg # Assume command returns MEDIA_ID
-
Post the tweet:
xurl -X POST /2/tweets -d '{"text":"Photo upload test","media":{"media_ids":["MEDIA_ID"]}}'
Application scenario: QA automation or developer testing where you need to verify the end-to-end posting experience including media attachments.
Workflow B — Local webhook debugging
-
Start webhook helper with ngrok:
xurl webhook start -p 8081 -o webhook_events.log
-
Register webhook:
xurl --auth app /2/webhooks -d '{"url": "<your ngrok url>"}' -X POST
-
Observe events in
webhook_events.log
.
Application scenario: Rapid development of webhook parsing and validation logic without deploying to a remote server.
Workflow C — Listen to a search stream
xurl /2/tweets/search/stream
Application scenario: Real-time data capture for monitoring, alerts, or sampling tweet content from a search stream.
Author’s reflection: These workflows show how the CLI commands chain naturally: auth → resource preparation (upload) → action (post) for media; webhook helper → registration → validation for callbacks; simple direct call for stream consumption.
Command cheat sheet — Quick reference table
Central question: What are the most commonly used xurl commands I should remember?
Direct answer: The table below condenses the README’s primary commands and their purpose for quick lookup.
Summary: Keep this cheat sheet as a clipboard-friendly reference while scripting or debugging.
Command sample | Purpose | |
---|---|---|
`curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | sudo bash` | Install xurl |
xurl auth app --bearer-token BEARER_TOKEN |
App bearer token auth | |
export CLIENT_ID=... |
Set OAuth2 client id | |
xurl auth oauth2 |
Start OAuth2 user-context flow | |
xurl auth oauth1 --consumer-key ... |
OAuth1.0a auth | |
xurl auth status |
Show authentication status | |
xurl auth clear --all |
Clear all tokens | |
xurl /2/users/me |
Simple GET request | |
xurl -X POST /2/tweets -d '{"text":"..."}' |
POST request (post tweet example) | |
xurl -H "Content-Type: application/json" /2/tweets |
Add header | |
xurl --auth oauth2 /2/users/me |
Specify auth type | |
xurl --username johndoe /2/users/me |
Use specific OAuth2 account | |
xurl /2/tweets/search/stream |
Listen to search stream | |
xurl webhook start -p 8081 -o webhook_events.log |
Start webhook helper w/ ngrok | |
xurl --auth app /2/webhooks -d '{"url":"..."}' -X POST |
Register webhook | |
xurl media upload path/to/file.mp4 |
Simplified media upload | |
xurl -X POST '/2/media/upload?command=INIT&...' |
Media INIT | |
xurl -X POST -F path/to/file.mp4 '/2/media/upload?command=APPEND&...' |
Media APPEND | |
xurl -X POST '/2/media/upload?command=FINALIZE&media_id=...' |
Media FINALIZE | |
xurl '/2/media/upload?command=STATUS&media_id=...' |
Media STATUS | |
~/.xurl |
Token storage location |
Code snippets & practical shell fragments
Central question: What ready-to-run command snippets does the README provide?
Direct answer: The README contains copy-pasteable examples for installing, authenticating, posting, streaming, starting webhooks, and chunked media uploads; paste them into a shell to run.
Summary: Use these snippets as-is or embed them into scripts.
Installation
curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | sudo bash
OAuth2 authentication
export CLIENT_ID=your_client_id
export CLIENT_SECRET=your_client_secret
xurl auth oauth2
Post a tweet
xurl -X POST /2/tweets -d '{"text":"Hello world!"}'
Chunked upload sequence
# INIT
xurl -X POST '/2/media/upload?command=INIT&total_bytes=FILE_SIZE&media_type=video/mp4&media_catefory=tweet_video'
# APPEND (segment 0)
xurl -X POST -F path/to/file.mp4 '/2/media/upload?command=APPEND&media_id=MEDIA_ID&segment_index=0'
# FINALIZE
xurl -X POST '/2/media/upload?command=FINALIZE&media_id=MEDIA_ID'
# STATUS
xurl '/2/media/upload?command=STATUS&media_id=MEDIA_ID'
Author’s reflection: Having these canonical snippets reduces context switching and speeds up writing reproducible scripts or small automation tasks.
Practical checklist — Actionable implementation steps
Central question: What immediate steps should I follow to start using xurl for common tasks?
Direct answer: Install xurl, set up credentials and redirect URI if using OAuth2, authenticate, verify xurl auth status
, then run the workflow that matches your goal (post with media, webhook testing, or stream consumption).
Summary: Follow the checklist below to get from zero to a working flow.
Action checklist
-
Install xurl:
curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | sudo bash
-
If using OAuth2 user-context: create an app in the developer portal and set the redirect URI to
http://localhost:8080/callback
. -
Export client credentials (if applicable):
export CLIENT_ID=your_client_id export CLIENT_SECRET=your_client_secret
-
Authenticate:
-
App: xurl auth app --bearer-token BEARER_TOKEN
-
OAuth2: xurl auth oauth2
-
OAuth1: xurl auth oauth1 --consumer-key ...
-
-
Confirm authentication:
xurl auth status
-
Execute your workflow (examples):
-
Post with media: upload → post tweet with MEDIA_ID
. -
Webhook dev: xurl webhook start
→ register webhook → inspect logs. -
Stream: xurl /2/tweets/search/stream
.
-
-
Clean up test credentials when done:
xurl auth clear --all
-
Backup or secure
~/.xurl
as needed.
One-page overview — Essentials at a glance
Central question: Can you summarize the CLI and the most important commands in one page?
Direct answer: xurl is a command-line tool for interacting with the X API; install with the single-line script, authenticate with xurl auth ...
, make requests by calling xurl <endpoint>
with -X
,-d
,-H
flags, manage streams with automatic detection or -s
, start a webhook helper with xurl webhook start
, and upload media either with xurl media upload
or the chunked INIT/APPEND/FINALIZE/STATUS flow. Tokens live in ~/.xurl
.
Summary: Keep the cheat sheet and action checklist nearby; use the workflows for common tasks.
Frequently Asked Questions (FAQ)
Central question: What common questions does the README answer about xurl usage?
Direct answer: The FAQ below distills likely operational questions and answers based only on the information in the README.
Summary: Use the FAQ for quick clarifications while using the tool.
-
Q: How do I install xurl?
A: Run the one-line installer:curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | sudo bash
-
Q: What redirect URI should I set for OAuth2?
A: Set the redirect URI to:http://localhost:8080/callback
-
Q: How do I upload an image and reference it in a tweet?
A: Usexurl media upload path/to/image.jpg
to obtain aMEDIA_ID
, then post:xurl -X POST /2/tweets -d '{"text":"Photo upload test","media":{"media_ids":["MEDIA_ID"]}}'
-
Q: Where are tokens stored?
A: Tokens are stored in the~/.xurl
directory in the user’s home. -
Q: Will xurl automatically handle streaming endpoints?
A: Yes — xurl automatically recognizes a set of stream endpoints (e.g.,/2/tweets/search/stream
) and enters stream mode. Use-s
to force streaming behavior. -
Q: How do I debug webhooks locally?
A: Run:xurl webhook start -p 8081 -o webhook_events.log
Then register the provided ngrok URL with the API via:
xurl --auth app /2/webhooks -d '{"url": "<your ngrok url>"}' -X POST
Inspect
webhook_events.log
for events. -
Q: How do I clear saved authentication tokens?
A: Usexurl auth clear
with flags:xurl auth clear --all xurl auth clear --oauth1 xurl auth clear --oauth2-username USERNAME xurl auth clear --bearer