How to search Threads posts by keyword in Python
Checked on 2026-11-24.
Meta's Threads API has a keyword search, GET /keyword_search, but until Meta approves your app for the threads_keyword_search permission it searches only your own posts. Meta grants that permission to business apps that help their users manage their social media presence, and prohibits it in consumer apps. Without that approval, the way to search public posts from Python is a service that reads Threads' own search.
1. The official endpoint: /keyword_search
The keyword search documentation describes one GET endpoint for keywords and topic tags. In Python, after the curl example there:
import os
import requests
res = requests.get(
"https://graph.threads.com/v1.0/keyword_search",
params={
"q": "coffee",
"search_type": "RECENT", # TOP is the default
"fields": "id,text,media_type,permalink,timestamp,username,has_replies,is_quote_post,is_reply",
"limit": 50,
"access_token": os.environ["THREADS_ACCESS_TOKEN"], # a Threads user access token
},
timeout=30,
)
res.raise_for_status()
for post in res.json()["data"]:
print(post["timestamp"], post["username"], post.get("text"), post["permalink"])q(required): "The keyword(s) to be queried."search_type:TOP(the default) "Returns the most popular search results";RECENT"Returns the most recent search results".search_mode:KEYWORD(the default), orTAGto search a topic tag.media_type:TEXT,IMAGEorVIDEO; without it every type is returned.sinceanduntil: a Unix timestamp or a date such as 2026-01-01.since"Must be on or after 1688540400", anduntilmay be "no later than the current time".limit: "The default is 25 and the maximum is 100."author_username: only posts by that account, "an exact match without the @ symbol".
The permission, and what Meta approves it for
Every call needs threads_basic, and this one also threads_keyword_search. The documentation says what approval changes: "If your app has not been approved for the threads_keyword_search permission, the search is performed only on posts owned by the authenticated user. After approval, public posts are searchable."
Meta's permissions reference says what it approves the permission for. It "allows a business app to search and fetch content with a specific keyword on behalf of a Threads user", and: "The allowed usage for this permission is to help the user manage their social media presence. It is not intended for any other purpose. For example, using threads_keyword_search permission in a consumer app is strictly prohibited." The allowed usages it lists are showing public content that a business app user searches by keyword, letting the user sort their own mentioned threads, and letting the user publish responses to what they find.
The review asks for a use case description and a screencast that shows the Threads login with the permission being granted, the linking of a Threads account, a keyword search for public content, and a post's result in your app and in the Threads app. The get-started guide adds that for people without a role on your app, "each permission must first be approved through the App Review process, and your app must be published". Until then, Threads testers you invite can use the app, and their searches cover their own posts.
Where it stops: at the purpose. If what you build is not a tool that helps its users manage their presence on Threads, such as a research script or a data pipeline, it is outside the usage the permission's description allows.
Limits of the official search
- "A user can send a maximum of 2,200 queries within a rolling 24-hour period." The limit belongs to the user across all apps, a repeated query counts again, and "Queries which return no results do not count against this limit".
- "The API returns an empty array for any requests that include keywords that Threads has deemed sensitive or offensive."
- No counts on the results: the fields a post can return include no like, reply, repost or view count, and for search "The owner field is excluded and is not returned."
- A short-lived token lasts 1 hour and a long-lived one 60 days. A grant from a user with a public profile is valid for 90 days and is extended when you refresh the token.
2. Without a Meta app: an HTTP API
The Pipefetch search endpoint returns the posts Threads' own search shows a visitor who is not logged in, so there is no Meta app, token or review.
import os
import requests
res = requests.get(
"https://pipefetch.com/v1/threads/search",
params={"q": "coffee", "sort": "recent", "limit": 20}, # sort: top (default) or recent
headers={"x-api-key": os.environ["PIPEFETCH_API_KEY"]},
timeout=90,
)
if res.status_code == 404:
print("No posts found for this term") # not charged
else:
res.raise_for_status()
for post in res.json()["data"]["posts"]:
if post["isReply"]:
continue # replies are included; skip them to keep top-level posts only
print(post["publishedAt"], post["likeCount"], post["replyCount"], post["repostCount"], post["text"][:80])
print(" ", post["url"])Each post has its text, link, publish time and detected language, its exact like, reply, repost and quote counts, and its author: username, name, verified flag, picture and profile address. It also carries image and video addresses, the topic, hashtags, mentions and links, and for a reply the post it answers. sort=recent starts with the last 24 hours, goes further back only when they do not hold enough posts, and returns the posts newest first. A search costs 1 credit, and most take 2 to 9 seconds. A search that finds nothing answers 404 and costs nothing, and a new account has 100 free credits and needs no card.
Where it stops:
- Up to 20 posts per search, and no further pages. There is no date window, no author filter, no media filter and no topic-tag mode.
- Threads matches terms of several words loosely, so only posts in which every word of the term appears (in the text, the topic, a link title or the author's name) are returned. A search can return fewer posts than you asked for.
- Replies are included and marked with
isReply: in the answer saved for "coffee", 6 of the 10 posts were replies. - Authors come without follower counts; the profile endpoint has those.
- It is not the official API, and Pipefetch is not affiliated with Threads or Meta.
Which one should you use?
| You want | Use |
|---|---|
| A tool that helps its users manage their Threads presence, and you can pass App Review | The official keyword search |
| Up to 100 results per query, date windows, topic tags, a search within one account | The official keyword search, after approval |
| Like, reply and repost counts on the posts a search finds | An HTTP API such as Pipefetch |
| A search from a script, for research or monitoring, without a Meta app | An HTTP API such as Pipefetch |
Profiles, and the posts people write
To read one account's profile and latest posts rather than search, the guide Threads API: can you read someone else's posts? covers Meta's profile discovery endpoints and their review. Whichever route you use, a post comes with its author's username and name, which is personal data when the author is a person, under laws such as the GDPR. Keep only what your purpose needs. Pipefetch's terms forbid using the API to harass people or to build profiles of private individuals.
Try it with 100 free credits. No card needed. No scraper to build or maintain. Get an API key or read the docs.
APIs used in this guide
-
2 credits
Threads Profile API
Exact follower count, name, bio and verified badge of a public Threads account, with its latest posts and their engagement.
GET /v1/threads/profile -
1 credit
Threads Search API
Public Threads posts that contain a search term, with exact likes, replies and reposts, media and the author of each.
GET /v1/threads/search
More Threads guides
Guides for other sources
Every source
YouTube
- How to get a YouTube transcript in Python
- How to get a YouTube transcript in Node.js
- YouTube API quota exceeded: what the error means and how to fix it
- How to find a YouTube channel ID from a handle or URL
- How to download YouTube subtitles as SRT or VTT
- youtube-transcript-api RequestBlocked or IpBlocked: why it happens and how to fix it
- How to get YouTube comments in Python
- How to search YouTube from Python
- How to list a YouTube channel's videos in Python
- How to summarize a YouTube video with an LLM in Python
- How to get YouTube transcripts and video stats in Google Sheets
- How to get YouTube video views and likes in Python
- How to get YouTube transcripts in n8n, Make and Zapier
- LangChain YoutubeLoader fails on a server: why, and a loader that works
- How to get a YouTube channel's subscriber count in Python
- How to give Claude or Cursor access to YouTube (MCP server)
- How to get YouTube comments in Node.js
- How to analyze YouTube comments with an LLM in Python
- How to list a YouTube channel's Shorts in Python
- How to search YouTube from JavaScript
- How to get an Instagram follower count in Python
- Instagram Basic Display API alternatives: what to use after the shutdown
- Instaloader 401 Unauthorized, 429 and "Login required": what to do
- How to calculate an Instagram engagement rate in Python
- How to get an Instagram follower count in Node.js
- How to get Instagram follower counts in Google Sheets
- How to get Instagram Reel views in Python
Websites
- Clearbit Logo API alternatives: get a company logo from its domain
- How to extract email addresses from a website in Python
- How to turn a web page into Markdown in Python
- How to detect what a website is built with, in Python
- How to get the contact emails and phone numbers of websites in Google Sheets
- How to build a LangChain tool that reads web pages and searches Google
- How to turn a web page into Markdown in JavaScript for RAG
- How to extract social media links from a website in Python
- How to get a website's favicon in Python
- How to check robots.txt in Python before you fetch a page
TikTok
- How to get a TikTok video's views and likes in Python
- How to get the comments of a TikTok video in Python
- How to get a TikTok follower count in Python
- TikTok Research API: who can get access, and what to do if you cannot
- How to get TikTok video views, likes and shares in Node.js
- How to get TikTok views, likes and follower counts in Google Sheets
- How to get a Facebook Page's posts without app review
- Is there a Facebook Marketplace API?
- Facebook Groups API alternatives after its removal in 2024
- How to get a Facebook Page's follower count and contact details in Python
- How to get Google search results in Python
- pytrends 429 TooManyRequestsError: what it means and what to do
- How to get Google Trends data in Python
- Why is Wyoming first in Google Trends?
- How to get Google search results in Node.js
- How to get Google search results into Google Sheets
- How to give an LLM live Google results with tool calling
- How to get LinkedIn company data in Python
- How to search LinkedIn jobs from Python
- How to get a LinkedIn company page's latest posts in Python