ThreadsHow-to

How to scrape Threads with Python: posts, profiles, replies

A free 333-line Python script scrapes public Threads profiles, posts, replies and search. It returned 100 posts in 13.7 seconds.

8 min read

Short answer

  • One Python file with curl_cffi reads public Threads profiles, a profile's posts, a post's first replies and keyword search with no login or API key, and returned 100 of NASA's posts in 13.7 seconds.
  • A post page returns about 10 replies however many it has, and keyword search returns one page of 20 to 29 posts, with no second page.
  • ToolzerHub's Threads API pages a profile's posts with one API key: 193 of NASA's posts in 10 calls, 1 credit each.
On this page

You can scrape public Threads profiles, a profile's recent posts, a post's replies and keyword search with one Python file and no login: toolzerhub/threads-scraper on GitHub. It is 333 lines and depends on one package, curl_cffi. It returned 100 of NASA's posts in 13.7 seconds and a profile in under 4.

Set up the Threads scraper

Clone the repo, install curl_cffi and run profile on any public username. Threads pages carry their data as JSON in <script type="application/json"> tags, and the script pulls them out with a regular expression, so it needs no browser. Every command takes -o file.json to save the result.

bash
git clone https://github.com/toolzerhub/threads-scraper.git
cd threads-scraper
pip install -r requirements.txt
python threads_scraper.py profile nasa

Scrape a Threads profile

Run profile with one or more usernames. It returns the bio, bio links, follower count and the verified and private flags. _user_page loads threads.com/@username, then walks every JSON blob until it finds a record with that username and a follower_count. It finds the record by its shape, so it does not depend on a fixed path.

python
    def _user_page(self, username):
        blobs = self.page(f"/@{quote(username)}")
        for node in walk(blobs):
            if str(node.get("username", "")).lower() == username.lower() and "follower_count" in node:
                return node, blobs
        raise ScrapeError(f"No profile data on the page for {username}. The user may not exist.")

    def profile(self, username):
        user, _ = self._user_page(username)
        pics = user.get("hd_profile_pic_versions") or []
        return {
            "id": str(user.get("pk") or user.get("id")),
            "username": user.get("username"),
            "url": f"{BASE}/@{user.get('username')}",
            "full_name": user.get("full_name"),
            "biography": user.get("biography"),
            "bio_links": [link.get("url") for link in user.get("bio_links") or [] if link.get("url")],
            "followers_count": user.get("follower_count"),
            "is_verified": user.get("is_verified"),
            "is_private": user.get("text_post_app_is_private"),
            "profile_pic_url": pics[-1].get("url") if pics else user.get("profile_pic_url"),
        }

profile nasa took 1.9 seconds. Trimmed output (the follower count is live and moves between runs):

json
{
  "id": "28829152388",
  "username": "nasa",
  "url": "https://www.threads.com/@nasa",
  "full_name": "NASA",
  "biography": "Making the seemingly impossible, possible. ✨",
  "bio_links": [],
  "followers_count": 12781503,
  "is_verified": true,
  "is_private": false,
  "profile_pic_url": "https://scontent-ord5-1.cdninstagram.com/v/t51.82787-19/..."
}

Ten accounts in one command (nasa, natgeo, zuck and seven more) returned 10 of 10 in 16.2 seconds. The signed profile_pic_url expires, so download images soon.

Threads is a class you can import, so a list of usernames becomes a CSV in a few lines. This script reuses one session, waits 2 seconds between names and reports the ones that fail.

python
import csv
import sys
import time

from threads_scraper import ScrapeError, Threads

FIELDS = ["username", "full_name", "followers_count", "is_verified", "is_private", "bio_links"]


