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 from PyPI:
pip install xcli-v2- 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 loginOptional: 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.jpgCurrently 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.
xcli auth loginxcli auth whoamixcli auth statusxcli auth logoutxcli composexcli postxcli reply --to <tweet_id>xcli quote --to <tweet_id>xcli posts minexcli posts mine --replies falsexcli posts get --id <tweet_id>xcli timeline --user <handle>xcli timeline --user <handle> --replies false
- 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.
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.
pip install -e .[dev]
pytest
ruff check
mypy src