Skip to content

Latest commit

ย 

History

History
415 lines (315 loc) ยท 13.3 KB

File metadata and controls

415 lines (315 loc) ยท 13.3 KB

๐Ÿ“ฑ SocialCLI

Unified social media CLI โ€” publish, search, and grow across all platforms.

One command. Multiple platforms. Zero API keys required.

Python License Tests Platforms

Install ยท Quick Start ยท Platforms ยท Commands ยท AI Features ยท License


Why

Social media managers juggle 5+ platforms daily. Existing tools either cost $50+/month, require complex API applications, or only support a few platforms.

SocialCLI takes a different approach:

  • No API keys โ€” uses browser cookie extraction and reverse-engineered APIs
  • No monthly fees โ€” open source, runs on your machine
  • Instant login โ€” extracts cookies from your Chrome/Firefox, no browser popups
  • Cross-platform publish โ€” one command posts to Reddit + Twitter simultaneously
  • All major platforms โ€” Chinese + international, one unified interface
  • AI-powered โ€” generate platform-optimized content from a single topic

Supported Platforms

Fully Working โœ…

Platform Login Search Trending Publish
๐Ÿ“– Reddit โœ… Instant โœ… โœ… โœ… Verified
๐Ÿฆ Twitter/X โœ… Instant โœ… โœ… โœ… Verified
๐Ÿ“บ Bilibili (B็ซ™) โœ… Instant โœ… โœ… ๐Ÿ”ง Playwright

Login + Partial API

Platform Login Search Trending Notes
๐Ÿ“• Xiaohongshu (ๅฐ็บขไนฆ) โœ… Instant ๐Ÿ”ง โ€” API signing integrated (xhshow)
๐Ÿ’ผ LinkedIn โœ… Instant ๐Ÿ”ง โ€” Voyager API auth verified
๐ŸŽฌ Douyin (ๆŠ–้Ÿณ) ๐Ÿ”ง ๐Ÿ”ง ๐Ÿ”ง Needs anti-crawl signatures
๐ŸŽต TikTok ๐Ÿ”ง ๐Ÿ”ง ๐Ÿ”ง Needs signatures
๐Ÿ”ฅ Weibo (ๅพฎๅš) ๐Ÿ”ง ๐Ÿ”ง ๐Ÿ”ง Skeleton
โšก Kuaishou (ๅฟซๆ‰‹) ๐Ÿ”ง ๐Ÿ”ง ๐Ÿ”ง Skeleton
โ–ถ๏ธ YouTube ๐Ÿ”ง ๐Ÿ”ง ๐Ÿ”ง Skeleton
๐Ÿ“˜ Facebook ๐Ÿ”ง โ€” โ€” Skeleton
๐Ÿ“ท Instagram ๐Ÿ”ง โ€” โ€” Skeleton
๐Ÿงต Threads ๐Ÿ”ง โ€” โ€” Skeleton

โœ… Instant Login: Uses browser-cookie3 to extract cookies from your local browser โ€” zero manual input, instant auth.

Install

# From source (recommended for now)
git clone https://github.com/Youhai020616/socialcli.git
cd socialcli
pip install -e ".[all]"
playwright install chromium

Optional extras:

pip install -e ".[browser]"    # Instant login from Chrome cookies
pip install -e ".[twitter]"    # Twitter GraphQL (curl_cffi + TLS fingerprint)
pip install -e ".[all]"        # Everything (browser + twitter + AI)

Quick Start

# 1. Login โ€” instant, extracts from your Chrome
social login reddit
social login twitter
social login bilibili

# 2. Check accounts
social accounts
social accounts --check    # Verify cookies still valid

# 3. Search across platforms
social reddit search "python programming" -n 5
social twitter search "AI tools" -n 5
social bilibili search "็ผ–็จ‹ๆ•™็จ‹" -n 5

# 4. Check what's trending
social trending -p reddit,twitter,bilibili -n 5

# 5. Publish to multiple platforms at once
social publish "My new blog post! ๐Ÿš€" \
  -t "Check This Out" \
  -p reddit,twitter \
  -r programming

# 6. Preview without posting
social publish "Test" -p reddit,twitter,bilibili --dry-run

Commands

Cross-Platform

