跳转到主要内容
用于 Post 操作的客户端 该客户端提供与 X API 的 posts 端点交互的方法。它负责处理所有与 Post 相关操作的身份验证、请求格式化和响应解析。

构造器

构造函数

new PostsClient(client): PostsClient 创建一个新的 Posts 客户端实例

参数

名称类型描述
clientClientX API 的主要客户端实例

返回值

PostsClient

定义于

posts/client.ts:453

方法

getInsights28hr

getInsights28hr(tweetIds, granularity, requestedMetrics, options?): Promise<Get2Insights28hrResponse> 获取 28 小时的 Post 洞察 检索过去 28 小时内指定 Post 的互动指标。

参数

名称类型描述
tweetIdsany[]用于 28 小时指标的 Post id 列表。
granularitystring指标返回结果的粒度。
requestedMetricsany[]历史查询所请求的指标。
optionsGetInsights28hrOptions-

返回

Promise<Get2Insights28hrResponse> 解析为 API 响应的 Promise

定义于

posts/client.ts:478

searchRecent

searchRecent(query, options?): Promise<Get2TweetsSearchRecentResponse> 搜索最近的 Post 检索过去 7 天内与搜索查询匹配的 Post。

参数

名称类型描述
querystring用于匹配 Post 的单条查询/规则/过滤条件。请参阅 https://t.co/rulelength 以了解最大查询长度。
optionsSearchRecentOptions-

返回

Promise<Get2TweetsSearchRecentResponse> 一个会解析为 API 响应的 Promise

定义于

posts/client.ts:540

getRepostedBy

getRepostedBy(id, options?): Promise<Get2TweetsIdRetweetedByResponse> 获取转发者 根据其 ID 获取将该特定 Post 转发的用户列表。

参数

名称类型说明
idstring单个 Post 的 ID。
optionsGetRepostedByOptions-

返回

Promise<Get2TweetsIdRetweetedByResponse> 解析为 API 响应的 Promise

定义于

posts/client.ts:670

getLikingUsers

getLikingUsers(id, options?): Promise<Get2TweetsIdLikingUsersResponse> 获取点赞用户 根据其 ID 获取对指定 Post 点赞的用户列表。

参数

名称类型描述
idstring单个 Post 的 ID。
optionsGetLikingUsersOptions-

返回

Promise<Get2TweetsIdLikingUsersResponse> 解析为 API 响应的 Promise

定义于

posts/client.ts:744

getInsightsHistorical

getInsightsHistorical(tweetIds, endTime, startTime, granularity, requestedMetrics, options?): Promise<Get2InsightsHistoricalResponse> 获取历史 Post 洞察 在指定时间范围内获取所选 Post 的历史互动指标。

参数

名称类型描述
tweetIdsany[]用于历史指标的 Post id 列表。
endTimestringYYYY-MM-DDTHH:mm:ssZ。表示时间范围结束的 UTC 时间戳。
startTimestringYYYY-MM-DDTHH:mm:ssZ。表示时间范围开始的 UTC 时间戳。
granularitystring指标结果的粒度。
requestedMetricsany[]历史查询所请求的指标。
optionsGetInsightsHistoricalOptions-

返回

Promise<Get2InsightsHistoricalResponse> 将解析为 API 响应的 Promise

定义于

posts/client.ts:834

getReposts

getReposts(id, options?): Promise<Get2TweetsIdRetweetsResponse> 获取转发 按其ID检索对特定 Post 的转发 Post 列表。

参数

名称类型说明
idstring单个 Post 的 id。
optionsGetRepostsOptions-

返回

Promise<Get2TweetsIdRetweetsResponse> 解析为 API 响应的 Promise

定义位置

posts/client.ts:906

hideReply

hideReply(tweetId, options?): Promise<TweetHideResponse> 隐藏回复 隐藏或取消隐藏经身份验证用户所拥有的会话中的某条回复。

参数

名称类型描述
tweetIdstring要隐藏或取消隐藏的回复的ID。
optionsHideReplyOptions-

返回

Promise<TweetHideResponse> 一个会解析为 API 响应的 Promise

定义于

posts/client.ts:998

getCountsRecent

