X 用户发布帖子
通过 Rest ID 检索 X (Twitter) 用户发布的帖子,使用游标分页。用于浏览已知账号的时间线或继续获取其公开帖子历史。
GET
/v1/twitter/get_user_posts_v1
$0.02
- 价格
- $0.02 / 次成功调用,失败不收费
- 接口 ID
twitter.get_user_posts_v1
参数
-
rest_idstring 必填X 用户的唯一数字标识符(Rest ID)。
示例
11348282 -
cursorstring 可选用于浏览长时线内容的分页游标。
代码示例
curl -G "https://api.mofa-ai.com/v1/twitter/get_user_posts_v1" \
-H "Authorization: Bearer $MOFA_API_KEY" \
--data-urlencode 'rest_id=11348282'
import os
import requests
resp = requests.get(
"https://api.mofa-ai.com/v1/twitter/get_user_posts_v1",
headers={"Authorization": f"Bearer {os.environ['MOFA_API_KEY']}"},
params={
"rest_id": "11348282",
},
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/get_user_posts_v1");
url.search = new URLSearchParams({
rest_id: "11348282",
});
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);
响应示例
请求参数 {"rest_id": "11348282"}
JSON
{
"success": true,
"code": 0,
"message": "success",
"request_id": "req_5f1c2a9be04d7c3a81f6e2d0",
"endpoint": "twitter.get_user_posts_v1",
"cost_usd": 0.02,
"data": {
"code": 0,
"data": {
"user": {
"id": "11348282",
"desc": null,
"name": "NASA",
"avatar": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg",
"friends": null,
"profile": "NASA",
"location": "Pale Blue Dot",
"protected": false,
"sub_count": null,
"affiliates": [],
"created_at": "Wed Dec 19 20:20:32 +0000 2007",
"media_count": null,
"header_image": null,
"blue_verified": true,
"statuses_count": null
},
"pinned": {
"lang": "en",
"text": "LIVE: @NASAAdmin and agency leaders are sharing our latest updates on the Moon Base, humanity's first lunar outpost. https://t.co/UN6JuBhFcr",
"media": [],
"views": "233111",
"author": {
"name": "NASA",
"avatar": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg",
"rest_id": "11348282",
"screen_name": "NASA",
"blue_verified": true,
"followers_count": 92275568
},
"quotes": 15,
"source": null,
"replies": 86,
"retweets": 154,
"tweet_id": "2119188276049228152",
"bookmarks": 77,
"favorites": 785,
"sensitive": false,
"created_at": "Sat Nov 07 22:00:32 +0000 2026",
"conversation_id": "2119188276049228152"
},
"status": "ok",
"timeline": [
{
"lang": "en",
"text": "RT @NASAMoonBase: New awards. New mission updates. More progress toward a Moon Base.\n\nWe're advancing commercial lunar deliveries, a nuclea…",
"media": [],
"views": "32835",
"author": {
"name": "NASA",
"avatar": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg",
"rest_id": "11348282",
"screen_name": "NASA",
"blue_verified": true,
"followers_count": 92275568
},
"quotes": 0,
"source": "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>",
"replies": 0,
"entities": {
"user_mentions": [
{
"name": "NASA Moon Base",
"id_str": "2031457713868386305",
"screen_name": "NASAMoonBase"
}
]
},
"retweets": 138,
"tweet_id": "2119201242320904516",
"bookmarks": 0,
"favorites": 0,
"retweeted": {
"id": "2119200929719472530"
},
"sensitive": null,
"created_at": "Sat Nov 07 22:52:03 +0000 2026",
"conversation_id": "2119201242320904516",
"retweeted_tweet": {
"lang": "en",
"text": "New awards. New mission updates. More progress toward a Moon Base.\n\nWe're advancing commercial lunar deliveries, a nuclear-powered rover, launch and orbital transfer services, and infrastructure to su…",
"media": [],
"views": "83254",
"author": {
"name": "NASA Moon Base",
"avatar": "https://pbs.twimg.com/profile_images/2090513058099494912/dBwj4x3V_normal.jpg",
"rest_id": "2031457713868386305",
"screen_name": "NASAMoonBase",
"blue_verified": true
},
"quotes": 23,
"replies": 22,
"entities": {
"urls": [
{
"url": "https://t.co/Yt7oqpvLk5",
"indices": [
246,
269
],
"display_url": "nasa.gov/news-release/n…",
"expanded_url": "https://www.nasa.gov/news-release/nasa-awards-moon-base-transportation-technology-science-projects/"
}
]
},
"retweets": 138,
"tweet_id": "2119200929719472530",
"bookmarks": 60,
"favorites": 774,
"sensitive": false,
"created_at": "Sat Nov 07 22:50:49 +0000 2026",
"conversation_id": "2119200929719472530"
}
},
{
"lang": "en",
"text": "Do you want to be an astronaut?\n\nApplications are now open to join NASA's astronaut corps. Join us as we expand the frontiers of discovery in low Earth orbit, on the Moon, and beyond — apply by Dec. 3…",
"media": {
"video": [
{
"id": "2119136507600531456",
"duration": 63463,
"variants": [
{
"url": "https://video.twimg.com/amplify_video/2119136507600531456/pl/8NB31njy-D7yFExo.m3u8?tag=16&v=f45",
"content_type": "application/x-mpegURL"
},
{
"url": "https://video.twimg.com/amplify_video/2119136507600531456/vid/avc1/320x568/gGTh1w80J_mIIY7P.mp4?tag=16",
"bitrate": 632000,
"content_type": "video/mp4"
},
"… +3"
],
"aspect_ratio": [
9,
16
],
"original_info": {
"width": 1080,
"height": 1920,
"focus_rects": []
},
"media_url_https": "https://pbs.twimg.com/media/HWivgtWW8AEKfEF.jpg"
}
]
},
"views": "251212",
"author": {
"name": "NASA",
"avatar": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg",
"rest_id": "11348282",
"screen_name": "NASA",
"blue_verified": true,
"followers_count": 92275568
},
"quotes": 74,
"source": null,
"replies": 177,
"entities": {
"urls": [
{
"url": "https://t.co/laY2ExWiGO",
"display_url": "go.nasa.gov/4iGqLqu",
"expanded_url": "https://go.nasa.gov/4iGqLqu"
}
]
},
"retweets": 342,
"tweet_id": "2119136607009734978",
"bookmarks": 185,
"favorites": 1588,
"sensitive": false,
"created_at": "Sat Nov 07 18:35:13 +0000 2026",
"conversation_id": "2119136607009734978"
},
"… +13"
],
"next_cursor": "DAAHCgABHWj56Pu___ELAAIAAAATMjExODM3ODg3OTA1MjEyMDM1OQgAAwAAAAIAAA",
"prev_cursor": "DAAHCgABHWj56PvAJxELAAIAAAATMjExOTIwMTI0MjMyMDkwNDUxNggAAwAAAAEAAA"
},
"message": null,
…
示例较长,此处截断显示。
在线试用
登录后可以在这里直接调用此接口,按价格从余额扣费,失败不收费。新账户赠送 $0.50 试用额度。
X 的其他接口
-
搜索时间线
$0.02按关键词搜索 X (Twitter),支持热门、最新、媒体、用户或列表结果模式,使用游标分页。用于查找与话题相关的公开对话、账号、媒体或列表。
/v1/twitter/search_v1
-
用户资料
$0.02通过数字 Rest ID 检索 X (Twitter) 用户资料。用于在监控帖子或进行创作者与账号研究前,查看已知账号信息。
/v1/twitter/get_user_detail_v1
-
帖子评论
$0.02通过推文 ID 检索 X (Twitter) 帖子的最新评论,使用游标分页。用于查看已知帖子的近期讨论,并翻页获取更多评论。
/v1/twitter/get_post_comments_v1