搜索时间线
按关键词搜索 X (Twitter),支持热门、最新、媒体、用户或列表结果模式,使用游标分页。用于查找与话题相关的公开对话、账号、媒体或列表。
参数
| 参数 | 必填 | 类型 | 说明 | 示例 | 可选值 |
|---|---|---|---|---|---|
keyword |
必填 | string | 搜索关键词。 | 咖啡 |
— |
search_type |
可选 | string | 搜索结果类型。 可用值: - `TOP`:热门搜索结果 - `LATEST`:最新搜索结果 - `MEDIA`:媒体搜索结果 - `PEOPLE`:人物搜索结果 - `LISTS`:列表搜索结果 | Top |
TOPLATESTMEDIAPEOPLELISTS |
cursor |
可选 | string | 由先前响应返回的分页游标。 | — | — |
代码示例
curl -G "https://api.mofa-ai.com/v1/twitter/search_v1" \
-H "Authorization: Bearer $MOFA_API_KEY" \
--data-urlencode 'keyword=咖啡' \
--data-urlencode 'search_type=Top'
import os
import requests
resp = requests.get(
"https://api.mofa-ai.com/v1/twitter/search_v1",
headers={"Authorization": f"Bearer {os.environ['MOFA_API_KEY']}"},
params={
"keyword": "咖啡",
"search_type": "Top",
},
timeout=60,
)
body = resp.json()
if body["success"]:
print(body["cost_usd"], body["data"])
else:
print(body["error"], body["message"])
const url = new URL("https://api.mofa-ai.com/v1/twitter/search_v1");
url.search = new URLSearchParams({
keyword: "咖啡",
search_type: "Top",
});
const resp = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.MOFA_API_KEY}` },
});
const body = await resp.json();
if (body.success) console.log(body.cost_usd, body.data);
else console.error(body.error, body.message);
在线试用
登录后可以在这里直接调用此接口,按价格从余额扣费,失败不收费。新账户赠送 $0.50 试用额度。
响应示例
采集于 2026-11-08,耗时 5958 ms · 请求参数 {"keyword": "咖啡", "search_type": "Top"}
JSON
{
"success": true,
"code": 0,
"message": "success",
"request_id": "req_5f1c2a9be04d7c3a81f6e2d0",
"endpoint": "twitter.search_v1",
"cost_usd": 0.02,
"data": {
"code": 0,
"data": {
"status": "ok",
"timeline": [
{
"lang": "zh",
"text": "虽然不太喜欢喝咖啡,但是咖啡的一些知识还是有必须要了解一下 https://t.co/bTjBkAV281",
"type": "tweet",
"media": {
"video": [
{
"id": "2053829266085904384",
"duration": 32415,
"variants": [
{
"url": "https://video.twimg.com/amplify_video/2053829266085904384/pl/In1Bur0JeF5L_f-C.m3u8?tag=27&v=ea0",
"content_type": "application/x-mpegURL"
},
{
"url": "https://video.twimg.com/amplify_video/2053829266085904384/vid/avc1/320x568/LiwoydUoWhPy7ubg.mp4?tag=27",
"bitrate": 632000,
"content_type": "video/mp4"
},
"… +2"
],
"aspect_ratio": [
9,
16
],
"original_info": {
"width": 720,
"height": 1280,
"focus_rects": []
},
"media_url_https": "https://pbs.twimg.com/amplify_video_thumb/2053829266085904384/img/zQYPedWrx_GIF-Nb.jpg"
}
]
},
"views": "326715",
"quotes": 5,
"source": null,
"replies": 1133,
"entities": {
"urls": [],
"media": [
{
"url": "https://t.co/bTjBkAV281",
"type": "video",
"sizes": {
"large": {
"h": 1280,
"w": 720,
"resize": "fit"
},
"small": {
"h": 680,
"w": 383,
"resize": "fit"
},
"thumb": {
"h": 150,
"w": 150,
"resize": "crop"
},
"medium": {
"h": 1200,
"w": 675,
"resize": "fit"
}
},
"id_str": "2053829266085904384",
"indices": [
30,
53
],
"media_key": "13_2053829266085904384",
"video_info": {
"variants": [
{
"url": "https://video.twimg.com/amplify_video/2053829266085904384/pl/In1Bur0JeF5L_f-C.m3u8?tag=27&v=ea0",
"content_type": "application/x-mpegURL"
},
{
"url": "https://video.twimg.com/amplify_video/2053829266085904384/vid/avc1/320x568/LiwoydUoWhPy7ubg.mp4?tag=27",
"bitrate": 632000,
"content_type": "video/mp4"
},
"… +2"
],
"aspect_ratio": [
9,
16
],
"duration_millis": 32415
},
"display_url": "pic.x.com/bTjBkAV281",
"expanded_url": "https://x.com/pjjin574832/status/2053829712812847442/video/1",
"media_results": {
"result": {
"media_key": "13_2053829266085904384"
}
},
"original_info": {
"width": 720,
"height": 1280,
"focus_rects": []
},
"media_url_https": "https://pbs.twimg.com/amplify_video_thumb/2053829266085904384/img/zQYPedWrx_GIF-Nb.jpg",
"additional_media_info": {
"monetizable": false
},
"allow_download_status": {
"allow_download": true
},
"ext_media_availability": {
"status": "Available"
}
}
],
"symbols": [],
"hashtags": [],
"timestamps": [],
"user_mentions": []
},
"retweets": 155,
"tweet_id": "2053829712812847442",
"bookmarks": 723,
"favorites": 1507,
"sensitive": false,
"user_info": {
"url": null,
"name": "等待被割的老韭菜",
"avatar": "https://pbs.twimg.com/profile_images/2064755237697826816/8bk9D1J__normal.jpg",
"rest_id": "1772563414008905728",
"location": "",
"verified": true,
"created_at": "Tue Mar 26 09:57:16 +0000 2024",
"cover_image": null,
"description": null,
"screen_name": "pjjin574832",
"friends_count": null,
"verified_type": null,
"favorites_count": 290891,
"followers_count": 20268
},
"created_at": "Mon May 11 13:28:56 +0000 2026",
"screen_name": "pjjin574832",
"conversation_id": "2053829712812847442",
"display_text_range": [
0,
29
]
},
{
"lang": "zh",
"text": "医疗机器人就在市中心逃离警察\n\n机器人被设计来服从命令。这个机器人却自行转身逃跑了。\n\n这不是摆拍。这不是演示。\n\n摄像头实时捕捉到了这一幕。一辆警车和一辆救护车已经在现场。身穿蓝色医疗袍的机器人冲过步行区,径直穿过咖啡馆的桌子。\n\n它在椅子间躲闪。它绕过人群而不减速。它从未失去平衡。\n\n步行的警员无法跟上步伐。步速、平衡、障碍反应,全都实时运行。没有人提前编写这个场景的脚本。\n\n自主性不是代码中…",
"type": "tweet",
"media": {
"video": [
{
"id": "2099200000039206914",
"duration": 15041,
"variants": [
{
"url": "https://video.twimg.com/amplify_video/2099200000039206914/pl/p7D7mdFacNWEGVBV.m3u8?tag=29&v=cfc",
"content_type": "application/x-mpegURL"
},
{
"url": "https://video.twimg.com/amplify_video/2099200000039206914/vid/avc1/320x568/70JX00ItkR_I6Ujg.mp4?tag=29",
"bitrate": 632000,
"content_type": "video/mp4"
},
"… +2"
],
"aspect_ratio": [
9,
16
…
示例较长,此处截断显示。