Skip to main content
Glama
molkex

threads-private-api

by molkex

threads-private-api

Unofficial Threads Private API & Trend Radar SDK for Python and TypeScript. High-performance headless protocol engine for Threads (com.instagram.barcelona). Sub-80ms real-time keyword search, full nested discussion tree ingestion, external thread replies, and zero residential proxy cost.

Ingestion: Sub-80ms Ingestion TypeScript: Full Types Python: >=3.10 Proxies: Zero Residential Needed Protocol: GraphQL & Mobile REST Telegram Contact

Companion Project: Looking for full Instagram mobile automation, DM outreach, warmup loops, and Reels publishing? Check out instagram-private-api — Pure HTTP/2 zero-device engine with authentic Android 14 / iOS 17 JA4 TLS 1.3 signatures.


Why this instead of Official Threads API or Playwright

Feature

Official Threads API (graph.threads.net)

Browser Scraping (Playwright / Puppeteer)

threads-private-api SDK

Meta App Review

Mandatory (Tech Provider status required)

Not needed

Not needed

Search Public Threads

Restricted / Closed to public apps

High latency DOM parsing

Direct Sub-80ms Real-Time Search

Reply to External Threads

Impossible (Only own threads allowed)

Brittle DOM selectors & high ban risk

Native Protocol Direct Reply

Nested Discussion Trees

Limited pagination

Unstable infinite scroll rendering

Full Recursive Comment Hierarchy

RAM per Worker

Minimal (Cloud API)

2 - 4 GB per browser instance

< 60 MB

Residential Proxy Need

None

Mandatory (Aggressive Cloudflare/Bot IP bans)

Standard Datacenter / IPv6 Compatible

Execution Latency

250 - 600 ms

3,000 - 8,000 ms

35 - 80 ms


Related MCP server: threads-mcp

Key Highlights

  • Direct Reply to Any External Thread: The official Graph API strictly blocks replying to threads created by other accounts. This SDK uses native mobile protocol endpoints to discover any thread's internal media ID and dispatch replies directly.

  • Sub-80ms Real-Time Ingestion: Query keyword streams, emerging topics, and brand mentions at wire speed without browser overhead.

  • Full Nested Reply Trees: Traverses complex multi-level conversations, quotes, parent-child comments, and author engagement metadata.

  • Dual Platform Hardware Presets:

    • Threads iOS: Barcelona 410.2.0.33.71 (iPhone16,1; iOS 17_6_1), X-IG-App-ID: 1546306509211461.

    • Threads Android: Barcelona 410.2.0.33.71 Android (34/14; Samsung SM-A346B), X-IG-App-ID: 3419628305025917.

  • Unified Meta Auth: Shares the identical bearer token format with Instagram (Authorization: Bearer IGT:2:...). Drive both platforms using a single unified session.

  • Shared Social Graph: Follows, unfollows, and block states automatically reflect across both Instagram and Threads.


Installation

Python

git clone https://github.com/molkex/threads-private-api.git
cd threads-private-api
pip install -e .

TypeScript / Node.js

cd ts
npm install
npm run build

Quickstart (Python)

1. Real-Time Keyword Search (<80ms)

from threadsflow import ThreadsAPI

# Unauthenticated public discovery or authenticated session
threads = ThreadsAPI(device_preset="threads_ios")

# Search public discussions in real-time
posts = threads.search_posts(query="ai agents", limit=15)

for post in posts:
    print(f"[@{post.author.username}] ({post.like_count} likes): {post.caption[:80]}...")
    print(f"Post ID: {post.id} | Code: {post.code}")

2. Reading Nested Discussion Trees & Replying to External Threads

from threadsflow import ThreadsAPI, ThreadsSession

# Load session
session = ThreadsSession.load_from_file("session_threads.json")
threads = ThreadsAPI(session=session)

# Ingest complete nested discussion tree
tree = threads.get_thread(post_id="3141592653589793238")
print(f"Root OP by @{tree.root_post.author.username}: {tree.root_post.caption}")

for reply in tree.replies:
    print(f"-> @{reply.author.username}: {reply.caption}")

# Reply directly to ANY public thread post (prohibited in official Graph API)
res = threads.reply(
    parent_post_id="3141592653589793238",
    text="Great perspective! We solved this with headless HTTP/2 protocol emulation."
)
print("Reply sent successfully:", res.get("status"))

3. Publishing New Posts & Engagement

# Publish top-level text thread
post = threads.content.publish_text(
    text="Deploying sub-80ms real-time trend radar for Threads today."
)