def main(path, usernames):
    threads = Threads()  # one session for the whole list; pass a proxy URL here if you need one
    done = 0
    with open(path, "w", newline="", encoding="utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=FIELDS, extrasaction="ignore")
        writer.writeheader()
        for name in usernames:
            try:
                row = threads.profile(name)
                row["bio_links"] = " ".join(row["bio_links"])
                writer.writerow(row)
                done += 1
            except ScrapeError as exc:
                print(f"{name}: {exc}", file=sys.stderr)
            time.sleep(2)  # pause between profiles
    print(f"wrote {done} of {len(usernames)} profiles to {path}")
    if done == 0:
        sys.exit(1)


if __name__ == "__main__":
    main(sys.argv[1], sys.argv[2:])

Run it as python profiles_to_csv.py profiles.csv nasa natgeo spotify netflix nba nytimes mosseri. The file has all 7 rows; four of them:

csv
username,full_name,followers_count,is_verified,is_private,bio_links
nasa,NASA,12781489,True,False,
natgeo,National Geographic,18380926,True,False,https://on.natgeo.com/instagram
netflix,Netflix US,8603346,True,False,
mosseri,Adam Mosseri,1049999,True,False,http://mosseri.net/

Page through a profile's posts

Run posts <username> --limit N. The profile page already embeds the first posts, so the script reads those, and for more it sends the same GraphQL query the Threads website sends for the next page, using the cursor from the page. The loop below is the whole paging logic.

python
    def posts(self, username, limit=20):
        user, blobs = self._user_page(username)
        feed = next((n for n in walk(blobs) if isinstance(n.get("edges"), list) and isinstance(n.get("page_info"), dict)
                     and any("thread_items" in (e.get("node") or {}) for e in n["edges"])), None)
        if feed is None:
            raise ScrapeError(f"No posts on the page for {username}. The account may be private or have no posts.")
        out = []
        while True:
            for edge in feed["edges"]:
                for item in edge["node"].get("thread_items") or []:
                    if item.get("post"):
                        out.append(clean_post(item["post"]))
            info = feed.get("page_info") or {}
            if len(out) >= limit or not info.get("has_next_page") or not info.get("end_cursor"):
                break
            feed = self._more_posts(str(user.get("pk") or user.get("id")), info["end_cursor"])
        return out[:limit]

posts nasa --limit 5 took 1.7 seconds and returned 5 posts. The profile page holds 5 posts for nasa, natgeo and nba, and 10 for zuck, so any --limit above that needs the second query. The five posts, with the counts as they stood:

text
code         created_at  type      likes  replies  reposts  quotes  is_reply
DekCdIIEZCG  2026-10-16  text        280       16       14       2  false
Decc755lYhC  2026-10-13  carousel  41036      586     4367     281  false
Decc8jiFYaY  2026-10-13  text       4182       17       89      11  true
DeaX_rOGaz-  2026-10-12  image      2290       58      105      13  false
DeUWxGgjHSK  2026-10-10  image      1969       55      103       5  false

The third row is NASA replying in its own thread: posts returns an account's replies too, so filter on is_reply. posts nasa --limit 40 returned 40 distinct posts on 3 of 3 runs, in 6.4, 6.7 and 8.0 seconds. posts nasa --limit 100 returned 100 distinct posts in 13.7 seconds, 27 of them replies, and posts natgeo --limit 100 took 16.2 seconds.

Scrape a post's replies

Run post <url>. It returns the post and a replies list. A Threads post page holds the post and its first replies as JSON, in a second record that shares the post's id. The script looks that record up by id and keeps only the entries under direct_replies, because the other posts on the page are recommendations.

python
    def post(self, url):
        path = post_path_of(url)
        code = path.rsplit("/", 1)[1]
        blobs = self.page(path)
        post = next((n for n in walk(blobs) if n.get("code") == code and n.get("user") and n.get("taken_at")), None)
        if post is None:
            raise ScrapeError(f"Post not found or not public: {url}")
        result = clean_post(post)
        # Replies sit in a second record with the same id as the post. The "related
        # posts" elsewhere on the page are recommendations, not replies.
        host = next((n for n in walk(blobs) if n.get("id") == post.get("id") and (n.get("text_post_app_info") or {}).get("direct_replies")), None)
        replies = (((host or {}).get("text_post_app_info") or {}).get("direct_replies") or {}).get("edges") or []
        result["replies"] = [
            clean_post(r["node"])
            for edge in replies
            for r in ((edge.get("node") or {}).get("posts") or {}).get("edges") or []
            if r.get("node")
        ]
        return result

    # --- search ------------------------------------------------------------

On two NASA posts, the one with 586 replies returned 11 in 1.7 seconds and the one with 58 returned 9. Each reply has a post's fields and is_reply true. A post page shows about 10 replies, so that is the script's limit.

Search Threads by keyword

Run search <keyword>. It returns the public posts Threads shows a logged-out visitor, about 20 to 29, with no second page. The script loads threads.com/search, finds the result list by its shape (edges that hold thread records) and cleans each post.

python
    def search(self, keyword, limit=20):
        """Threads shows about 20 results to logged-out visitors and no second page."""
        blobs = self.page(f"/search?{urlencode({'q': keyword, 'serp_type': 'default'})}")
        results = next((n for n in walk(blobs) if isinstance(n.get("edges"), list)
                        and any(isinstance((e.get("node") or {}).get("thread"), dict) for e in n["edges"])), None)
        if results is None:
            raise ScrapeError(f"No search results for {keyword!r}.")
        out = []
        for edge in results["edges"]:
            for item in edge["node"]["thread"].get("thread_items") or []:
                if item.get("post"):
                    out.append(clean_post(item["post"]))
        return out[:limit]

search astronomy --limit 20 took 4.5 seconds and returned 20 posts from 17 accounts, 3 of them verified. The median post had 810 likes and the top post 11,290; 14 were text, 3 images, 2 carousels and 1 video. --limit 40 returned 29 posts for "astronomy" and 22 for "bitcoin", and results are not sorted by date. For Meta's own keyword search, see Threads API keyword search.

Threads with ToolzerHub

We make ToolzerHub, and its Threads API pages a profile's posts to the end with one API key. Send a profile's id as user_id:

bash
curl -H "x-api-key: $TOOLZERHUB_API_KEY" \
  "https://api.toolzerhub.com/v1/threads/profile/posts?user_id=28829152388"

The first call took 2.1 seconds and returned 21 posts, with has_next_page true. Trimmed to the fields the script also returns:

json
{
  "data": {
    "edges": [
      {
        "node": {
          "thread_items": [
            {
              "post": {
                "code": "DekCdIIEZCG",
                "taken_at": 1792170638,
                "like_count": 280,
                "text_post_app_info": { "direct_reply_count": 16, "repost_count": 14, "quote_count": 2 }
              }
            }
          ]
        }
      }
    ],
    "page_info": { "has_next_page": true, "end_cursor": "QVFDbmR0..." }
  }
}

Send each end_cursor back as end_cursor until has_next_page is false. For NASA that took 10 calls and 38.6 seconds and returned 193 posts with no duplicates. The response is Threads' own record, with many more fields than the script's cleaned ones, and user_id is the id that profile returns. The API's post endpoint returns the same 11 replies on the 586-reply post, and one search page holds 26 posts for "astronomy" with no cursor for more.

What it costs

Every Threads call costs 1 credit, so NASA's 193 posts cost 10 credits. You get 100 free credits a month; $19 buys 10,000 credits that never expire, and plans for higher volume cover more profiles. Get a free API key and page your first profile.

If the data is yours, Meta's own Threads API is the supported route; what Meta's Threads API returns covers what it allows for other accounts. To read a profile without logging in, see how to view Threads without an account; to save a post's media, how to download Threads videos.

We are not affiliated with Meta Platforms, Inc. or Threads.

Get this data from your own code

The Threads API returns it as JSON with one x-api-key header. 100 free credits monthly.