Open-source CLI for composing and publishing X posts
Project description
xcli
xcli is a command line tool for interacting with the X API.
It is designed for local-first usage, safe publishing defaults, and open-source packaging.
Install
Install from PyPI:
pip install xcli-v2
Quickstart
- Set OAuth app credentials:
export TWITTER_CLIENT_ID="..."
export TWITTER_CLIENT_SECRET="..."
Set your app callback/redirect URL to http://localhost:3000/callback.
If needed, override in the CLI with XCLI_REDIRECT_URI.
- Run login flow (prints an auth URL you can open manually):
xcli auth login
Optional: attempt auto-open in your default browser:
xcli auth login --open-browser
- Draft content:
xcli compose "shipping small daily"
- Post from terminal text (default):
xcli post "shipping small daily"
- Preview without posting:
xcli post "shipping small daily" --dry-run
- Post from file:
xcli post --file draft.txt
- Attach media (repeat
--mediaup to 4 files):
xcli post "launch day" --media image1.png --media image2.jpg
- Post a video with subtitle sidecar:
xcli post --video clip.mp4 --srt clip.srt
Optional post text:
xcli post "launch clip" --video clip.mp4 --srt clip.srt
Currently supported media types are image uploads accepted by the X media upload endpoint (jpeg, png, webp, bmp, tiff).
Media upload requires OAuth scope media.write; if you logged in before this was added,
run xcli auth login again to refresh token scopes.
For --video, supported formats are .mp4, .m4v, .mov, .webm, and .ts.
For --srt, supported subtitle formats are .srt and .vtt.
--video and --srt must be used together and cannot be combined with --media.
Commands
xcli auth loginxcli auth whoamixcli auth statusxcli auth logoutxcli composexcli postxcli post --video <file> --srt <file>xcli reply --to <tweet_id>xcli quote --to <tweet_id>xcli posts minexcli posts mine --replies falsexcli posts get --id <tweet_id>xcli posts get --url <post_url>xcli posts get --id <tweet_id> --md --out post.mdxcli timeline --user <handle>xcli timeline --user <handle> --replies false
Safety model
- Posting commands send by default (with confirmation prompt).
- Use
--dry-runto preview payload without posting. - Non-interactive workflows can use
--yes. - Machine output is available with
--json.
Auth storage
Default token path uses platform config directories:
- macOS:
~/Library/Application Support/xcli/auth.json - Linux:
~/.config/xcli/auth.json - Windows:
%APPDATA%\\xcli\\auth.json
Legacy compatibility fallback is supported for ~/.twitter/auth.json.
Development
pip install -e .[dev]
pytest
ruff check
mypy src
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xcli_v2-0.1.3.tar.gz.
File metadata
- Download URL: xcli_v2-0.1.3.tar.gz
- Upload date:
- Size: 66.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04dd478c5a552b3a4133d4544d7274425fb2b5fffa472b2b9dd6d66b7ea8bb90
|
|
| MD5 |
43e28cd94587d5a6d2cfe0a5b79e6fbc
|
|
| BLAKE2b-256 |
0aac738066426ae6dd307c2368b33b22879a935685aca79dcfb5610a68652f7c
|
File details
Details for the file xcli_v2-0.1.3-py3-none-any.whl.
File metadata
- Download URL: xcli_v2-0.1.3-py3-none-any.whl
- Upload date:
- Size: 26.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4d6234c753cc9881c7633512de5a912a78b1e80f9535509d33f501078e4bb19
|
|
| MD5 |
65e3f6c39588f6ee3e39408471f8d196
|
|
| BLAKE2b-256 |
b695a64b3ac67486323bf3eae57b3a159c7f965c20185938024f9b19a4d61743
|