Command Description
social publish Publish to one or all platforms (parallel)
social trending Aggregated trending from multiple platforms
social login Login to a platform (instant from browser cookies)
social logout Remove saved credentials
social accounts List logged-in accounts (--check to verify)
social history View publish history
social schedule Manage scheduled posts
social config View and set configuration
social batch Batch publish from CSV, JSON, or directory
social monitor Watch keywords across platforms
social ai AI content generation and adaptation

Per-Platform

social <platform> search <query>     # Search
social <platform> trending           # Platform trending
social <platform> publish [options]  # Platform-specific publish

Usage

Publish

# Single platform
social publish "Hello World!" -p twitter

# Multiple platforms (publishes in parallel)
social publish "Cross-post this!" -t "My Title" -p reddit,twitter -r programming

# From Markdown file
social publish -f post.md -p reddit,twitter --dry-run

# With images, tags, and link
social publish "Check this out!" \
  -i photo1.jpg -i photo2.jpg \
  --tags "coding,AI,startup" \
  --link https://myblog.com \
  -p twitter,reddit

# Reddit with subreddit
social publish "Look what I built" \
  -p reddit -r programming \
  -t "Show HN: SocialCLI"

# Schedule for later
social publish "Good morning! โ˜€๏ธ" \
  -p twitter \
  --schedule "2026-04-01T09:00:00"

# Preview without posting
social publish "Test" -p all --dry-run

Content is automatically adapted per platform:

  • Twitter: title merged into text, truncated to 280 chars, hashtags appended
  • Reddit: title and body kept separate, Markdown format, subreddit targeting
  • Bilibili: video-first, tags formatted for B็ซ™
  • Xiaohongshu: image-first, emoji, ็ง่‰ style

Search

social reddit search "rust vs go" -r programming --sort top
social twitter search "AI startups" -n 10 --json
social bilibili search "็ผ–็จ‹ๆ•™็จ‹" -n 5 --json

Trending

# Aggregated from multiple platforms
social trending -p reddit,twitter,bilibili -n 10

# JSON output
social trending -p twitter --json

# Single platform
social reddit trending -n 5
social twitter trending -n 5
social bilibili trending -n 5

History

# View recent publishes
social history

# Filter by platform
social history -p reddit -n 10

# JSON output
social history --json

Schedule

# Schedule a post
social publish "Scheduled post" -p twitter --schedule "2026-04-01T09:00:00"

# List scheduled tasks
social schedule list

# Execute due tasks
social schedule run

# Remove a task
social schedule remove <task-id>

Batch Publish

# From CSV
social batch posts.csv

# From JSON
social batch posts.json --dry-run

# From directory (each .md file = one post)
social batch ./content/ -p twitter,reddit

CSV format:

platform,title,content,image,video,tags,subreddit
twitter,,Hello from CSV!,photo.jpg,,coding,
reddit,My Post,Post body in Markdown,,,python,programming

Monitor

# Monitor keywords across platforms
social monitor -k "my-product,my-brand" -p twitter,reddit

# With interval
social monitor -k "AI tools" -p reddit -n 10 -i 120

AI Features

Generate and adapt content using OpenAI-compatible APIs:

# Setup
social config set ai_api_key sk-xxx
social config set ai_model gpt-4o-mini

# Generate content for multiple platforms
social ai generate "AI coding tools" -p twitter,reddit,xhs

# Adapt existing content for a platform
social ai adapt "My long article about..." -p twitter

# Suggest hashtags
social ai tags "My post about web development" -p twitter

Login

SocialCLI extracts cookies from your local browser โ€” no password entry needed.

social login reddit       # Instant โ€” reads Chrome cookies
social login twitter      # Instant โ€” reads Chrome cookies
social login bilibili     # Instant โ€” reads Chrome cookies
social login xhs          # Instant โ€” reads Chrome cookies
social login linkedin     # Instant โ€” reads Chrome cookies

social accounts           # View all logged-in accounts
social accounts --check   # Verify cookies are still valid
social logout reddit      # Remove saved cookies

How it works: If you're logged into Reddit/Twitter/etc. in your Chrome browser, SocialCLI extracts those cookies instantly. No browser popup, no QR code, no password. Falls back to Playwright browser login if extraction fails.

Cookies are stored locally at ~/.socialcli/accounts/.

Configuration

social config show                                    # View all settings
social config set default_platforms twitter,reddit     # Set defaults
social config set ai_api_key sk-xxx                   # AI API key
social config set ai_model gpt-4o-mini                # AI model
social config unset ai_api_key                        # Remove a setting

