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:789Methods
getInsights28hr
▸ getInsights28hr(tweetIds, granularity, requestedMetrics, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:842 ▸ getInsights28hr(tweetIds, granularity, requestedMetrics, options?): Promise<Get2Insights28hrResponse>
Parameters
| Name | Type |
|---|---|
tweetIds | any[] |
granularity | string |
requestedMetrics | any[] |
options? | GetInsights28hrOptions |
Returns
Promise<Get2Insights28hrResponse>
Defined in
posts/client.ts:863getAnalytics
▸ getAnalytics(ids, endTime, startTime, granularity, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:1052 ▸ getAnalytics(ids, endTime, startTime, granularity, options?): Promise<Analytics>
Parameters
| Name | Type |
|---|---|
ids | any[] |
endTime | string |
startTime | string |
granularity | string |
options? | GetAnalyticsOptions |
Returns
Promise<Analytics>
Defined in
posts/client.ts:1077getReposts
▸ getReposts(id, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:1271 ▸ getReposts(id, options?): Promise<Get2TweetsIdRetweetsResponse>
Parameters
| Name | Type |
|---|---|
id | string |
options? | GetRepostsOptions |
Returns
Promise<Get2TweetsIdRetweetsResponse>
Defined in
posts/client.ts:1284searchRecent
▸ searchRecent(query, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:1559 ▸ searchRecent(query, options?): Promise<Get2TweetsSearchRecentResponse>
Parameters
| Name | Type |
|---|---|
query | string |
options? | SearchRecentOptions |
Returns
Promise<Get2TweetsSearchRecentResponse>
Defined in
posts/client.ts:1572searchAll
▸ searchAll(query, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:1968 ▸ searchAll(query, options?): Promise<Get2TweetsSearchAllResponse>
Parameters
| Name | Type |
|---|---|
query | string |
options? | SearchAllOptions |
Returns
Promise<Get2TweetsSearchAllResponse>
Defined in
posts/client.ts:1981getByIds
▸ getByIds(ids, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:2365 ▸ getByIds(ids, options?): Promise<Get2TweetsResponse>
Parameters
| Name | Type |
|---|---|
ids | any[] |
options? | GetByIdsOptions |
Returns
Promise<Get2TweetsResponse>
Defined in
posts/client.ts:2378create
▸ create(body, options): Promise<Response>
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 |
options | Object | - |
options.requestOptions | Object | - |
options.requestOptions.raw | true | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:2622 ▸ create(body): Promise<TweetCreateResponse>
Parameters
| Name | Type |
|---|---|
body | TweetCreateRequest |
Returns
Promise<TweetCreateResponse>
Defined in
posts/client.ts:2633getQuoted
▸ getQuoted(id, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:2718 ▸ getQuoted(id, options?): Promise<Get2TweetsIdQuoteTweetsResponse>
Parameters
| Name | Type |
|---|---|
id | string |
options? | GetQuotedOptions |
Returns
Promise<Get2TweetsIdQuoteTweetsResponse>
Defined in
posts/client.ts:2731getCountsRecent
▸ getCountsRecent(query, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:3025 ▸ getCountsRecent(query, options?): Promise<Get2TweetsCountsRecentResponse>
Parameters
| Name | Type |
|---|---|
query | string |
options? | GetCountsRecentOptions |
Returns
Promise<Get2TweetsCountsRecentResponse>
Defined in
posts/client.ts:3038hideReply
▸ hideReply(tweetId, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:3298 ▸ hideReply(tweetId, options?): Promise<TweetHideResponse>
Parameters
| Name | Type |
|---|---|
tweetId | string |
options? | HideReplyOptions |
Returns
Promise<TweetHideResponse>
Defined in
posts/client.ts:3311getInsightsHistorical
▸ getInsightsHistorical(tweetIds, endTime, startTime, granularity, requestedMetrics, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:3435 ▸ getInsightsHistorical(tweetIds, endTime, startTime, granularity, requestedMetrics, options?): Promise<Get2InsightsHistoricalResponse>
Parameters
| Name | Type |
|---|---|
tweetIds | any[] |
endTime | string |
startTime | string |
granularity | string |
requestedMetrics | any[] |
options? | GetInsightsHistoricalOptions |
Returns
Promise<Get2InsightsHistoricalResponse>
Defined in
posts/client.ts:3464getCountsAll
▸ getCountsAll(query, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:3679 ▸ getCountsAll(query, options?): Promise<Get2TweetsCountsAllResponse>
Parameters
| Name | Type |
|---|---|
query | string |
options? | GetCountsAllOptions |
Returns
Promise<Get2TweetsCountsAllResponse>
Defined in
posts/client.ts:3692getById
▸ getById(id, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:3952 ▸ getById(id, options?): Promise<Get2TweetsIdResponse>
Parameters
| Name | Type |
|---|---|
id | string |
options? | GetByIdOptions |
Returns
Promise<Get2TweetsIdResponse>
Defined in
posts/client.ts:3965delete
▸ delete(id, options): Promise<Response>
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. |
options | Object | - |
options.requestOptions | Object | - |
options.requestOptions.raw | true | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:4202 ▸ delete(id): Promise<TweetDeleteResponse>
Parameters
| Name | Type |
|---|---|
id | string |
Returns
Promise<TweetDeleteResponse>
Defined in
posts/client.ts:4215getLikingUsers
▸ getLikingUsers(id, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:4306 ▸ getLikingUsers(id, options?): Promise<Get2TweetsIdLikingUsersResponse>
Parameters
| Name | Type |
|---|---|
id | string |
options? | GetLikingUsersOptions |
Returns
Promise<Get2TweetsIdLikingUsersResponse>
Defined in
posts/client.ts:4319getRepostedBy
▸ getRepostedBy(id, options): Promise<Response>
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 & { requestOptions: { raw: true } } | - |
Returns
Promise<Response>
Promise resolving to the API response, or raw Response if requestOptions.raw is true
Defined in
posts/client.ts:4525 ▸ getRepostedBy(id, options?): Promise<Get2TweetsIdRetweetedByResponse>
Parameters
| Name | Type |
|---|---|
id | string |
options? | GetRepostedByOptions |
Returns
Promise<Get2TweetsIdRetweetedByResponse>