threads-cli is a terminal-first CLI for personal Threads workflows.
It separates unofficial read workflows from official publishing workflows:
- Reads use your own authenticated Threads/Instagram web session and unofficial Instagram private endpoints.
- Canonical post commands use the official Threads API with OAuth access tokens.
- The CLI emits
sns-json-v1JSON for AI agents and Skim.
This repository is an early golden-template clone of linkedin-cli.
Implemented and covered by focused tests:
threads-cli auth-statusthreads-cli auth status --jsonthreads-cli auth cookie-file --from-stdinthreads-cli read feed --limit 5 --jsonthreads-cli read feed --user-id 12345 --limit 5 --jsonthreads-cli read thread https://www.threads.net/@aiden/post/ABC123 --jsonthreads-cli post text --text "..." --dry-run --jsonthreads-cli post text --text "..." --jsonthreads-cli post media --text "..." --media-url "https://..." --jsonsns-json-v1success/error envelopes
Live publishing requires a valid Threads API token and should only be run after dry-run review.
- This project is not affiliated with Meta, Instagram, or Threads.
- Read commands are unofficial and rely on private endpoint behavior. Review the terms that apply to your account.
- Canonical post commands are designed around official Threads publishing APIs.
- Session cookies and OAuth tokens are credentials. Treat them like passwords.
- Do not use this project for spam, bulk scraping, engagement loops, or anything that violates platform rules.
uv syncRead commands resolve cookies from:
THREADS_COOKIE_HEADERTHREADS_COOKIE_FILEor~/.config/threads/cookies.envTHREADS_READ_SESSION_FILE~/.config/threads/read-session.json
The cookie file stores a shell-quoted THREADS_COOKIE_HEADER line with 0600 permissions. Create it without saving the raw cookie header in shell history:
uv run threads-cli auth cookie-file --from-stdinPaste the one-line Threads/Instagram Cookie header, press Return, then press Control+D.
The read-session file uses Playwright storage_state JSON shape.
Verify read auth before extraction:
uv run threads-cli auth status --json
uv run threads-cli auth-statusauth status --json reports cookie presence in sns-json-v1. auth-status also runs a live timeline probe. Neither command prints raw cookie values.
Post commands resolve OAuth credentials from:
THREADS_ACCESS_TOKEN+THREADS_USER_IDTHREADS_OAUTH_FILE~/.config/threads/oauth.json
Token file shape:
{
"access_token": "...",
"user_id": "12345",
"graph_version": "v1.0"
}uv run threads-cli auth-status
uv run threads-cli auth status --json
uv run threads-cli auth cookie-file --from-stdin
uv run threads-cli read feed --limit 10 --json
uv run threads-cli read feed --limit 10 --user-id 12345 --json
uv run threads-cli read thread https://www.threads.net/@aiden/post/ABC123 --json
uv run threads-cli read thread 987654321 --json
uv run threads-cli post text --text "hello from threads-cli" --dry-run --json
uv run threads-cli post text --text "hello from threads-cli" --json
uv run threads-cli post media --text "hello with image" --media-url "https://example.com/image.jpg" --jsonread thread accepts a Threads post URL or numeric media id. URL extraction reads the Threads web page and looks for embedded post JSON. Numeric id extraction uses the private Instagram media info endpoint.
uv run pytest -q
uv run ruff check .
uv run python -m compileall threads_cli tests