Config stored at ~/.socialcli/config.json.

Architecture

socialcli/
โ”œโ”€โ”€ platforms/                    # Platform adapters (13 platforms)
โ”‚   โ”œโ”€โ”€ base.py                   #   Platform ABC + data models + browser cookie extraction
โ”‚   โ”œโ”€โ”€ registry.py               #   Auto-discovery registry
โ”‚   โ”œโ”€โ”€ reddit/client.py          #   Cookie auth + modhash + JSON API
โ”‚   โ”œโ”€โ”€ twitter/client.py         #   GraphQL + curl_cffi + x-client-transaction-id
โ”‚   โ”œโ”€โ”€ bilibili/client.py        #   Public API + Playwright upload
โ”‚   โ”œโ”€โ”€ xiaohongshu/client.py     #   xhshow signing + Playwright
โ”‚   โ””โ”€โ”€ ...                       #   7 more platform adapters
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ publisher.py              #   Parallel multi-platform publish (ThreadPoolExecutor)
โ”‚   โ”œโ”€โ”€ content_adapter.py        #   Auto-format content per platform (13 rule sets)
โ”‚   โ”œโ”€โ”€ scheduler.py              #   Scheduled publishing (JSON storage)
โ”‚   โ”œโ”€โ”€ ai_writer.py              #   AI content generation (OpenAI-compatible)
โ”‚   โ”œโ”€โ”€ batch.py                  #   Batch operations (CSV/JSON/directory)
โ”‚   โ””โ”€โ”€ monitor.py                #   Keyword monitoring
โ”œโ”€โ”€ auth/
โ”‚   โ”œโ”€โ”€ browser_login.py          #   Playwright browser login (fallback)
โ”‚   โ””โ”€โ”€ cookie_store.py           #   Cookie persistence (~/.socialcli/accounts/)
โ”œโ”€โ”€ commands/                     #   12 Click CLI commands
โ””โ”€โ”€ tests/                        #   112 tests (10 test files)

How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  social CLI       โ”‚  โ† You type commands
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  browser-cookie3  โ”‚  โ† Extracts cookies from Chrome/Firefox (instant)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Content Adapter  โ”‚  โ† Adapts content per platform rules
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Parallel Publisher (ThreadPool)      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚ Reddit  โ”‚ โ”‚ Twitter โ”‚ โ”‚Bilibiliโ”‚ โ”‚  โ† Simultaneous publish
โ”‚  โ”‚ JSON APIโ”‚ โ”‚ GraphQL โ”‚ โ”‚ Public โ”‚ โ”‚     Cookie-based auth
โ”‚  โ”‚ +modhashโ”‚ โ”‚+curl_cffiโ”‚ โ”‚  API  โ”‚ โ”‚     No official APIs
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Comparison

SocialCLI AiToEarn Buffer Hootsuite
Type CLI Desktop App Web SaaS Web SaaS
Platforms 13 14 6 6
API Required No No Yes Yes
Price Free (OSS) Free (OSS) $6-120/mo $99-739/mo
Parallel Publish โœ… โŒ โœ… โœ…
Server Deploy โœ… โŒ โœ… โœ…
AI Content โœ… โœ… โœ… โœ…
Open Source โœ… โœ… โŒ โŒ
Install pip install Desktop Browser Browser
Login Method Cookie extract Browser OAuth OAuth

Development

# Setup
git clone https://github.com/Youhai020616/socialcli.git
cd socialcli
pip install -e ".[all,dev]"
playwright install chromium

# Run tests
pytest -m "not flaky_network"     # 109 stable tests
pytest                            # All 112 tests

# Smoke test
social --help
social login reddit
social reddit search "python" -n 3 --json
social publish "Test" -p reddit --dry-run

Contributing

Contributions are welcome! To add a new platform:

  1. Create platforms/<name>/client.py extending Platform base class
  2. Set cookie_domain and required_cookies for browser cookie extraction
  3. Implement login, check_login, publish, search
  4. Add cli_group property with Click subcommands
  5. Register in platforms/<name>/__init__.py
  6. Add to registry.load_all() and content_adapter.PLATFORM_RULES
  7. Write tests

Disclaimer

This tool is for educational and personal use. When using SocialCLI to interact with any social media platform, you must comply with that platform's Terms of Service. Any account restrictions or bans resulting from the use of this tool are the user's own responsibility.

License

MIT