Threads Search Scraper API
最后更新: · REST · JSON
向 GET https://api.scrapier.io/api/v2/threads-search/?queries=AI 发送请求,并在 X-API-Key 请求头中带上你的密钥。你会得到 JSON 格式的搜索结果页。每个搜索结果页 10 积分;失败的调用免费。
- 每页搜索结果 10 积分
- 失败的调用免费
- 没有速率限制
调用 Threads Search Scraper API
在你自己的应用、脚本或智能体中使用 Threads Search Scraper API。你需要一个 Scrapier 账号,以及控制台中的 API 密钥。选择一种语言。
import requests# Replace YOUR_API_KEY with the key from your Scrapier dashboardAPI_KEY = "YOUR_API_KEY"params = { "queries": "AI", "sort": "top",}r = requests.get( "https://api.scrapier.io/api/v2/threads-search/", headers={"X-API-Key": API_KEY}, params=params, timeout=210,)r.raise_for_status()# The result sits under data.postsresult = r.json()["data"]["posts"]print(result)
// Replace YOUR_API_KEY with the key from your Scrapier dashboardconst API_KEY = "YOUR_API_KEY";const params = new URLSearchParams({ queries: "AI", sort: "top",});const res = await fetch(`https://api.scrapier.io/api/v2/threads-search/?${params}`, { headers: { "X-API-Key": API_KEY }, signal: AbortSignal.timeout(210_000),});if (!res.ok) throw new Error(`HTTP ${res.status}`);const { data } = await res.json();console.log(data.posts);
# One GET request. The key goes in a header, never in the URL.GET /api/v2/threads-search/?queries=AI&sort=top HTTP/1.1Host: api.scrapier.ioX-API-Key: YOUR_API_KEYAccept: application/json
# Scrapier publishes an OpenAPI spec that covers every endpoint. No API key needed.curl -O https://api.scrapier.io/api/v2/openapi.json# Import openapi.json into Postman, Insomnia, Bruno or a code generator,# then add your key as the X-API-Key header.
# 1. Add the Scrapier MCP server to Claude Codeclaude mcp add -t http scrapier https://mcp.scrapier.io/mcp --header "X-API-Key: YOUR_API_KEY"# 2. Ask your agent. It finds the endpoint with search_endpoints# and calls it with run_scrape:"Search Threads for the latest posts about AI"run_scrape("threads-search", {queries: "AI"})
Python 版 Threads Search Scraper API
只需普通的 requests,无需 SDK。每个响应都是类型化 JSON。
安装
JavaScript 版 Threads Search Scraper API
可在 Node 18+、Deno、Bun 和边缘运行时中使用内置的 fetch。
检查你的环境
HTTP 版 Threads Search Scraper API
一次 GET 请求。认证只需一个 X-API-Key 请求头。
检查你的环境
Threads Search Scraper API 的 OpenAPI 定义
下载一次规范,然后导入到你已在使用的工具中。获取它无需密钥。
下载规范
通过 MCP 使用 Threads Search Scraper API
同一个端点也是 Claude Code、Cursor 和 Windsurf 的工具调用。输入同样是 queries,每个搜索结果页同样是 10 积分。
安装
其他调用方式
Threads Search Scraper API 交互式试用
编辑请求,观察代码更新,然后运行。没有密钥时它显示目录示例,不计费。使用你的密钥时,它会从浏览器发出真实调用;密钥只会发送到 api.scrapier.io,从不存储。
GET /api/v2/threads-search/?queries=AI点击运行请求发送。没有密钥时你得到的是目录示例。
失败的调用不计费。
无论输入什么,示例都相同:它展示的是响应结构,而不是你输入的账户。
示例响应,目录示例,2026 年11月 9 日
{
"success": true,
"data": {
"query": "AI",
"page": 1,
"page_size": 18,
"posts": [
{
"postId": "3921506418558274796",
"postUrl": "https://www.threads.com/@theeconomist/post/DLabcXYZ",
"username": "theeconomist",
"isVerified": true,
"captionText": "Today the cost of providing AI services is subsidised by the labs...",
"likeCount": 1240,
"directReplyCount": 87,
"repostCount": 34,
"takenAt": 1718628028,
"takenAtISO": "2026-06-17T12:40:28.000Z",
"nextCursor": "GDA6...opaque-end-cursor",
"keyword": "AI",
"scraped_at": "2026-06-18T12:00:00.000Z"
}
],
"next_cursor": "eyJxIjoiQUkiLCJyIjowLCJhIjoiR0RBNi4uLiIsImxrIjp7fSwicCI6MX0"
}
}你可以提取的数据
Threads Search Scraper 按关键词、话题标签或短语搜索 Threads 帖子,并把匹配结果以结构化 JSON 返回。下面每个字段都来自目录中的示例响应,是带类型的 JSON。
帖子
响应中有 5 个字段。
- postId
- postUrl
- captionText
- takenAt
- takenAtISO
互动
响应中有 3 个字段。
- likeCount
- directReplyCount
- repostCount
作者
响应中有 2 个字段。
- username
- isVerified
搜索上下文
响应中有 3 个字段。
- keyword
- nextCursor
- scraped_at
响应结构与分页
响应中有 5 个字段。
- success
- data.query
- data.page
- data.page_size
- data.next_cursor
响应结构参考
示例响应中的每个字段。字段名每次调用都保持不变。
| 字段 | 类型 | 示例 | 说明 |
|---|---|---|---|
posts.postId | string | "3921506418558274796" | 帖子 ID |
posts.postUrl | string | "https://www.threads.com/@theeconomist/post/…" | 帖子的 URL |
posts.captionText | string | "Today the cost of providing AI services is …" | 帖子的文本 |
posts.takenAt | integer | 1718628028 | 以 Unix 时间戳表示的发布时间 |
posts.takenAtISO | string | "2026-06-17T12:40:28.000Z" | 发布时间(ISO 8601) |
posts.likeCount | integer | 1240 | 点赞数 |
posts.directReplyCount | integer | 87 | 直接回复数 |
posts.repostCount | integer | 34 | 转发数 |
posts.username | string | "theeconomist" | 作者的用户名 |
posts.isVerified | boolean | true | 作者是否已认证 |
posts.keyword | string | "AI" | 匹配该帖子的搜索词 |
posts.nextCursor | string | "GDA6...opaque-end-cursor" | 记录在帖子行上的游标 |
posts.scraped_at | string | "2026-06-18T12:00:00.000Z" | Scrapier 读取该帖子的时间(ISO 8601) |
success | boolean | true | 每个 200 响应都为 true |
data.query | string | "AI" | 你发送的搜索词 |
data.page | integer | 1 | 本次响应的页码 |
data.page_size | integer | 18 | 本页帖子数量 |
data.next_cursor | string | "eyJxIjoiQUkiLCJyIjowLCJhIjoiR0RBNi4uLiIsImx…" | 作为 cursor 传回即可获取下一页;最后一页为 null |
请求参数参考
| 名称 | 类型 | 必填 | 默认值 | 说明 | 示例 |
|---|---|---|---|---|---|
queries | string | 是 | — | Threads 搜索词、话题标签或短语。每次调用一个。首次调用必填。别名:search_query、searchQuery、keyword、q | AI |
cursor | string | 否 | — | 传回上一个响应的 data.next_cursor 以获取下一页;null 表示最后一页 | — |
sort | string | 否 | top | top 或 recent(默认 top)。锁定在游标中 | top |
from | string | 否 | — | 只保留该用户名的帖子(客户端筛选)。锁定在游标中。别名:from_user | — |
before | string | 否 | — | 只保留该日期之前的帖子,格式为 YYYY-MM-DD。锁定在游标中 | — |
after | string | 否 | — | 只保留该日期之后的帖子,格式为 YYYY-MM-DD。锁定在游标中 | — |
session_id | string | 否 | — | 可选的 Threads sessionid cookie,每次调用都会重新读取。匿名调用仍然可用,但限制为一页 | — |
use_proxy | boolean | 否 | true | 为 true 时使用 Scrapier 的住宅代理池(默认 true)。保持默认 | true |
raw_data | boolean | 否 | false | 在 raw_responses 下返回上游原始数据,而不是格式化后的帖子 | true |
每次调用一个值:要搜索十个关键词,就调用十次,并用 cursor 为每个关键词翻页。布尔值是字符串 true 或 false。
Threads Search Scraper API 的分页
Threads Search Scraper API 分页返回结果。把 data.next_cursor 作为 cursor 传回即可获取下一页;当它为 null 时说明没有更多了。每次成功调用,无论首页还是后续页,都是 10 积分。
无需登录 Threads 即可访问
Threads Search Scraper API 不需要 Threads 账号、登录或会话 cookie。你只需在 X-API-Key 请求头中带上 Scrapier 密钥,即可获得 JSON。它只读取公开数据:任何访客无需登录就能看到的内容。
速度、成本和并发
| 指标 | 数值 | 来源 |
|---|---|---|
| 成功调用的成本 | 10 积分 | Scrapier 目录 |
| 失败调用的成本 | 0 积分 | 任何非 2xx 响应 |
| 每个密钥的并行请求数 | 无限制 | 所有套餐均无速率限制 |
| 建议的客户端超时 | 210 秒 | Scrapier 文档,适用于每个端点 |
Threads Search Scraper API 的延迟
Scrapier 不公布该端点的延迟或成功率数据。每次调用都在调用时读取 Threads,因此响应时间取决于 Threads 和结果的大小。请按文档对所有端点的建议,将客户端超时设为 210 秒。
端点的限制
Threads Search Scraper API 的实际限制。
- 仅限公开数据。
- 调用失败(例如搜索结果页缺失或不可用)会返回非 2xx 状态码,并消耗 0 积分。
- 数据在调用时实时读取。
- 没有速率限制,因此需要多少并行请求,就发多少。
- 较大的结果分页返回;把
data.next_cursor作为cursor传回。 - Threads 不显示的字段不会返回。
Scrapier 与官方 Threads API 对比
当你要发布帖子、管理回复,或代表你拥有的账户执行操作时,官方 Threads API 是更好的选择。
| 功能 | Scrapier 搜索结果页爬虫 | Threads 官方 API |
|---|---|---|
| 所需权限 | 一个 Scrapier API 密钥 | Meta 开发者应用、访问令牌以及 Meta 授予的权限 |
| 哪些数据 | 按关键词、话题标签或短语获取帖子,可按热门或最新排序 | 取决于你的应用可用的端点和权限 |
| 返回的字段 | 13 个字段,与目录示例一致 | 取决于你请求的字段 |
| 速率限制 | 无:需要多少并行请求,就发多少 | Meta 按应用设定的限制 |
| 设置 | 注册,复制密钥,发送请求 | 创建应用、设置 OAuth、管理令牌 |
| 成本 | 每次调用 10 积分,每 1,000 次调用低至 $1.20 | 由 Meta 的条款决定 |
错误与重试处理
| 状态 | 含义 | 是否计费 | 解决办法 |
|---|---|---|---|
| 200 | data.posts 中返回的搜索结果页数据 | 是 | — |
| 400 | 输入有误或缺失 | 否 | 检查 queries:每次调用一个值 |
| 401 | 缺少 X-API-Key 请求头 | 否 | 添加该请求头 |
| 402 | 积分用完(响应体含 balance) | 否 | 充值;重试无济于事 |
| 403 | API 密钥无效或已撤销 | 否 | 在控制台中检查密钥 |
| 429 | 被限流 | 否 | 等待 Retry-After 秒后重试 |
| 5xx | 上游故障或超时 | 否 | 退避重试;把客户端超时设为 210 s |
来自错误参考。任何非 2xx 响应消耗 0 积分。
Threads Search Scraper API 的重试逻辑
import time, requests def get_search(value, key, tries=5): for attempt in range(tries): r = requests.get( "https://api.scrapier.io/api/v2/threads-search/", headers={"X-API-Key": key}, params={"queries": value}, timeout=210, ) if r.status_code == 429: time.sleep(int(r.headers.get("Retry-After", 2 ** attempt))) elif r.status_code >= 500: time.sleep(2 ** attempt) else: r.raise_for_status() return r.json() raise RuntimeError("gave up after retries")
价格与速率限制
| 套餐 | 月费 | 包含搜索结果页面 | 每 1,000 次成本 |
|---|---|---|---|
| Hobby | $29 | 15,000 | $1.93 |
| Pro | $79 | 50,000 | $1.58 |
| Scale | $299 | 250,000 | $1.20 |
Threads Search Scraper API 的计费规则
Threads Search Scraper API 按每个成功获取的搜索结果页收取 10 积分。失败的调用(即任何非 2xx 状态)消耗 0 积分。所有套餐都没有速率限制。付费前可以先用免费额度试用。
批量查询与 CSV
queries 每次调用只接受一个值。对于列表,循环并行调用(没有速率限制),然后把每一行展平为一行 CSV。
import csv, requests from concurrent.futures import ThreadPoolExecutor values = ["AI"] # your list def fetch(value): r = requests.get( "https://api.scrapier.io/api/v2/threads-search/", headers={"X-API-Key": "YOUR_API_KEY"}, params={"queries": value}, timeout=210, ) r.raise_for_status() out = r.json()["data"]["posts"] return out if isinstance(out, list) else [out] # no rate limits: use as many workers as you need with ThreadPoolExecutor(max_workers=3) as pool: rows = [row for part in pool.map(fetch, values) for row in part] cols = ["username", "captionText", "likeCount", "directReplyCount", "repostCount", "takenAtISO"] with open("out.csv", "w", newline="") as f: w = csv.DictWriter(f, fieldnames=cols, extrasaction="ignore") w.writeheader() w.writerows(rows)
从 Threads Search Scraper API 导出 CSV
username,captionText,likeCount,directReplyCount,repostCount,takenAtISO theeconomist,Today the cost of providing AI services is subsidised by the labs...,1240,87,34,2026-06-17T12:40:28.000Z
通过 MCP 供 AI 智能体访问
Threads Search Scraper API 的 MCP
AI 智能体可通过 Scrapier MCP 服务器 https://mcp.scrapier.io/mcp 使用同一个端点。一条命令即可在 Claude Code 中注册:claude mcp add -t http scrapier https://mcp.scrapier.io/mcp --header "X-API-Key: YOUR_API_KEY"。智能体通过 search_endpoints 找到该端点,再用 run_scrape 和端点 id threads-search 调用它。它使用相同的 queries 输入,每个搜索结果页同样是 10 积分。各客户端的设置方法见 Threads Search Scraper MCP 页面。
按角色划分的集成路径
n8n 和 Make
- 添加一个 HTTP Request 步骤
- 带上你的
X-API-Key请求头,对该端点发送 GET - 把
data.posts字段映射到你的列
循环并翻页
CSV 和展平的 JSON
把每一行展平为一行 CSV,每个字段一列,可直接用于 Sheets、Excel 或 BI 工具。
法律与合规说明
在许多国家,抓取公开可得的 Threads 数据通常是合法的,但答案取决于你收集什么、你身处何地以及如何使用。在美国,关于公开数据抓取最常被引用的案例是 hiQ Labs v. LinkedIn。Scrapier 只返回任何访客无需登录即可看到的公开数据。根据 GDPR 及类似法律,收集公开数据可能是允许的,但你如何存储和使用个人数据(例如姓名、用户名或帖子)仍须遵守当地数据保护规定,并且 Threads 的条款同样适用。如果你的用例涉及大量存储个人数据,请咨询法律顾问。这不构成法律意见;请参阅我们的使用条款。
常见问题
有 Threads 搜索结果页 API 吗?
有。Scrapier 的 Threads Search Scraper API 只需一次 GET 请求和一个 X-API-Key 请求头,就能以 JSON 返回任何公开的搜索结果页。无需 Threads 应用或登录。
如何从 Python 调用?
对 <code>https://api.scrapier.io/api/v2/threads-search/</code> 使用 <code>requests.get</code>,参数为 <code>params={'queries': 'AI'}</code>,请求头为 <code>headers={"X-API-Key": KEY}</code>。读取 <code>r.json()["data"]["posts"]</code>。
调用失败时会怎样?
任何非 200 响应都免费。对 429 和 5xx 请退避重试;API 已经会重试上游故障。
多少钱?
每次成功调用 10 积分,在 Pro 套餐上每 1,000 页搜索结果约 $1.58。失败的调用免费。
有 OpenAPI 规范吗?
有。获取它无需密钥,并且涵盖每个 Scrapier 端点。