Skip to main content

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

  1. 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.

  1. 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
  1. Draft content:
xcli compose "shipping small daily"
  1. Post from terminal text (default):
xcli post "shipping small daily"
  1. Preview without posting:
xcli post "shipping small daily" --dry-run
  1. Post from file:
xcli post --file draft.txt
  1. Attach media (repeat --media up to 4 files):
xcli post "launch day" --media image1.png --media image2.jpg
  1. 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 login
  • xcli auth whoami
  • xcli auth status
  • xcli auth logout
  • xcli compose
  • xcli post
  • xcli post --video <file> --srt <file>
  • xcli reply --to <tweet_id>
  • xcli quote --to <tweet_id>
  • xcli posts mine
  • xcli posts mine --replies false
  • xcli posts get --id <tweet_id>
  • xcli posts get --url <post_url>
  • xcli posts get --id <tweet_id> --md --out post.md
  • xcli profile <handle>
  • xcli timeline --user <handle>
  • xcli timeline --user <handle> --replies false

Safety model

  • Posting commands send by default (with confirmation prompt).
  • Use --dry-run to 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)

Source distribution for xcli-v2 0.1.9
File Size Uploaded
xcli_v2-0.1.9.tar.gz 68.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xcli-v2 0.1.9
File Interpreter ABI Platform
xcli_v2-0.1.9-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page