Constructors
constructor
• new PostsClient(client): PostsClient
Creates a new posts client instance
Parameters
| Name | Type | Description | 
|---|---|---|
client | Client | The main X API client instance | 
Returns
PostsClient
Defined in
posts/client.ts:453Methods
getInsights28hr
▸ getInsights28hr(tweetIds, granularity, requestedMetrics, options?): Promise<Get2Insights28hrResponse>
Get 28-hour Post insights
Retrieves engagement metrics for specified Posts over the last 28 hours.
Parameters
| Name | Type | Description | 
|---|---|---|
tweetIds | any[] | List of PostIds for 28hr metrics. | 
granularity | string | granularity of metrics response. | 
requestedMetrics | any[] | request metrics for historical request. | 
options | GetInsights28hrOptions | - | 
Returns
Promise<Get2Insights28hrResponse>
Promise resolving to the API response
Defined in
posts/client.ts:478searchRecent
▸ searchRecent(query, options?): Promise<Get2TweetsSearchRecentResponse>
Search recent Posts
Retrieves Posts from the last 7 days matching a search query.
Parameters
| Name | Type | Description | 
|---|---|---|
query | string | One query/rule/filter for matching Posts. Refer to https://t.co/rulelength to identify the max query length. | 
options | SearchRecentOptions | - | 
Returns
Promise<Get2TweetsSearchRecentResponse>
Promise resolving to the API response
Defined in
posts/client.ts:540getRepostedBy
▸ getRepostedBy(id, options?): Promise<Get2TweetsIdRetweetedByResponse>
Get Reposted by
Retrieves a list of Users who reposted a specific Post by its ID.
Parameters
| Name | Type | Description | 
|---|---|---|
id | string | A single Post ID. | 
options | GetRepostedByOptions | - | 
Returns
Promise<Get2TweetsIdRetweetedByResponse>
Promise resolving to the API response
Defined in
posts/client.ts:670getLikingUsers
▸ getLikingUsers(id, options?): Promise<Get2TweetsIdLikingUsersResponse>
Get Liking Users
Retrieves a list of Users who liked a specific Post by its ID.
Parameters
| Name | Type | Description | 
|---|---|---|
id | string | A single Post ID. | 
options | GetLikingUsersOptions | - | 
Returns
Promise<Get2TweetsIdLikingUsersResponse>
Promise resolving to the API response
Defined in
posts/client.ts:744getInsightsHistorical
▸ getInsightsHistorical(tweetIds, endTime, startTime, granularity, requestedMetrics, options?): Promise<Get2InsightsHistoricalResponse>
Get historical Post insights
Retrieves historical engagement metrics for specified Posts within a defined time range.
Parameters
| Name | Type | Description | 
|---|---|---|
tweetIds | any[] | List of PostIds for historical metrics. | 
endTime | string | YYYY-MM-DDTHH:mm:ssZ. The UTC timestamp representing the end of the time range. | 
startTime | string | YYYY-MM-DDTHH:mm:ssZ. The UTC timestamp representing the start of the time range. | 
granularity | string | granularity of metrics response. | 
requestedMetrics | any[] | request metrics for historical request. | 
options | GetInsightsHistoricalOptions | - | 
Returns
Promise<Get2InsightsHistoricalResponse>
Promise resolving to the API response
Defined in
posts/client.ts:834getReposts
▸ getReposts(id, options?): Promise<Get2TweetsIdRetweetsResponse>
Get Reposts
Retrieves a list of Posts that repost a specific Post by its ID.
Parameters
| Name | Type | Description | 
|---|---|---|
id | string | A single Post ID. | 
options | GetRepostsOptions | - | 
Returns
Promise<Get2TweetsIdRetweetsResponse>
Promise resolving to the API response
Defined in
posts/client.ts:906hideReply
▸ hideReply(tweetId, options?): Promise<TweetHideResponse>
Hide reply
Hides or unhides a reply to a conversation owned by the authenticated user.
Parameters
| Name | Type | Description | 
|---|---|---|
tweetId | string | The ID of the reply that you want to hide or unhide. | 
options | HideReplyOptions | - | 
Returns
Promise<TweetHideResponse>
Promise resolving to the API response
Defined in
posts/client.ts:998getCountsRecent
▸ getCountsRecent(query, options?): Promise<Get2TweetsCountsRecentResponse>
Get count of recent Posts
Retrieves the count of Posts from the last 7 days matching a search query.
Parameters
| Name | Type | Description | 
|---|---|---|
query | string | One query/rule/filter for matching Posts. Refer to https://t.co/rulelength to identify the max query length. | 
options | GetCountsRecentOptions | - | 
Returns
Promise<Get2TweetsCountsRecentResponse>
Promise resolving to the API response
Defined in
posts/client.ts:1046getByIds
▸ getByIds(ids, options?): Promise<Get2TweetsResponse>
Get Posts by IDs
Retrieves details of multiple Posts by their IDs.
Parameters
| Name | Type | Description | 
|---|---|---|
ids | any[] | A comma separated list of Post IDs. Up to 100 are allowed in a single request. | 
options | GetByIdsOptions | - | 
Returns
Promise<Get2TweetsResponse>
Promise resolving to the API response
Defined in
posts/client.ts:1140create
▸ create(body): Promise<TweetCreateResponse>
Create or Edit Post
Creates a new Post for the authenticated user, or edits an existing Post when edit_options are provided.
Parameters
| Name | Type | Description | 
|---|---|---|
body | TweetCreateRequest | Request body | 
Returns
Promise<TweetCreateResponse>
Promise resolving to the API response
Defined in
posts/client.ts:1220getById
▸ getById(id, options?): Promise<Get2TweetsIdResponse>
Get Post by ID
Retrieves details of a specific Post by its ID.
Parameters
| Name | Type | Description | 
|---|---|---|
id | string | A single Post ID. | 
options | GetByIdOptions | - | 
Returns
Promise<Get2TweetsIdResponse>
Promise resolving to the API response
Defined in
posts/client.ts:1258delete
▸ delete(id): Promise<TweetDeleteResponse>
Delete Post
Deletes a specific Post by its ID, if owned by the authenticated user.
Parameters
| Name | Type | Description | 
|---|---|---|
id | string | The ID of the Post to be deleted. | 
Returns
Promise<TweetDeleteResponse>
Promise resolving to the API response
Defined in
posts/client.ts:1338getAnalytics
▸ getAnalytics(ids, endTime, startTime, granularity, options?): Promise<Analytics>
Get Post analytics
Retrieves analytics data for specified Posts within a defined time range.
Parameters
| Name | Type | Description | 
|---|---|---|
ids | any[] | A comma separated list of Post IDs. Up to 100 are allowed in a single request. | 
endTime | string | YYYY-MM-DDTHH:mm:ssZ. The UTC timestamp representing the end of the time range. | 
startTime | string | YYYY-MM-DDTHH:mm:ssZ. The UTC timestamp representing the start of the time range. | 
granularity | string | The granularity for the search counts results. | 
options | GetAnalyticsOptions | - | 
Returns
Promise<Analytics>
Promise resolving to the API response
Defined in
posts/client.ts:1388getCountsAll
▸ getCountsAll(query, options?): Promise<Get2TweetsCountsAllResponse>
Get count of all Posts
Retrieves the count of Posts matching a search query from the full archive.
Parameters
| Name | Type | Description | 
|---|---|---|
query | string | One query/rule/filter for matching Posts. Refer to https://t.co/rulelength to identify the max query length. | 
options | GetCountsAllOptions | - | 
Returns
Promise<Get2TweetsCountsAllResponse>
Promise resolving to the API response
Defined in
posts/client.ts:1455getQuoted
▸ getQuoted(id, options?): Promise<Get2TweetsIdQuoteTweetsResponse>
Get Quoted Posts
Retrieves a list of Posts that quote a specific Post by its ID.
Parameters
| Name | Type | Description | 
|---|---|---|
id | string | A single Post ID. | 
options | GetQuotedOptions | - | 
Returns
Promise<Get2TweetsIdQuoteTweetsResponse>
Promise resolving to the API response
Defined in
posts/client.ts:1549searchAll
▸ searchAll(query, options?): Promise<Get2TweetsSearchAllResponse>
Search all Posts
Retrieves Posts from the full archive matching a search query.
Parameters
| Name | Type | Description | 
|---|---|---|
query | string | One query/rule/filter for matching Posts. Refer to https://t.co/rulelength to identify the max query length. | 
options | SearchAllOptions | - | 
Returns
Promise<Get2TweetsSearchAllResponse>
Promise resolving to the API response