rettiwt-api 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -11
- package/dist/Rettiwt.d.ts +37 -1
- package/dist/Rettiwt.js +37 -1
- package/dist/Rettiwt.js.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +39 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/Auth.d.ts +3 -0
- package/dist/commands/Auth.js +90 -0
- package/dist/commands/Auth.js.map +1 -0
- package/dist/commands/Tweet.d.ts +10 -0
- package/dist/commands/Tweet.js +242 -0
- package/dist/commands/Tweet.js.map +1 -0
- package/dist/commands/User.d.ts +10 -0
- package/dist/commands/User.js +162 -0
- package/dist/commands/User.js.map +1 -0
- package/dist/helper/CliUtils.d.ts +6 -0
- package/dist/helper/CliUtils.js +20 -0
- package/dist/helper/CliUtils.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/models/internal/RettiwtConfig.d.ts +1 -3
- package/dist/models/internal/RettiwtConfig.js +1 -0
- package/dist/models/internal/RettiwtConfig.js.map +1 -1
- package/dist/models/public/CursoredData.d.ts +0 -3
- package/dist/models/public/CursoredData.js +0 -1
- package/dist/models/public/CursoredData.js.map +1 -1
- package/dist/models/public/List.d.ts +0 -7
- package/dist/models/public/List.js.map +1 -1
- package/dist/models/public/Tweet.d.ts +0 -20
- package/dist/models/public/Tweet.js +0 -4
- package/dist/models/public/Tweet.js.map +1 -1
- package/dist/models/public/User.d.ts +0 -14
- package/dist/models/public/User.js.map +1 -1
- package/dist/services/internal/FetcherService.d.ts +7 -0
- package/dist/services/internal/FetcherService.js +23 -1
- package/dist/services/internal/FetcherService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +138 -0
- package/dist/services/public/TweetService.js +138 -0
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.d.ts +119 -0
- package/dist/services/public/UserService.js +119 -0
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/internal/RettiwtConfig.d.ts +2 -0
- package/package.json +5 -1
- package/src/Rettiwt.ts +37 -1
- package/src/cli.ts +40 -0
- package/src/commands/Auth.ts +45 -0
- package/src/commands/Tweet.ts +163 -0
- package/src/commands/User.ts +85 -0
- package/src/helper/CliUtils.ts +15 -0
- package/src/index.ts +2 -0
- package/src/models/internal/RettiwtConfig.ts +2 -5
- package/src/models/public/CursoredData.ts +0 -4
- package/src/models/public/List.ts +0 -13
- package/src/models/public/Tweet.ts +0 -37
- package/src/models/public/User.ts +0 -27
- package/src/services/internal/FetcherService.ts +25 -1
- package/src/services/public/TweetService.ts +138 -0
- package/src/services/public/UserService.ts +119 -0
- package/src/types/internal/RettiwtConfig.ts +3 -0
|
@@ -21,49 +21,20 @@ import { normalizeText } from '../../helper/JsonUtils';
|
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
export class Tweet implements ITweet {
|
|
24
|
-
/** The rest id of the tweet. */
|
|
25
24
|
public id: string;
|
|
26
|
-
|
|
27
|
-
/** The details of the user who made the tweet. */
|
|
28
25
|
public tweetBy: User;
|
|
29
|
-
|
|
30
|
-
/** The date and time of creation of the tweet, in UTC string format. */
|
|
31
26
|
public createdAt: string;
|
|
32
|
-
|
|
33
|
-
/** Additional tweet entities like urls, mentions, etc. */
|
|
34
27
|
public entities: TweetEntities;
|
|
35
|
-
|
|
36
|
-
/** The urls of the media contents of the tweet (if any). */
|
|
37
28
|
public media: TweetMedia[];
|
|
38
|
-
|
|
39
|
-
/** The rest id of the tweet which is quoted in the tweet. */
|
|
40
29
|
public quoted: string;
|
|
41
|
-
|
|
42
|
-
/** The full text content of the tweet. */
|
|
43
30
|
public fullText: string;
|
|
44
|
-
|
|
45
|
-
/** The rest id of the user to which the tweet is a reply. */
|
|
46
31
|
public replyTo: string;
|
|
47
|
-
|
|
48
|
-
/** The language in which the tweet is written. */
|
|
49
32
|
public lang: string;
|
|
50
|
-
|
|
51
|
-
/** The number of quotes of the tweet. */
|
|
52
33
|
public quoteCount: number;
|
|
53
|
-
|
|
54
|
-
/** The number of replies to the tweet. */
|
|
55
34
|
public replyCount: number;
|
|
56
|
-
|
|
57
|
-
/** The number of retweets of the tweet. */
|
|
58
35
|
public retweetCount: number;
|
|
59
|
-
|
|
60
|
-
/** The number of likes of the tweet. */
|
|
61
36
|
public likeCount: number;
|
|
62
|
-
|
|
63
|
-
/** The number of views of a tweet. */
|
|
64
37
|
public viewCount: number;
|
|
65
|
-
|
|
66
|
-
/** The number of bookmarks of a tweet. */
|
|
67
38
|
public bookmarkCount: number;
|
|
68
39
|
|
|
69
40
|
/**
|
|
@@ -96,13 +67,8 @@ export class Tweet implements ITweet {
|
|
|
96
67
|
* @public
|
|
97
68
|
*/
|
|
98
69
|
export class TweetEntities implements ITweetEntities {
|
|
99
|
-
/** The list of hashtags mentioned in the tweet. */
|
|
100
70
|
public hashtags: string[] = [];
|
|
101
|
-
|
|
102
|
-
/** The list of urls mentioned in the tweet. */
|
|
103
71
|
public urls: string[] = [];
|
|
104
|
-
|
|
105
|
-
/** The list of IDs of users mentioned in the tweet. */
|
|
106
72
|
public mentionedUsers: string[] = [];
|
|
107
73
|
|
|
108
74
|
/**
|
|
@@ -140,10 +106,7 @@ export class TweetEntities implements ITweetEntities {
|
|
|
140
106
|
* @public
|
|
141
107
|
*/
|
|
142
108
|
export class TweetMedia {
|
|
143
|
-
/** The type of media. */
|
|
144
109
|
public type: EMediaType;
|
|
145
|
-
|
|
146
|
-
/** The direct URL to the media. */
|
|
147
110
|
public url: string = '';
|
|
148
111
|
|
|
149
112
|
/**
|
|
@@ -10,46 +10,19 @@ import { IUser } from '../../types/public/User';
|
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
12
|
export class User implements IUser {
|
|
13
|
-
/** The rest id of the user. */
|
|
14
13
|
public id: string;
|
|
15
|
-
|
|
16
|
-
/** The username/screenname of the user. */
|
|
17
14
|
public userName: string;
|
|
18
|
-
|
|
19
|
-
/** The full name of the user. */
|
|
20
15
|
public fullName: string;
|
|
21
|
-
|
|
22
|
-
/** The creation date of user's account. */
|
|
23
16
|
public createdAt: string;
|
|
24
|
-
|
|
25
|
-
/** The user's description. */
|
|
26
17
|
public description: string;
|
|
27
|
-
|
|
28
|
-
/** Whether the account is verified or not. */
|
|
29
18
|
public isVerified: boolean;
|
|
30
|
-
|
|
31
|
-
/** The number of tweets liked by the user. */
|
|
32
19
|
public favouritesCount: number;
|
|
33
|
-
|
|
34
|
-
/** The number of followers of the user. */
|
|
35
20
|
public followersCount: number;
|
|
36
|
-
|
|
37
|
-
/** The number of following of the user. */
|
|
38
21
|
public followingsCount: number;
|
|
39
|
-
|
|
40
|
-
/** The number of tweets made by the user. */
|
|
41
22
|
public statusesCount: number;
|
|
42
|
-
|
|
43
|
-
/** The location of user as provided by user. */
|
|
44
23
|
public location: string;
|
|
45
|
-
|
|
46
|
-
/** The rest id of the tweet pinned in the user's profile. */
|
|
47
24
|
public pinnedTweet: string;
|
|
48
|
-
|
|
49
|
-
/** The url of the profile banner image. */
|
|
50
25
|
public profileBanner: string;
|
|
51
|
-
|
|
52
|
-
/** The url of the profile image. */
|
|
53
26
|
public profileImage: string;
|
|
54
27
|
|
|
55
28
|
/**
|
|
@@ -55,7 +55,18 @@ export class FetcherService {
|
|
|
55
55
|
* @param config - The config object for configuring the Rettiwt instance.
|
|
56
56
|
*/
|
|
57
57
|
public constructor(config?: RettiwtConfig) {
|
|
58
|
-
|
|
58
|
+
// If API key is supplied
|
|
59
|
+
if (config?.apiKey) {
|
|
60
|
+
this.cred = this.getAuthCredential(config.apiKey);
|
|
61
|
+
}
|
|
62
|
+
// If guest key is supplied
|
|
63
|
+
else if (config?.guestKey) {
|
|
64
|
+
this.cred = this.getGuestCredential(config.guestKey);
|
|
65
|
+
}
|
|
66
|
+
// If no key is supplied
|
|
67
|
+
else {
|
|
68
|
+
this.cred = undefined;
|
|
69
|
+
}
|
|
59
70
|
this.isAuthenticated = config?.apiKey ? true : false;
|
|
60
71
|
this.httpsAgent = this.getHttpsAgent(config?.proxyUrl);
|
|
61
72
|
this.logger = new LogService(config?.logging);
|
|
@@ -74,6 +85,19 @@ export class FetcherService {
|
|
|
74
85
|
return new AuthCredential(apiKey.split(';'));
|
|
75
86
|
}
|
|
76
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Returns an AuthCredential generated using the given guest key.
|
|
90
|
+
*
|
|
91
|
+
* @param guestKey - The guest key to use for authenticating as guest.
|
|
92
|
+
* @returns The generated AuthCredential.
|
|
93
|
+
*/
|
|
94
|
+
private getGuestCredential(guestKey: string): AuthCredential {
|
|
95
|
+
// Converting guestKey from base64 to string
|
|
96
|
+
guestKey = Buffer.from(guestKey).toString('ascii');
|
|
97
|
+
|
|
98
|
+
return new AuthCredential(undefined, guestKey);
|
|
99
|
+
}
|
|
100
|
+
|
|
77
101
|
/**
|
|
78
102
|
* Checks the authorization status based on the requested resource.
|
|
79
103
|
*
|
|
@@ -31,6 +31,23 @@ export class TweetService extends FetcherService {
|
|
|
31
31
|
* @param id - The id of the target tweet.
|
|
32
32
|
* @returns The details of a single tweet with the given tweet id.
|
|
33
33
|
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```
|
|
36
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
37
|
+
*
|
|
38
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
39
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
40
|
+
*
|
|
41
|
+
* // Fetching the details of the tweet with the id '12345678'
|
|
42
|
+
* rettiwt.tweet.details('12345678')
|
|
43
|
+
* .then(res => {
|
|
44
|
+
* console.log(res);
|
|
45
|
+
* })
|
|
46
|
+
* .catch(err => {
|
|
47
|
+
* console.log(err);
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
34
51
|
* @public
|
|
35
52
|
*/
|
|
36
53
|
public async details(id: string): Promise<Tweet> {
|
|
@@ -48,6 +65,25 @@ export class TweetService extends FetcherService {
|
|
|
48
65
|
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
49
66
|
* @returns The list of tweets that match the given filter.
|
|
50
67
|
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```
|
|
70
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
71
|
+
*
|
|
72
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
73
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
74
|
+
*
|
|
75
|
+
* // Fetching the most recent 5 tweets from user 'user1'
|
|
76
|
+
* rettiwt.tweet.search({ fromUsers: ['user1'] }, 5)
|
|
77
|
+
* .then(res => {
|
|
78
|
+
* console.log(res);
|
|
79
|
+
* })
|
|
80
|
+
* .catch(err => {
|
|
81
|
+
* console.log(err);
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @remarks For details about available filters, refer to {@link TweetFilter}
|
|
86
|
+
*
|
|
51
87
|
* @public
|
|
52
88
|
*/
|
|
53
89
|
public async search(query: TweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
@@ -72,6 +108,23 @@ export class TweetService extends FetcherService {
|
|
|
72
108
|
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
73
109
|
* @returns The list tweets present in the given list.
|
|
74
110
|
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```
|
|
113
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
114
|
+
*
|
|
115
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
116
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
117
|
+
*
|
|
118
|
+
* // Fetching the most recent 100 tweets of the Twitter list with id '12345678'
|
|
119
|
+
* rettiwt.tweet.list('12345678')
|
|
120
|
+
* .then(res => {
|
|
121
|
+
* console.log(res);
|
|
122
|
+
* })
|
|
123
|
+
* .catch(err => {
|
|
124
|
+
* console.log(err);
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
75
128
|
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
76
129
|
*/
|
|
77
130
|
public async list(listId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
@@ -96,6 +149,23 @@ export class TweetService extends FetcherService {
|
|
|
96
149
|
* @param cursor - The cursor to the batch of favoriters to fetch.
|
|
97
150
|
* @returns The list of users who liked the given tweet.
|
|
98
151
|
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```
|
|
154
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
155
|
+
*
|
|
156
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
157
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
158
|
+
*
|
|
159
|
+
* // Fetching the most recent 100 likers of the Tweet with id '12345678'
|
|
160
|
+
* rettiwt.tweet.favoriters('12345678')
|
|
161
|
+
* .then(res => {
|
|
162
|
+
* console.log(res);
|
|
163
|
+
* })
|
|
164
|
+
* .catch(err => {
|
|
165
|
+
* console.log(err);
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
99
169
|
* @public
|
|
100
170
|
*/
|
|
101
171
|
public async favoriters(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
@@ -117,6 +187,23 @@ export class TweetService extends FetcherService {
|
|
|
117
187
|
* @param cursor - The cursor to the batch of retweeters to fetch.
|
|
118
188
|
* @returns The list of users who retweeted the given tweet.
|
|
119
189
|
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```
|
|
192
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
193
|
+
*
|
|
194
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
195
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
196
|
+
*
|
|
197
|
+
* // Fetching the most recent 100 retweeters of the Tweet with id '12345678'
|
|
198
|
+
* rettiwt.tweet.retweeters('12345678')
|
|
199
|
+
* .then(res => {
|
|
200
|
+
* console.log(res);
|
|
201
|
+
* })
|
|
202
|
+
* .catch(err => {
|
|
203
|
+
* console.log(err);
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
120
207
|
* @public
|
|
121
208
|
*/
|
|
122
209
|
public async retweeters(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
@@ -136,6 +223,23 @@ export class TweetService extends FetcherService {
|
|
|
136
223
|
* @param tweetText - The text to be posted, length must be \<= 280 characters.
|
|
137
224
|
* @returns Whether posting was successful or not.
|
|
138
225
|
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```
|
|
228
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
229
|
+
*
|
|
230
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
231
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
232
|
+
*
|
|
233
|
+
* // Posting a tweet to twitter
|
|
234
|
+
* rettiwt.tweet.tweet('Hello World!')
|
|
235
|
+
* .then(res => {
|
|
236
|
+
* console.log(res);
|
|
237
|
+
* })
|
|
238
|
+
* .catch(err => {
|
|
239
|
+
* console.log(err);
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
139
243
|
* @public
|
|
140
244
|
*/
|
|
141
245
|
public async tweet(tweetText: string): Promise<boolean> {
|
|
@@ -151,6 +255,23 @@ export class TweetService extends FetcherService {
|
|
|
151
255
|
* @param tweetId - The id of the tweet to be favorited.
|
|
152
256
|
* @returns Whether favoriting was successful or not.
|
|
153
257
|
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```
|
|
260
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
261
|
+
*
|
|
262
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
263
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
264
|
+
*
|
|
265
|
+
* // Liking the Tweet with id '12345678'
|
|
266
|
+
* rettiwt.tweet.favorite('12345678')
|
|
267
|
+
* .then(res => {
|
|
268
|
+
* console.log(res);
|
|
269
|
+
* })
|
|
270
|
+
* .catch(err => {
|
|
271
|
+
* console.log(err);
|
|
272
|
+
* });
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
154
275
|
* @public
|
|
155
276
|
*/
|
|
156
277
|
public async favorite(tweetId: string): Promise<boolean> {
|
|
@@ -166,6 +287,23 @@ export class TweetService extends FetcherService {
|
|
|
166
287
|
* @param tweetId - The id of the tweet with the given id.
|
|
167
288
|
* @returns Whether retweeting was successful or not.
|
|
168
289
|
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```
|
|
292
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
293
|
+
*
|
|
294
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
295
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
296
|
+
*
|
|
297
|
+
* // Retweeting the Tweet with id '12345678'
|
|
298
|
+
* rettiwt.tweet.retweet('12345678')
|
|
299
|
+
* .then(res => {
|
|
300
|
+
* console.log(res);
|
|
301
|
+
* })
|
|
302
|
+
* .catch(err => {
|
|
303
|
+
* console.log(err);
|
|
304
|
+
* });
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
169
307
|
* @public
|
|
170
308
|
*/
|
|
171
309
|
public async retweet(tweetId: string): Promise<boolean> {
|
|
@@ -33,6 +33,40 @@ export class UserService extends FetcherService {
|
|
|
33
33
|
* @param id - The username/id of the target user.
|
|
34
34
|
* @returns The details of the given user.
|
|
35
35
|
*
|
|
36
|
+
* @example Fetching the details of the Twitter user with username 'user1'
|
|
37
|
+
* ```
|
|
38
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
39
|
+
*
|
|
40
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
41
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
42
|
+
*
|
|
43
|
+
* // Fetching the details of the User with username 'user1'
|
|
44
|
+
* rettiwt.user.details('user1')
|
|
45
|
+
* .then(res => {
|
|
46
|
+
* console.log(res);
|
|
47
|
+
* })
|
|
48
|
+
* .catch(err => {
|
|
49
|
+
* console.log(err);
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example Fetching the details of the Twitter user with id '12345678'
|
|
54
|
+
* ```
|
|
55
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
56
|
+
*
|
|
57
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
58
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
59
|
+
*
|
|
60
|
+
* // Fetching the details of the User with id '12345678'
|
|
61
|
+
* rettiwt.user.details('12345678')
|
|
62
|
+
* .then(res => {
|
|
63
|
+
* console.log(res);
|
|
64
|
+
* })
|
|
65
|
+
* .catch(err => {
|
|
66
|
+
* console.log(err);
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
36
70
|
* @public
|
|
37
71
|
*/
|
|
38
72
|
public async details(id: string): Promise<User> {
|
|
@@ -60,6 +94,23 @@ export class UserService extends FetcherService {
|
|
|
60
94
|
* @param cursor - The cursor to the batch of following to fetch.
|
|
61
95
|
* @returns The list of users followed by the target user.
|
|
62
96
|
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```
|
|
99
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
100
|
+
*
|
|
101
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
102
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
103
|
+
*
|
|
104
|
+
* // Fetching the first 100 following of the User with id '12345678'
|
|
105
|
+
* rettiwt.user.following('12345678')
|
|
106
|
+
* .then(res => {
|
|
107
|
+
* console.log(res);
|
|
108
|
+
* })
|
|
109
|
+
* .catch(err => {
|
|
110
|
+
* console.log(err);
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
63
114
|
* @public
|
|
64
115
|
*/
|
|
65
116
|
public async following(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
@@ -81,6 +132,23 @@ export class UserService extends FetcherService {
|
|
|
81
132
|
* @param cursor - The cursor to the batch of followers to fetch.
|
|
82
133
|
* @returns The list of users following the target user.
|
|
83
134
|
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```
|
|
137
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
138
|
+
*
|
|
139
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
140
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
141
|
+
*
|
|
142
|
+
* // Fetching the first 100 followers of the User with id '12345678'
|
|
143
|
+
* rettiwt.user.followers('12345678')
|
|
144
|
+
* .then(res => {
|
|
145
|
+
* console.log(res);
|
|
146
|
+
* })
|
|
147
|
+
* .catch(err => {
|
|
148
|
+
* console.log(err);
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
84
152
|
* @public
|
|
85
153
|
*/
|
|
86
154
|
public async followers(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
@@ -102,6 +170,23 @@ export class UserService extends FetcherService {
|
|
|
102
170
|
* @param cursor - The cursor to the batch of likes to fetch.
|
|
103
171
|
* @returns The list of tweets liked by the target user.
|
|
104
172
|
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```
|
|
175
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
176
|
+
*
|
|
177
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
178
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
179
|
+
*
|
|
180
|
+
* // Fetching the most recent 100 liked Tweets of the User with id '12345678'
|
|
181
|
+
* rettiwt.user.likes('12345678')
|
|
182
|
+
* .then(res => {
|
|
183
|
+
* console.log(res);
|
|
184
|
+
* })
|
|
185
|
+
* .catch(err => {
|
|
186
|
+
* console.log(err);
|
|
187
|
+
* });
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
105
190
|
* @public
|
|
106
191
|
*/
|
|
107
192
|
public async likes(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
@@ -123,6 +208,23 @@ export class UserService extends FetcherService {
|
|
|
123
208
|
* @param cursor - The cursor to the batch of timeline items to fetch.
|
|
124
209
|
* @returns The timeline of the target user.
|
|
125
210
|
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```
|
|
213
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
214
|
+
*
|
|
215
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
216
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
217
|
+
*
|
|
218
|
+
* // Fetching the first 20 timeline tweets of the User with id '12345678'
|
|
219
|
+
* rettiwt.user.timeline('12345678')
|
|
220
|
+
* .then(res => {
|
|
221
|
+
* console.log(res);
|
|
222
|
+
* })
|
|
223
|
+
* .catch(err => {
|
|
224
|
+
* console.log(err);
|
|
225
|
+
* });
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
126
228
|
* @remarks
|
|
127
229
|
* - If the target user has a pinned tweet, the returned timeline has one item extra and this is always the pinned tweet.
|
|
128
230
|
* - If timeline is fetched without authenticating, then the most popular tweets of the target user are returned instead.
|
|
@@ -148,6 +250,23 @@ export class UserService extends FetcherService {
|
|
|
148
250
|
* @param cursor - The cursor to the batch of replies to fetch.
|
|
149
251
|
* @returns The reply timeline of the target user.
|
|
150
252
|
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```
|
|
255
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
256
|
+
*
|
|
257
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
258
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
259
|
+
*
|
|
260
|
+
* // Fetching the first 100 timeline replies of the User with id '12345678'
|
|
261
|
+
* rettiwt.user.replies('12345678')
|
|
262
|
+
* .then(res => {
|
|
263
|
+
* console.log(res);
|
|
264
|
+
* })
|
|
265
|
+
* .catch(err => {
|
|
266
|
+
* console.log(err);
|
|
267
|
+
* });
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
151
270
|
* @remarks If the target user has a pinned tweet, the returned reply timeline has one item extra and this is always the pinned tweet.
|
|
152
271
|
*
|
|
153
272
|
* @public
|
|
@@ -7,6 +7,9 @@ export interface IRettiwtConfig {
|
|
|
7
7
|
/** The apiKey (cookie) to use for authenticating Rettiwt against Twitter API. */
|
|
8
8
|
apiKey?: string;
|
|
9
9
|
|
|
10
|
+
/** The guestKey (guest token) to use for guest access to Twitter API. */
|
|
11
|
+
guestKey?: string;
|
|
12
|
+
|
|
10
13
|
/** Optional URL with proxy configuration to use for requests to Twitter API. */
|
|
11
14
|
proxyUrl?: URL;
|
|
12
15
|
|