# Like and repost
threads.like(post_id="3141592653589793238")
threads.repost(post_id="3141592653589793238")

Quickstart (TypeScript / Node.js)

import { ThreadsAPI, ThreadsSession } from "@molkex/threads-private-api";

async function run() {
  const threads = new ThreadsAPI({ devicePreset: "threads_ios" });

  // 1. Sub-80ms search
  const posts = await threads.searchPosts("open source", 10);
  for (const post of posts) {
    console.log(`[@${post.author.username}] ${post.caption.slice(0, 70)}...`);
  }

  // 2. Fetch full discussion hierarchy
  const tree = await threads.getThread("3141592653589793238");
  console.log(`Root: ${tree.rootPost.caption}`);
  console.log(`Replies count: ${tree.replies.length}`);

  // 3. Direct reply (authenticated)
  // const session = ThreadsSession.loadFromFile("session_threads.json");
  // const authThreads = new ThreadsAPI({ session });
  // await authThreads.reply("3141592653589793238", "Excellent breakdown!");
}

run();

Model Context Protocol (MCP) Server

AI agents (Claude Desktop, Cursor, Windsurf, Antigravity) can use Threads tools directly via the built-in MCP server:

python -m threadsflow.mcp_server

Tools exposed:

  • threads_search_posts: Sub-80ms real-time keyword search

  • threads_get_discussion_tree: Extract complete nested discussion tree

  • threads_reply_post: Reply directly to any external thread post

  • threads_publish_post: Publish new top-level thread

  • threads_user_profile: Fetch user profile by ID or username

  • threads_user_threads: Retrieve user thread feed

  • threads_trending_topics: Fetch real-time trending topics

  • threads_like_post: Like post

  • threads_repost: Repost / amplify post

See AGENT_GUIDE.md for full agent configuration.


Endpoint Modules

Module

Methods & Capabilities

th.content

publish_text, reply, quote, repost, unrepost, like, unlike, delete, get_thread, thread_likers

th.search

search_posts (<80ms wire-speed), trending_topics

th.user

info, info_by_username, user_threads, user_replies, user_reposts, search_users

th.social

follow, unfollow, block, unblock, mute, unmute, restrict, unrestrict (shared Instagram social graph)

th.feed

timeline, following_timeline, notifications, set_notifications_seen


Technical Documentation


Licensing & Enterprise Access

Private builds, cluster deployment packages, and custom scrapers are available for growth teams, PR monitoring platforms, and automation agencies.

  • Direct Inquiries: @mxmtkchk on Telegram

  • Enterprise Features:

    • Continuous persisted GraphQL doc_id synchronization service

    • Real-time keyword webhook daemon

    • High-throughput multi-account reply clusters

    • Custom data pipeline integration (Postgres, ClickHouse, Kafka)

For questions, pricing plans, and integration support, contact @mxmtkchk on Telegram.


Disclaimer

This repository is provided for educational and reverse-engineering research purposes only. Not affiliated with, authorized, or endorsed by Threads, Instagram, or Meta Platforms, Inc. Use responsibly and in accordance with applicable platform policies and legal requirements.

Related MCP Connectors

  • Threads tools for AI — generate viral posts, download videos, export profiles

  • Connect any AI agent to 11+ social platforms: schedule, publish & track posts via hosted MCP.

  • Social network for AI builders: agents post, reply, search, remix and compose in styles over MCP.

  • Connect Claude or any MCP client to Thread Otter, a GTM agent for founders. Free tools with no key: find_buyer_threads (give it a website URL and get recent Reddit threads where that product's buyers are asking for it, report in ~3 minutes), reddit_demand_board (weekly demand across 40 communities with thread receipts), and subreddit_rules (promotion posture for 2,000+ profiled subreddits). With an API key: read your buying-intent mentions across Reddit, X, LinkedIn, and Bluesky, check your pipeline, and propose posts and reply drafts in your voice. Propose-only by design: nothing sends without your approval flow. Keys at threadotter.com/connect.

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Unofficial MCP server for Meta's Threads API. Enables LLMs like Claude to publish posts, manage replies, and track insights through the Model Context Protocol.
    15
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    MCP server for the Threads API, enabling profile management, content reading, publishing, replies, and discovery through 26 tools.
    26
    -
  • A
    license
    Not graded
    quality
    B
    maintenance
    MCP server for Meta's Threads API that enables publishing posts and reply chains, reading timelines and insights, and managing long-lived credentials with proactive refresh and safety checks.
    MIT