getCountsRecent(query, options?): Promise<Get2TweetsCountsRecentResponse> 获取近期 Post 的数量 检索过去 7 天内与搜索查询匹配的 Post 数量。

参数

名称类型描述
querystring用于匹配 Post 的单个查询/规则/筛选条件。请参阅 https://t.co/rulelength 了解查询长度上限。
optionsGetCountsRecentOptions-

返回

Promise<Get2TweetsCountsRecentResponse> 解析为 API 响应的 Promise

定义位置

posts/client.ts:1046

getByIds

getByIds(ids, options?): Promise<Get2TweetsResponse> 按 ID 获取 Post 根据多个 Post 的 ID 获取其详细信息。

参数

名称类型描述
idsany[]以逗号分隔的 Post id 列表。单个请求最多可传入 100 个。
optionsGetByIdsOptions-

返回

Promise<Get2TweetsResponse> 解析为 API 响应的 Promise

定义于

posts/client.ts:1140

create

create(body): Promise<TweetCreateResponse> 创建或编辑 Post 为已通过身份验证的用户创建新的 Post;若提供 edit_options,则编辑现有的 Post。

参数

名称类型说明
bodyTweetCreateRequest请求体

返回

Promise<TweetCreateResponse> 解析为 API 响应的 Promise

定义于

posts/client.ts:1220

getById

getById(id, options?): Promise<Get2TweetsIdResponse> 按 ID 获取 Post 根据 ID 获取指定 Post 的详细信息。

参数

名称类型描述
idstring单个 Post 的 ID。
optionsGetByIdOptions-

返回

Promise<Get2TweetsIdResponse> 解析为 API 响应的 Promise

定义于

posts/client.ts:1258

delete

delete(id): Promise<TweetDeleteResponse> 删除 Post 如果由已认证用户拥有,则按其 ID 删除特定的 Post。

参数

名称类型说明
idstring要删除的 Post 的 id。

返回

Promise<TweetDeleteResponse> 解析为 API 响应的 Promise

定义于

posts/client.ts:1338

getAnalytics

getAnalytics(ids, endTime, startTime, granularity, options?): Promise<Analytics> 获取 Post 分析 在指定时间范围内检索所选 Post 的分析数据。

参数

名称类型描述
idsany[]以逗号分隔的 Post id 列表。单个请求最多可包含 100 个。
endTimestringYYYY-MM-DDTHH:mm:ssZ。表示时间范围结束的 UTC 时间戳。
startTimestringYYYY-MM-DDTHH:mm:ssZ。表示时间范围开始的 UTC 时间戳。
granularitystring搜索计数结果的粒度。
optionsGetAnalyticsOptions-

返回

Promise<Analytics> 解析为 API 响应的 Promise

定义于

posts/client.ts:1388

getCountsAll

getCountsAll(query, options?): Promise<Get2TweetsCountsAllResponse> 获取所有 Post 的数量 从完整存档中检索与搜索查询匹配的 Post 数量。

参数

名称类型说明
querystring用于匹配 Post 的单条查询/规则/过滤条件。请参阅 https://t.co/rulelength 了解最大查询长度。
optionsGetCountsAllOptions-

返回

Promise<Get2TweetsCountsAllResponse> 会解析为 API 响应的 Promise

定义于

posts/client.ts:1455

getQuoted

getQuoted(id, options?): Promise<Get2TweetsIdQuoteTweetsResponse> 获取引用的 Post 返回引用指定 Post(通过其 id)的 Post 列表。

参数

名称类型描述
idstring单个 Post 的 ID。
optionsGetQuotedOptions-

返回

Promise<Get2TweetsIdQuoteTweetsResponse> 解析为 API 响应的 Promise

定义于

posts/client.ts:1549

searchAll

searchAll(query, options?): Promise<Get2TweetsSearchAllResponse> 搜索所有 Post 从完整存档中检索与查询匹配的 Post。

参数

名称类型描述
querystring用于匹配 Post 的单个查询/规则/筛选。请参见 https://t.co/rulelength 了解最大查询长度。
optionsSearchAllOptions-

返回

Promise<Get2TweetsSearchAllResponse> 解析为 API 响应的 Promise

定义位置

posts/client.ts:1647