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 profile <handle>xcli 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
Metadata
Release files for xcli-v2 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xcli_v2-0.1.9.tar.gz | 68.7 kB | Without provenance | Details for xcli_v2-0.1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xcli_v2-0.1.9-py3-none-any.whl | Python 3 | none | any | Details for xcli_v2-0.1.9-py3-none-any.whl |
Total release size: 96.5 kB
Release files / xcli_v2-0.1.9.tar.gz
| Download URL | xcli_v2-0.1.9.tar.gz |
|---|---|
| Size | 68.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e066faf4623306c649c518007e5209847e69a5752b4dff5ec323fdf45e64e9a9
|
|
BLAKE2b-256 checksum How to use checksums |
c7ba109c7652ee2b066a762a9574f21eac43a1aed2b9dde7ccd9bc395c8ca105
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|
Release files / xcli_v2-0.1.9-py3-none-any.whl
| Download URL | xcli_v2-0.1.9-py3-none-any.whl |
|---|---|
| Size | 27.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68e845125ccdff6e02efe376f4b1bcf70bdf2cfd5f6214922eace80f26a28310
|
|
BLAKE2b-256 checksum How to use checksums |
669e3df39e4a8438ce69ed4afb8ab43ff5dcd06194cf3f03e213f0ab85f33896
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|
Security for xcli-v2 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.