X Search Timeline
Searches X (Twitter) by keyword across top, latest, media, people, or list result modes with cursor pagination. Use it to find public conversations, accounts, media, or lists related to a topic.
/v1/twitter/search_v1
$0.02
- Price
- $0.02 per successful call, Failed calls are free
- Endpoint ID
twitter.search_v1
Parameters
-
keywordstring RequiredSearch keyword.
Example
咖啡 -
search_typestring OptionalSearch result type.
Available Values:
TOP: Top search resultsLATEST: Latest search resultsMEDIA: Media search resultsPEOPLE: People search resultsLISTS: List search results
Example
Top -
cursorstring OptionalPagination cursor returned by the previous response.
Code samples
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);
Example response
Request parameters {"keyword": "咖啡", "search_type": "Top"}
{
"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
…
Truncated for display; the full response is longer.
Try it
Sign in to call this endpoint from this page. Successful calls are billed to your balance, failed calls are free, and new accounts get $0.50 of trial credit.
More X endpoints
-
User Profile
$0.02Retrieves an X (Twitter) user profile identified by its numeric Rest ID. Use it to review a known account before monitoring its posts or conducting creator a…
/v1/twitter/get_user_detail_v1
-
User Published Posts
$0.02Retrieves posts published by an X (Twitter) user identified by Rest ID, with cursor pagination. Use it to browse a known account's timeline or continue throu…
/v1/twitter/get_user_posts_v1
-
Post Comments
$0.02Retrieves the latest comments for an X (Twitter) post identified by tweet ID, with cursor pagination. Use it to review recent discussion on a known post and…
/v1/twitter/get_post_comments_v1