Skip to content

Fast Threads CLI for reading, posting, and engagement

Notifications You must be signed in to change notification settings

jeizzon/yarn-threads-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yarn-threads-cli

A fast, lightweight CLI for Threads β€” read posts, browse profiles, search users, and more from your terminal.

yarn-threads whoami
# Jeizzon Mendes @jeizzon.mp4
# βœ… Authenticated successfully

yarn-threads about zuck
# Mark Zuckerberg @zuck
# βœ”οΈ Verified
# πŸ“‹ Mostly superintelligence and MMA takes
# 5,444,367 followers | 460 following

yarn-threads user-posts zuck
# Posts by @zuck (15):
# Today we're establishing a new top-level initiative called Meta Compute...

Features

  • Read posts β€” Fetch any thread by URL or shortcode
  • Browse profiles β€” View user info, posts, followers, following
  • Search users β€” Find accounts by name or handle
  • View likes β€” See your liked posts
  • Replies β€” Get reply threads for any post
  • Cookie-based auth β€” Uses your existing browser session (no OAuth needed)
  • Multiple output formats β€” Human-friendly, plain text, or JSON

Installation

npm install -g yarn-threads-cli

From Source

git clone https://github.com/jeizzon/yarn-threads-cli.git
cd yarn-threads-cli
npm install
npm run build
npm link

Authentication

yarn-threads-cli uses cookies from your browser to authenticate with Threads. You must be logged into Threads in your browser.

Option 1: Chrome Profile (Recommended)

# Use default Chrome profile
yarn-threads whoami

# Use a specific Chrome profile directory
yarn-threads --chrome-profile-dir "/path/to/chrome/profile/Default" whoami

# Use Chrome profile by name
yarn-threads --chrome-profile "Profile 1" whoami

Option 2: Firefox Profile

yarn-threads --firefox-profile "default-release" whoami

Option 3: Manual Cookies

yarn-threads --session-id "YOUR_SESSION_ID" --csrf-token "YOUR_CSRF_TOKEN" whoami

Or via environment variables:

export THREADS_SESSION_ID="..."
export THREADS_CSRF_TOKEN="..."
yarn-threads whoami

Cookie Extraction

The CLI automatically extracts cookies from Safari, Chrome, and Firefox. On macOS, it uses the system keychain to decrypt Chrome cookies.

Commands

whoami β€” Show authenticated user

yarn-threads whoami
yarn-threads whoami --json

about <handle> β€” Get user profile

yarn-threads about zuck
yarn-threads about @mosseri
yarn-threads about 314216 --json  # by user ID

user-posts <handle> β€” Get user's posts

yarn-threads user-posts zuck
yarn-threads user-posts mosseri --limit 5

read <url-or-code> β€” Fetch a single post

yarn-threads read https://www.threads.net/@zuck/post/DTa3-B1EbTp
yarn-threads read DTa3-B1EbTp  # shortcode only
yarn-threads read 3812345678901234567  # post ID

replies <url-or-code> β€” Get replies to a post

yarn-threads replies https://www.threads.net/@zuck/post/DTa3-B1EbTp
yarn-threads replies DTa3-B1EbTp --limit 10

thread <url-or-code> β€” Full thread (post + replies)

yarn-threads thread https://www.threads.net/@zuck/post/DTa3-B1EbTp

search <query> β€” Search for users

yarn-threads search "design"
yarn-threads search "AI" --limit 20

Note: Search returns users, not posts (Instagram API limitation).

likes β€” Get your liked posts

yarn-threads likes
yarn-threads likes --limit 50

followers <handle> β€” Get user's followers

yarn-threads followers zuck
yarn-threads followers zuck --limit 100

following <handle> β€” Get user's following list

yarn-threads following zuck
yarn-threads following jeizzon.mp4 --limit 50

Output Formats

Default (Human-Friendly)

yarn-threads about zuck

Plain (No Emoji, No Color)

yarn-threads about zuck --plain

JSON

yarn-threads about zuck --json

Configuration

Create ~/.config/yarn/config.json5:

{
  // Chrome profile directory (full path)
  chromeProfileDir: "/Users/you/.clawdbot/browser/clawd/user-data/Default",
  
  // Or Chrome profile name
  chromeProfile: "Default",
  
  // Firefox profile name
  firefoxProfile: "default-release",
  
  // Request timeout (ms)
  timeoutMs: 30000,
  
  // Cookie extraction timeout (ms)
  cookieTimeoutMs: 5000,
}

Environment Variables

Variable Description
THREADS_SESSION_ID Session cookie value
THREADS_CSRF_TOKEN CSRF token cookie value
THREADS_USER_ID User ID cookie value
NO_COLOR Disable colored output

Current Limitations

Unavailable Commands

Command Status Reason
home ❌ Home timeline requires app-level authentication
saved ❌ Saved posts endpoint not publicly accessible

Search Limitations

  • Search returns users only β€” The Instagram mobile API doesn't expose post search. Use the Threads web app for searching posts.

Rate Limits

  • The Instagram API may rate-limit requests if you make too many in a short period.
  • If you encounter errors, wait a few minutes before retrying.

Cookie Expiration

  • Session cookies expire periodically. If authentication fails, log into Threads in your browser again.

How It Works

yarn-threads-cli uses the Instagram mobile API (i.instagram.com) with your browser session cookies. This is the same API that the Threads mobile app uses.

Why not the official Threads API?

The official Threads API requires:

  • Meta developer app registration
  • OAuth flow for authentication
  • Access token management

The cookie-based approach works with your existing browser session β€” no app registration needed.

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Watch mode
npm run dev

Credits

Inspired by bird (Twitter/X CLI) and threads-api.

License

MIT

About

Fast Threads CLI for reading, posting, and engagement

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published