X(Twitter) · 内容详情
账号的推文
传入用户名或主页链接,返回每个账号的推文(从新到旧),含文本、各项计数、时间、媒体和作者信息。
POST/v1/twitter/userTweets
怎么发
用 POST 带 JSON 请求体,或者用 GET 把同样的参数放进查询串。key 放在 Authorization 头里。
curl -X POST "https://api.silklinedata.com/v1/twitter/userTweets" \
-H "Authorization: Bearer $SILKLINE_KEY" \
-H "Content-Type: application/json" \
-d '{"limit":5,"handles":["nasa"]}'import os, requests
response = requests.post(
"https://api.silklinedata.com/v1/twitter/userTweets",
headers={"Authorization": "Bearer " + os.environ["SILKLINE_KEY"]},
json={
"limit": 5,
"handles": ["nasa"],
},
)
answer = response.json()
print(answer["data"], answer["meta"]["charged_usd"])const response = await fetch("https://api.silklinedata.com/v1/twitter/userTweets", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.SILKLINE_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"limit": 5,
"handles": [
"nasa"
]
}),
});
const { data, cursor, meta } = await response.json();
console.log(data, meta.charged_usd);返回什么
这是 2026-11-21 一次真实请求返回的记录。普通用户的名字、头像和主页链接显示为 <masked>;长文字只在这里截短,接口里是完整的。
{
"data": [
{
"type": "tweet",
"tweetId": "2123907405339582769",
"url": "https://x.com/NASA/status/21239074053…",
"text": "RT @N***: Another week of exploration…",
"lang": "en",
"createdAt": "2026-11-20T22:32:40Z",
"viewCount": 41545,
"likeCount": 0,
"retweetCount": 41,
"replyCount": 0,
"quoteCount": 0,
"bookmarkCount": 0,
"conversationId": "2123907405339582769",
"isRetweet": true,
"isQuote": false,
"isReply": false,
"inReplyToTweetId": null,
"retweetedTweetId": "2123892108893295099",
"retweetedAuthorHandle": "<masked>",
"retweetedText": "Another week of exploration, partners…",
"quotedTweetId": null,
"quotedAuthorHandle": null,
"quotedText": null,
"sensitive": null,
"source": "Twitter Web App",
"hashtags": [],
"mentions": [
"NASASpox",
"NASA",
"NASAAdmin"
],
"urls": [],
"mediaType": null,
"imageUrls": [],
"videoUrl": null,
"videoThumbnailUrl": null,
"videoDurationMs": null,
"mediaUrls": [],
"authorHandle": "<masked>",
"authorName": "<masked>",
"authorId": "<masked>",
"authorFollowers": "<masked>",
"authorVerified": "<masked>",
"authorAvatarUrl": "<masked>",
"authorBio": null,
"authorLocation": null,
"authorFollowing": null,
"authorLikeCount": null,
"authorCreatedAt": null,
"authorVerifiedType": null,
"authorCoverUrl": null,
"authorUrl": null,
"sourceHandle": "<masked>"
},
{
"type": "tweet",
"tweetId": "2123837600607949296",
"url": "https://x.com/NASA/status/21238376006…",
"text": "RT @N***: Millions of people fly ever…",
"lang": "en",
"createdAt": "2026-11-20T17:55:17Z",
"viewCount": 45398,
"likeCount": 0,
"retweetCount": 90,
"replyCount": 0,
"quoteCount": 0,
"bookmarkCount": 0,
"conversationId": "2123837600607949296",
"isRetweet": true,
"isQuote": false,
"isReply": false,
"inReplyToTweetId": null,
"retweetedTweetId": "2123830179617186024",
"retweetedAuthorHandle": "<masked>",
"retweetedText": "Millions of people fly every day, but…",
"quotedTweetId": null,
"quotedAuthorHandle": null,
"quotedText": null,
"sensitive": null,
"source": "Twitter Web App",
"hashtags": [],
"mentions": [
"NASASolarSystem"
],
"urls": [],
"mediaType": null,
"imageUrls": [],
"videoUrl": null,
"videoThumbnailUrl": null,
"videoDurationMs": null,
"mediaUrls": [],
"authorHandle": "<masked>",
"authorName": "<masked>",
"authorId": "<masked>",
"authorFollowers": "<masked>",
"authorVerified": "<masked>",
"authorAvatarUrl": "<masked>",
"authorBio": null,
"authorLocation": null,
"authorFollowing": null,
"authorLikeCount": null,
"authorCreatedAt": null,
"authorVerifiedType": null,
"authorCoverUrl": null,
"authorUrl": null,
"sourceHandle": "<masked>"
}
],
"cursor": "c1.Hq8vR2mTn5wK.yJ0dXA…",
"meta": {
"request_id": "req_01JD8Q…",
"charged_usd": "0.001420",
"balance_usd": "9.875000",
"items": 2
}
}字段 49
| 字段 | 类型 | 示例值 |
|---|---|---|
| type | string | tweet |
| tweetId | string | 2123907405339582769 |
| url | string | https://x.com/NASA/status/2123907405339582769 |
| text | string | RT @N***: Another week of exploration, partnership, and disc… |
| lang | string | en |
| createdAt | string | 2026-11-20T22:32:40Z |
| viewCount | number | 41545 |
| likeCount | number | 0 |
| retweetCount | number | 41 |
| replyCount | number | 0 |
| quoteCount | number | 0 |
| bookmarkCount | number | 0 |
| conversationId | string | 2123907405339582769 |
| isRetweet | boolean | true |
| isQuote | boolean | false |
| isReply | boolean | false |
| inReplyToTweetId | null | null |
| retweetedTweetId | string | 2123892108893295099 |
| retweetedAuthorHandle | string | <masked> |
| retweetedText | string | Another week of exploration, partnership, and discovery at @… |
| quotedTweetId | null | null |
| quotedAuthorHandle | null | null |
| quotedText | null | null |
| sensitive | null | null |
| source | string | Twitter Web App |
| hashtags | array | [] |
| mentions | array | ["NASASpox","NASA","NASAAdmin"] |
| urls | array | [] |
| mediaType | null | null |
| imageUrls | array | [] |
| videoUrl | null | null |
| videoThumbnailUrl | null | null |
| videoDurationMs | null | null |
| mediaUrls | array | [] |
| authorHandle | string | <masked> |
| authorName | string | <masked> |
| authorId | string | <masked> |
| authorFollowers | string | <masked> |
| authorVerified | string | <masked> |
| authorAvatarUrl | string | <masked> |
| authorBio | null | null |
| authorLocation | null | null |
| authorFollowing | null | null |
| authorLikeCount | null | null |
| authorCreatedAt | null | null |
| authorVerifiedType | null | null |
| authorCoverUrl | null | null |
| authorUrl | null | null |
| sourceHandle | string | <masked> |
参数 2
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| limit | integer | 否 | 返回的记录条数,1 到 100。一次请求返回的条数不会超过这个数。 | 5 |
| handles | array | 是 | X 用户名(@name 或 name)或主页链接(https://x.com/name 或 https://twitter.com/name)。每个账号按从新到旧返回其推文,包括主页上显示的转推和回复。 | ["nasa"] |
翻页
把上一次返回的 cursor 连同同样的参数传回来,拿下一页。每一页是一次独立的请求,单独计费;最后一页的 cursor 是 null。
const params = {"handles":["nasa"]};
const records = [];
let cursor = null;
do {
const response = await fetch("https://api.silklinedata.com/v1/twitter/userTweets", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.SILKLINE_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ ...params, limit: 100, ...(cursor ? { cursor } : {}) }),
});
const answer = await response.json();
records.push(...answer.data);
cursor = answer.cursor;
} while (cursor);
console.log(records.length);一次请求花多少
按条计费;一次请求条数少或没有结果时,每取一页收费不超过这个接口每页的最低收费,可能更低;我们这边出错或超时不收费。
这个接口一页最多 15 条,每页最低收费 $0.00142;要 100 条的请求会取 7 页。
- 1 条:最多 $0.00142
- 20 条:最多 $0.0046
- 100 条:最多 $0.023
返回的 meta 里写着这次扣了多少(charged_usd)和还剩多少(balance_usd)。我们这边出错不收费。
常见问题
「账号的推文」要传哪些参数?
必填:handles。另外都可以传 limit(1 到 100)。
一次请求最多返回多少条?
每次请求最多 100 条(limit 1 到 100)。每页最多 15 条,要 100 条时一次请求取 7 页。
能接着往后取吗?
能。回答里有 cursor 时,带上同样的参数和这个 cursor 再请求一次,就从上次停下的地方接着取。
怎么收费?
每条 记录 $0.00023。每页最低收费 $0.00142:条数少或没有结果时,每取一页最多收这么多,可能更低。取 100 条最多 $0.023。
请求失败或者没有结果时怎么收费?
按条计费;一次请求条数少或没有结果时,每取一页收费不超过这个接口每页的最低收费,可能更低;我们这边出错或超时不收费。回答里的 meta 写着这次收了多少、余额还剩多少。