twitter-api-v2
Advanced tools
Comparing version 1.6.5 to 1.7.0
@@ -0,1 +1,8 @@ | ||
1.7.0 | ||
----- | ||
- Feat: Create tweet v2 endpoint (thanks to @sudo-kaizen) #110 | ||
- Feat: Delete tweet v2 endpoint (thanks to @sudo-kaizen) #111 | ||
- Feat: Tweet thread and reply to a tweet v2 | ||
- Fix: BREAKING: Explicitly specify userId on userMutingUsers (thanks to @mika-f) #114 | ||
1.6.5 | ||
@@ -2,0 +9,0 @@ ----- |
@@ -74,2 +74,8 @@ "use strict"; | ||
} | ||
else if (this._clientId) { | ||
return { | ||
type: 'oauth2-user', | ||
clientId: this._clientId, | ||
}; | ||
} | ||
return { type: 'none' }; | ||
@@ -76,0 +82,0 @@ } |
@@ -34,2 +34,6 @@ export declare enum ETwitterStreamEvent { | ||
} | ||
export interface IClientOAuth2UserClient { | ||
clientId: string; | ||
type: 'oauth2-user'; | ||
} | ||
export interface IClientTokenBasic { | ||
@@ -49,2 +53,2 @@ token: string; | ||
} | ||
export declare type TClientTokens = IClientTokenNone | IClientTokenBearer | IClientTokenOauth | IClientTokenBasic; | ||
export declare type TClientTokens = IClientTokenNone | IClientTokenBearer | IClientTokenOauth | IClientTokenBasic | IClientOAuth2UserClient; |
@@ -143,2 +143,25 @@ import type { UserV2 } from './user.v2.types'; | ||
export declare type TweetPromotedMetricsV2 = TweetOrganicMetricsV2; | ||
export declare type TTweetReplySettingsV2 = 'mentionedUsers' | 'following' | 'everyone'; | ||
export interface SendTweetV2Params { | ||
direct_message_deep_link?: string; | ||
for_super_followers_only?: 'True' | 'False'; | ||
geo?: { | ||
place_id: string; | ||
}; | ||
media?: { | ||
media_ids?: string[]; | ||
tagged_user_ids?: string[]; | ||
}; | ||
poll?: { | ||
duration_minutes: number; | ||
options: string[]; | ||
}; | ||
quote_tweet_id?: string; | ||
reply?: { | ||
exclude_reply_user_ids?: string[]; | ||
in_reply_to_tweet_id: string; | ||
}; | ||
reply_settings?: TTweetReplySettingsV2 | string; | ||
text?: string; | ||
} | ||
export interface TweetV2 { | ||
@@ -145,0 +168,0 @@ id: string; |
@@ -89,2 +89,6 @@ /// <reference types="node" /> | ||
}; | ||
export declare type TweetV2PostTweetResult = DataV2<{ | ||
id: string; | ||
text: string; | ||
}>; | ||
export declare type TweetV2HideReplyResult = DataV2<{ | ||
@@ -103,2 +107,5 @@ hidden: boolean; | ||
}, ApiV2Includes>; | ||
export declare type TweetV2DeleteTweetResult = DataV2<{ | ||
deleted: boolean; | ||
}>; | ||
export interface BatchComplianceJobV2 { | ||
@@ -105,0 +112,0 @@ resumable: false; |
@@ -134,3 +134,3 @@ import TwitterApiSubClient from '../client.subclient'; | ||
*/ | ||
userMutingUsers(options?: Partial<UserV2TimelineParams>): Promise<UserMutingUsersV2Paginator>; | ||
userMutingUsers(userId: string, options?: Partial<UserV2TimelineParams>): Promise<UserMutingUsersV2Paginator>; | ||
/** | ||
@@ -137,0 +137,0 @@ * Get a single space by ID. |
@@ -247,4 +247,3 @@ "use strict"; | ||
*/ | ||
async userMutingUsers(options = {}) { | ||
const { id_str: userId } = await this.getCurrentUserObject(); | ||
async userMutingUsers(userId, options = {}) { | ||
const params = { id: userId }; | ||
@@ -251,0 +250,0 @@ const initialRq = await this.get('users/:id/muting', options, { fullResponse: true, params }); |
import TwitterApiv2ReadOnly from './client.v2.read'; | ||
import type { ListCreateV2Params, ListCreateV2Result, ListDeleteV2Result, ListFollowV2Result, ListMemberV2Result, ListPinV2Result, ListUpdateV2Params, ListUpdateV2Result, TweetV2HideReplyResult, TweetV2LikeResult, TweetV2RetweetResult, UserV2BlockResult, UserV2FollowResult, UserV2MuteResult, UserV2UnfollowResult } from '../types'; | ||
import type { ListCreateV2Params, ListCreateV2Result, ListDeleteV2Result, ListFollowV2Result, ListMemberV2Result, ListPinV2Result, ListUpdateV2Params, ListUpdateV2Result, TweetV2DeleteTweetResult, SendTweetV2Params, TweetV2HideReplyResult, TweetV2LikeResult, TweetV2PostTweetResult, TweetV2RetweetResult, UserV2BlockResult, UserV2FollowResult, UserV2MuteResult, UserV2UnfollowResult } from '../types'; | ||
import TwitterApiv2LabsReadWrite from '../v2-labs/client.v2.labs.write'; | ||
@@ -54,2 +54,23 @@ /** | ||
/** | ||
* Creates a Tweet on behalf of an authenticated user. | ||
* https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets | ||
*/ | ||
tweet(status: string, payload?: Partial<SendTweetV2Params>): Promise<TweetV2PostTweetResult>; | ||
tweet(payload: SendTweetV2Params): Promise<TweetV2PostTweetResult>; | ||
/** | ||
* Reply to a Tweet on behalf of an authenticated user. | ||
* https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets | ||
*/ | ||
reply(status: string, toTweetId: string, payload?: Partial<SendTweetV2Params>): Promise<TweetV2PostTweetResult>; | ||
/** | ||
* Post a series of tweets. | ||
* https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets | ||
*/ | ||
tweetThread(tweets: (SendTweetV2Params | string)[]): Promise<TweetV2PostTweetResult[]>; | ||
/** | ||
* Allows a user or authenticated user ID to delete a Tweet | ||
* https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/delete-tweets-id | ||
*/ | ||
deleteTweet(tweetId: string): Promise<TweetV2DeleteTweetResult>; | ||
/** | ||
* Allows a user ID to follow another user. | ||
@@ -56,0 +77,0 @@ * If the target user does not have public Tweets, this endpoint will send a follow request. |
@@ -82,2 +82,55 @@ "use strict"; | ||
} | ||
tweet(status, payload = {}) { | ||
if (typeof status === 'object') { | ||
payload = status; | ||
} | ||
else { | ||
payload = { text: status, ...payload }; | ||
} | ||
return this.post('tweets', payload); | ||
} | ||
/** | ||
* Reply to a Tweet on behalf of an authenticated user. | ||
* https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets | ||
*/ | ||
reply(status, toTweetId, payload = {}) { | ||
var _a; | ||
const reply = { in_reply_to_tweet_id: toTweetId, ...(_a = payload.reply) !== null && _a !== void 0 ? _a : {} }; | ||
return this.post('tweets', { text: status, ...payload, reply }); | ||
} | ||
/** | ||
* Post a series of tweets. | ||
* https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets | ||
*/ | ||
async tweetThread(tweets) { | ||
var _a, _b; | ||
const postedTweets = []; | ||
for (const tweet of tweets) { | ||
// Retrieve the last sent tweet | ||
const lastTweet = postedTweets.length ? postedTweets[postedTweets.length - 1] : null; | ||
// Build the tweet query params | ||
const queryParams = { ...(typeof tweet === 'string' ? ({ text: tweet }) : tweet) }; | ||
// Reply to an existing tweet if needed | ||
const inReplyToId = lastTweet ? lastTweet.data.id : (_a = queryParams.reply) === null || _a === void 0 ? void 0 : _a.in_reply_to_tweet_id; | ||
const status = (_b = queryParams.text) !== null && _b !== void 0 ? _b : ''; | ||
if (inReplyToId) { | ||
postedTweets.push(await this.reply(status, inReplyToId, queryParams)); | ||
} | ||
else { | ||
postedTweets.push(await this.tweet(status, queryParams)); | ||
} | ||
} | ||
return postedTweets; | ||
} | ||
/** | ||
* Allows a user or authenticated user ID to delete a Tweet | ||
* https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/delete-tweets-id | ||
*/ | ||
deleteTweet(tweetId) { | ||
return this.delete('tweets/:id', undefined, { | ||
params: { | ||
id: tweetId, | ||
}, | ||
}); | ||
} | ||
/* Users */ | ||
@@ -84,0 +137,0 @@ /** |
{ | ||
"name": "twitter-api-v2", | ||
"version": "1.6.5", | ||
"version": "1.7.0", | ||
"description": "Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
401014
8943