rettiwt-api 2.0.3 → 2.1.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 +53 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/models/List.d.ts +29 -0
- package/dist/models/List.js +27 -0
- package/dist/models/List.js.map +1 -0
- package/dist/models/Tweet.d.ts +9 -2
- package/dist/models/Tweet.js +7 -1
- package/dist/models/Tweet.js.map +1 -1
- package/dist/models/User.d.ts +2 -0
- package/dist/models/User.js +2 -0
- package/dist/models/User.js.map +1 -1
- package/dist/services/FetcherService.js +7 -2
- package/dist/services/FetcherService.js.map +1 -1
- package/dist/services/TweetService.d.ts +16 -5
- package/dist/services/TweetService.js +36 -7
- package/dist/services/TweetService.js.map +1 -1
- package/dist/types/List.d.ts +21 -0
- package/dist/types/List.js +3 -0
- package/dist/types/List.js.map +1 -0
- package/dist/types/Tweet.d.ts +7 -2
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/models/List.ts +48 -0
- package/src/models/Tweet.ts +16 -3
- package/src/models/User.ts +2 -0
- package/src/services/FetcherService.ts +12 -3
- package/src/services/TweetService.ts +31 -7
- package/src/types/List.ts +27 -0
- package/src/types/Tweet.ts +11 -2
- package/.dockerignore +0 -2
package/README.md
CHANGED
|
@@ -33,6 +33,8 @@ The following examples may help you to get started using the library:
|
|
|
33
33
|
### 1. Getting the details of a target Twitter user
|
|
34
34
|
|
|
35
35
|
```
|
|
36
|
+
const { Rettiwt } = require('rettiwt-api');
|
|
37
|
+
|
|
36
38
|
// Creating a new Rettiwt instance using the API_KEY
|
|
37
39
|
const rettiwt = new Rettiwt(API_KEY);
|
|
38
40
|
|
|
@@ -49,6 +51,8 @@ rettiwt.user.details('<username>')
|
|
|
49
51
|
### 2. Getting the list of tweets that match a given filter
|
|
50
52
|
|
|
51
53
|
```
|
|
54
|
+
const { Rettiwt } = require('rettiwt-api');
|
|
55
|
+
|
|
52
56
|
// Creating a new Rettiwt instance using the API_KEY
|
|
53
57
|
const rettiwt = new Rettiwt(API_KEY);
|
|
54
58
|
|
|
@@ -66,11 +70,60 @@ rettiwt.tweet.search({
|
|
|
66
70
|
})
|
|
67
71
|
.catch(err => {
|
|
68
72
|
...
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Getting the next batch of data using a cursor
|
|
77
|
+
|
|
78
|
+
The previous example fetches the the list of tweets matching the given filter. Since no count is specified, in this case, a default of 20 such Tweets are fetched initially. The following example demonstrates how to use the [cursor string](https://rishikant181.github.io/Rettiwt-API/classes/Cursor.html#value) obtained from the [response](https://rishikant181.github.io/Rettiwt-API/classes/CursoredData.html) object's [next](https://rishikant181.github.io/Rettiwt-API/classes/CursoredData.html#next) field, from the previous example, to fetch the next batch of tweets:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
const { Rettiwt } = require('rettiwt-api');
|
|
82
|
+
|
|
83
|
+
// Creating a new Rettiwt instance using the API_KEY
|
|
84
|
+
const rettiwt = new Rettiwt(API_KEY);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Fetching the list of tweets that:
|
|
88
|
+
* - are made by a user with username <username>,
|
|
89
|
+
* - contain the words <word1> and <word2>
|
|
90
|
+
*
|
|
91
|
+
* 'data' is the response object received in the previous example.
|
|
92
|
+
*/
|
|
93
|
+
rettiwt.tweet.search({
|
|
94
|
+
fromUsers: ['<username>'],
|
|
95
|
+
words: ['<word1>', '<word2>']
|
|
96
|
+
}, data.next.value)
|
|
97
|
+
.then(data => {
|
|
98
|
+
...
|
|
69
99
|
})
|
|
100
|
+
.catch(err => {
|
|
101
|
+
...
|
|
102
|
+
});
|
|
70
103
|
```
|
|
71
104
|
|
|
72
105
|
For more information regarding the different available filter options, please refer to [TweetFilter](https://rishikant181.github.io/Rettiwt-API/classes/TweetFilter.html).
|
|
73
106
|
|
|
107
|
+
## Features
|
|
108
|
+
|
|
109
|
+
So far, the following operations are supported:
|
|
110
|
+
|
|
111
|
+
### Tweets
|
|
112
|
+
- [Getting the details of a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#details)
|
|
113
|
+
- [Favoriting/liking a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#favorite)
|
|
114
|
+
- [Getting the list of users who favorited/liked a given tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#favoriters)
|
|
115
|
+
- [Getting the list of tweets from a given Twitter list](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#list)
|
|
116
|
+
- [Retweeting/reposting a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#retweet)
|
|
117
|
+
- [Getting the list of users who retweeted/reposted a given tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#retweeters)
|
|
118
|
+
- [Searching for the list of tweets that match a given filter](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#search)
|
|
119
|
+
- [Posting a new tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#tweet)
|
|
120
|
+
|
|
121
|
+
### Users
|
|
122
|
+
- [Getting the details of a user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#details)
|
|
123
|
+
- [Getting the list of users who follow the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#followers)
|
|
124
|
+
- [Getting the list of users who are followed by the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#following)
|
|
125
|
+
- [Getting the list of tweets favorited/liked by the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#likes)
|
|
126
|
+
|
|
74
127
|
## API Reference
|
|
75
128
|
|
|
76
129
|
The complete API reference can be found at [this](https://rishikant181.github.io/Rettiwt-API/) page.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,13 @@ export * from './Rettiwt';
|
|
|
2
2
|
export * from './enums/ApiErrors';
|
|
3
3
|
export * from './enums/HTTP';
|
|
4
4
|
export * from './models/CursoredData';
|
|
5
|
+
export * from './models/List';
|
|
5
6
|
export * from './models/Tweet';
|
|
6
7
|
export * from './models/User';
|
|
7
8
|
export * from './services/FetcherService';
|
|
8
9
|
export * from './services/TweetService';
|
|
9
10
|
export * from './services/UserService';
|
|
10
11
|
export * from './types/CursoredData';
|
|
12
|
+
export * from './types/List';
|
|
11
13
|
export * from './types/Tweet';
|
|
12
14
|
export * from './types/User';
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./enums/ApiErrors"), exports);
|
|
|
21
21
|
__exportStar(require("./enums/HTTP"), exports);
|
|
22
22
|
// Exporting models
|
|
23
23
|
__exportStar(require("./models/CursoredData"), exports);
|
|
24
|
+
__exportStar(require("./models/List"), exports);
|
|
24
25
|
__exportStar(require("./models/Tweet"), exports);
|
|
25
26
|
__exportStar(require("./models/User"), exports);
|
|
26
27
|
// Exporting services
|
|
@@ -29,6 +30,7 @@ __exportStar(require("./services/TweetService"), exports);
|
|
|
29
30
|
__exportStar(require("./services/UserService"), exports);
|
|
30
31
|
// Exporting types
|
|
31
32
|
__exportStar(require("./types/CursoredData"), exports);
|
|
33
|
+
__exportStar(require("./types/List"), exports);
|
|
32
34
|
__exportStar(require("./types/Tweet"), exports);
|
|
33
35
|
__exportStar(require("./types/User"), exports);
|
|
34
36
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO;AACP,4CAA0B;AAE1B,kBAAkB;AAClB,oDAAkC;AAClC,+CAA6B;AAE7B,mBAAmB;AACnB,wDAAsC;AACtC,iDAA+B;AAC/B,gDAA8B;AAE9B,qBAAqB;AACrB,4DAA0C;AAC1C,0DAAwC;AACxC,yDAAuC;AAEvC,kBAAkB;AAClB,uDAAqC;AACrC,gDAA8B;AAC9B,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO;AACP,4CAA0B;AAE1B,kBAAkB;AAClB,oDAAkC;AAClC,+CAA6B;AAE7B,mBAAmB;AACnB,wDAAsC;AACtC,gDAA8B;AAC9B,iDAA+B;AAC/B,gDAA8B;AAE9B,qBAAqB;AACrB,4DAA0C;AAC1C,0DAAwC;AACxC,yDAAuC;AAEvC,kBAAkB;AAClB,uDAAqC;AACrC,+CAA6B;AAC7B,gDAA8B;AAC9B,+CAA6B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IList as IRawList } from 'rettiwt-core';
|
|
2
|
+
import { IList } from '../types/List';
|
|
3
|
+
/**
|
|
4
|
+
* The details of a single Twitter List.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class List implements IList {
|
|
9
|
+
/** The rest id of the list. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** The name of the list. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** The date and time of creation of the list, int UTC string format. */
|
|
14
|
+
createdAt: string;
|
|
15
|
+
/** The list description. */
|
|
16
|
+
description: string;
|
|
17
|
+
/** The number of memeber of the list. */
|
|
18
|
+
memberCount: number;
|
|
19
|
+
/** The number of subscribers of the list. */
|
|
20
|
+
subscriberCount: number;
|
|
21
|
+
/** The rest id of the user who created the list. */
|
|
22
|
+
createdBy: string;
|
|
23
|
+
/**
|
|
24
|
+
* Initializes a new Tweet List from the given raw list data.
|
|
25
|
+
*
|
|
26
|
+
* @param list - list The raw tweet list data.
|
|
27
|
+
*/
|
|
28
|
+
constructor(list: IRawList);
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.List = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The details of a single Twitter List.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
var List = /** @class */ (function () {
|
|
10
|
+
/**
|
|
11
|
+
* Initializes a new Tweet List from the given raw list data.
|
|
12
|
+
*
|
|
13
|
+
* @param list - list The raw tweet list data.
|
|
14
|
+
*/
|
|
15
|
+
function List(list) {
|
|
16
|
+
this.id = list.id_str;
|
|
17
|
+
this.name = list.name;
|
|
18
|
+
this.createdAt = new Date(list.created_at).toISOString();
|
|
19
|
+
this.description = list.description;
|
|
20
|
+
this.memberCount = list.member_count;
|
|
21
|
+
this.subscriberCount = list.subscriber_count;
|
|
22
|
+
this.createdBy = list.user_results.result.id;
|
|
23
|
+
}
|
|
24
|
+
return List;
|
|
25
|
+
}());
|
|
26
|
+
exports.List = List;
|
|
27
|
+
//# sourceMappingURL=List.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../src/models/List.ts"],"names":[],"mappings":";;;AAMA;;;;GAIG;AACH;IAsBC;;;;OAIG;IACH,cAAY,IAAc;QACzB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;QACzD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IAC9C,CAAC;IACF,WAAC;AAAD,CAAC,AApCD,IAoCC;AApCY,oBAAI"}
|
package/dist/models/Tweet.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ITweet, ITweetEntities } from '../types/Tweet';
|
|
2
2
|
import { ITweet as IRawTweet, IEntities as IRawTweetEntities } from 'rettiwt-core';
|
|
3
|
+
import { User } from './User';
|
|
3
4
|
/**
|
|
4
5
|
* The different types parsed entities like urls, media, mentions, hashtags, etc.
|
|
5
6
|
*
|
|
@@ -24,8 +25,8 @@ export declare class TweetEntities implements ITweetEntities {
|
|
|
24
25
|
export declare class Tweet implements ITweet {
|
|
25
26
|
/** The rest id of the tweet. */
|
|
26
27
|
id: string;
|
|
27
|
-
/** The
|
|
28
|
-
tweetBy:
|
|
28
|
+
/** The details of the user who made the tweet. */
|
|
29
|
+
tweetBy: User;
|
|
29
30
|
/** The date and time of creation of the tweet, in UTC string format. */
|
|
30
31
|
createdAt: string;
|
|
31
32
|
/** Additional tweet entities like urls, mentions, etc. */
|
|
@@ -46,7 +47,13 @@ export declare class Tweet implements ITweet {
|
|
|
46
47
|
retweetCount: number;
|
|
47
48
|
/** The number of likes of the tweet. */
|
|
48
49
|
likeCount: number;
|
|
50
|
+
/** The number of views of a tweet. */
|
|
51
|
+
viewCount: number;
|
|
52
|
+
/** The number of bookmarks of a tweet. */
|
|
53
|
+
bookmarkCount: number;
|
|
49
54
|
/**
|
|
55
|
+
* Initializes a new Tweet from the given raw tweet data.
|
|
56
|
+
*
|
|
50
57
|
* @param tweet - The raw tweet data.
|
|
51
58
|
*/
|
|
52
59
|
constructor(tweet: IRawTweet);
|
package/dist/models/Tweet.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Tweet = exports.TweetEntities = void 0;
|
|
4
|
+
// MODELS
|
|
5
|
+
var User_1 = require("./User");
|
|
4
6
|
// PARSERS
|
|
5
7
|
var JsonUtils_1 = require("../helper/JsonUtils");
|
|
6
8
|
/**
|
|
@@ -57,12 +59,14 @@ exports.TweetEntities = TweetEntities;
|
|
|
57
59
|
*/
|
|
58
60
|
var Tweet = /** @class */ (function () {
|
|
59
61
|
/**
|
|
62
|
+
* Initializes a new Tweet from the given raw tweet data.
|
|
63
|
+
*
|
|
60
64
|
* @param tweet - The raw tweet data.
|
|
61
65
|
*/
|
|
62
66
|
function Tweet(tweet) {
|
|
63
67
|
this.id = tweet.rest_id;
|
|
64
68
|
this.createdAt = tweet.legacy.created_at;
|
|
65
|
-
this.tweetBy = tweet.
|
|
69
|
+
this.tweetBy = new User_1.User(tweet.core.user_results.result);
|
|
66
70
|
this.entities = new TweetEntities(tweet.legacy.entities);
|
|
67
71
|
this.quoted = tweet.legacy.quoted_status_id_str;
|
|
68
72
|
this.fullText = (0, JsonUtils_1.normalizeText)(tweet.legacy.full_text);
|
|
@@ -72,6 +76,8 @@ var Tweet = /** @class */ (function () {
|
|
|
72
76
|
this.replyCount = tweet.legacy.reply_count;
|
|
73
77
|
this.retweetCount = tweet.legacy.retweet_count;
|
|
74
78
|
this.likeCount = tweet.legacy.favorite_count;
|
|
79
|
+
this.viewCount = parseInt(tweet.views.count);
|
|
80
|
+
this.bookmarkCount = tweet.legacy.bookmark_count;
|
|
75
81
|
}
|
|
76
82
|
return Tweet;
|
|
77
83
|
}());
|
package/dist/models/Tweet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../src/models/Tweet.ts"],"names":[],"mappings":";;;AAIA,UAAU;AACV,iDAAoD;AAEpD;;;;GAIG;AACH;IAaC,uBAAY,QAA2B;QAZvC,mDAAmD;QACnD,aAAQ,GAAa,EAAE,CAAC;QAExB,+CAA+C;QAC/C,SAAI,GAAa,EAAE,CAAC;QAEpB,uDAAuD;QACvD,mBAAc,GAAa,EAAE,CAAC;QAE9B,gEAAgE;QAChE,UAAK,GAAa,EAAE,CAAC;QAGpB,2BAA2B;QAC3B,IAAI,QAAQ,CAAC,aAAa,EAAE;YAC3B,KAAmB,UAAsB,EAAtB,KAAA,QAAQ,CAAC,a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,GAAG,KAAK,CAAC,OAAO,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,WAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAA,yBAAa,EAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,yBAAyB,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;QAC/C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC;IAClD,CAAC;IACF,YAAC;AAAD,CAAC,AAhED,IAgEC;AAhEY,sBAAK"}
|
package/dist/models/User.d.ts
CHANGED
package/dist/models/User.js
CHANGED
package/dist/models/User.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../src/models/User.ts"],"names":[],"mappings":";;;AAIA;;;;GAIG;AACH;IA2CC
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../src/models/User.ts"],"names":[],"mappings":";;;AAIA;;;;GAIG;AACH;IA2CC;;;;OAIG;IACH,cAAY,IAAc;QACzB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACpD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;QAClD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACvD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;QACpD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC;IACzD,CAAC;IACF,WAAC;AAAD,CAAC,AAhED,IAgEC;AAhEY,oBAAI"}
|
|
@@ -147,10 +147,15 @@ var FetcherService = /** @class */ (function () {
|
|
|
147
147
|
else if (type == rettiwt_core_1.EResourceType.USER_DETAILS || type == rettiwt_core_1.EResourceType.USER_DETAILS_BY_ID) {
|
|
148
148
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'User');
|
|
149
149
|
}
|
|
150
|
-
else if (type == rettiwt_core_1.EResourceType.TWEET_SEARCH ||
|
|
150
|
+
else if (type == rettiwt_core_1.EResourceType.TWEET_SEARCH ||
|
|
151
|
+
type == rettiwt_core_1.EResourceType.USER_LIKES ||
|
|
152
|
+
type == rettiwt_core_1.EResourceType.LIST_TWEETS) {
|
|
151
153
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineTweet').map(function (item) { return item.tweet_results.result; });
|
|
152
154
|
}
|
|
153
|
-
else
|
|
155
|
+
else if (type == rettiwt_core_1.EResourceType.TWEET_FAVORITERS ||
|
|
156
|
+
type == rettiwt_core_1.EResourceType.TWEET_RETWEETERS ||
|
|
157
|
+
type == rettiwt_core_1.EResourceType.USER_FOLLOWERS ||
|
|
158
|
+
type == rettiwt_core_1.EResourceType.USER_FOLLOWING) {
|
|
154
159
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineUser').map(function (item) { return item.user_results.result; });
|
|
155
160
|
}
|
|
156
161
|
return new CursoredData_1.CursoredData(required, (_a = (0, JsonUtils_1.findByFilter)(data, 'cursorType', 'Bottom')[0]) === null || _a === void 0 ? void 0 : _a.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../src/services/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAWsB;AACtB,gDAAsF;AAGtF,QAAQ;AACR,sCAA4C;AAC5C,gDAAgD;AAEhD,SAAS;AACT,uDAAsD;AAItD,UAAU;AACV,iDAAmE;AAEnE;;;;GAIG;AACH;IAIC;;OAEG;IACH,wBAAY,IAAoB;QAC/B,IAAI,CA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,EAAC;;;;KACZ;IAED;;;;;;OAMG;IACa,6BAAI,GAApB,UAAqB,YAA2B,EAAE,IAAU;;;;;;wBAErD,OAAO,GAAY,IAAI,sBAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;wBAEzD,mBAAmB;wBACnB,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAA;;wBAD3B,mBAAmB;wBACnB,SAA2B,CAAC;wBAE5B,sBAAO,IAAI,EAAC;;;;KACZ;IACF,qBAAC;AAAD,CAAC,AAjKD,IAiKC;AAjKY,wCAAc"}
|
|
@@ -16,6 +16,15 @@ export declare class TweetService extends FetcherService {
|
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
18
|
constructor(cred: AuthCredential);
|
|
19
|
+
/**
|
|
20
|
+
* Get the details of a tweet.
|
|
21
|
+
*
|
|
22
|
+
* @param id - The id of the target tweet.
|
|
23
|
+
* @returns The details of a single tweet with the given tweet id.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
details(id: string): Promise<Tweet>;
|
|
19
28
|
/**
|
|
20
29
|
* Search for tweets using a query.
|
|
21
30
|
*
|
|
@@ -28,14 +37,16 @@ export declare class TweetService extends FetcherService {
|
|
|
28
37
|
*/
|
|
29
38
|
search(query: TweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
30
39
|
/**
|
|
31
|
-
* Get the
|
|
40
|
+
* Get the tweets from the tweet list with the given id.
|
|
32
41
|
*
|
|
33
|
-
* @param
|
|
34
|
-
* @
|
|
42
|
+
* @param listId - The id of list from where the tweets are to be fetched.
|
|
43
|
+
* @param count - The number of tweets to fetch, must be \<= 100.
|
|
44
|
+
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
45
|
+
* @returns The list tweets present in the given list.
|
|
35
46
|
*
|
|
36
|
-
* @
|
|
47
|
+
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
37
48
|
*/
|
|
38
|
-
|
|
49
|
+
list(listId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
39
50
|
/**
|
|
40
51
|
* Get the list of users who liked a tweet.
|
|
41
52
|
*
|
|
@@ -71,6 +71,27 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
71
71
|
function TweetService(cred) {
|
|
72
72
|
return _super.call(this, cred) || this;
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the details of a tweet.
|
|
76
|
+
*
|
|
77
|
+
* @param id - The id of the target tweet.
|
|
78
|
+
* @returns The details of a single tweet with the given tweet id.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
TweetService.prototype.details = function (id) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
var data;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.TWEET_DETAILS, { id: id })];
|
|
88
|
+
case 1:
|
|
89
|
+
data = _a.sent();
|
|
90
|
+
return [2 /*return*/, data.list[0]];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
74
95
|
/**
|
|
75
96
|
* Search for tweets using a query.
|
|
76
97
|
*
|
|
@@ -101,22 +122,30 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
101
122
|
});
|
|
102
123
|
};
|
|
103
124
|
/**
|
|
104
|
-
* Get the
|
|
125
|
+
* Get the tweets from the tweet list with the given id.
|
|
105
126
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @
|
|
127
|
+
* @param listId - The id of list from where the tweets are to be fetched.
|
|
128
|
+
* @param count - The number of tweets to fetch, must be \<= 100.
|
|
129
|
+
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
130
|
+
* @returns The list tweets present in the given list.
|
|
108
131
|
*
|
|
109
|
-
* @
|
|
132
|
+
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
110
133
|
*/
|
|
111
|
-
TweetService.prototype.
|
|
134
|
+
TweetService.prototype.list = function (listId, count, cursor) {
|
|
112
135
|
return __awaiter(this, void 0, void 0, function () {
|
|
113
136
|
var data;
|
|
114
137
|
return __generator(this, function (_a) {
|
|
115
138
|
switch (_a.label) {
|
|
116
|
-
case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.
|
|
139
|
+
case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.LIST_TWEETS, {
|
|
140
|
+
id: listId,
|
|
141
|
+
count: count,
|
|
142
|
+
cursor: cursor,
|
|
143
|
+
})];
|
|
117
144
|
case 1:
|
|
118
145
|
data = _a.sent();
|
|
119
|
-
|
|
146
|
+
// Sorting the tweets by date, from recent to oldest
|
|
147
|
+
data.list.sort(function (a, b) { return new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf(); });
|
|
148
|
+
return [2 /*return*/, data];
|
|
120
149
|
}
|
|
121
150
|
});
|
|
122
151
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TweetService.js","sourceRoot":"","sources":["../../src/services/TweetService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAA0D;AAG1D,WAAW;AACX,mDAAkD;AAOlD;;;;GAIG;AACH;IAAkC,gCAAc;IAC/C;;;;OAIG;IACH,sBAAY,IAAoB;eAC/B,kBAAM,IAAI,CAAC;IACZ,CAAC;IAED;;;;;;;;;OASG;IACG,6BAAM,GAAZ,UAAa,KAAkB,EAAE,KAAc,EAAE,MAAe;;;;;4BAElD,qBAAM,IAAI,CAAC,KAAK,CAAQ,4BAAa,CAAC,YAAY,EAAE;4BAChE,MAAM,EAAE,KAAK;4BACb,KAAK,EAAE,KAAK;4BACZ,MAAM,EAAE,MAAM;yBACd,CAAC,EAAA;;wBAJ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E,KAAK;4BACZ,MAAM,EAAE,MAAM;yBACd,CAAC,EAAA;;wBAJI,IAAI,GAAG,SAIX;wBAEF,sBAAO,IAAI,EAAC;;;;KACZ;IAED;;;;;;;OAOG;IACG,4BAAK,GAAX,UAAY,SAAiB;;;;;4BAEf,qBAAM,IAAI,CAAC,IAAI,CAAC,4BAAa,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAA;;wBAA5E,IAAI,GAAG,SAAqE;wBAElF,sBAAO,IAAI,EAAC;;;;KACZ;IAED;;;;;;;OAOG;IACG,+BAAQ,GAAd,UAAe,OAAe;;;;;4BAEhB,qBAAM,IAAI,CAAC,IAAI,CAAC,4BAAa,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAA;;wBAArE,IAAI,GAAG,SAA8D;wBAE3E,sBAAO,IAAI,EAAC;;;;KACZ;IAED;;;;;;;OAOG;IACG,8BAAO,GAAb,UAAc,OAAe;;;;;4BAEf,qBAAM,IAAI,CAAC,IAAI,CAAC,4BAAa,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAA;;wBAArE,IAAI,GAAG,SAA8D;wBAE3E,sBAAO,IAAI,EAAC;;;;KACZ;IACF,mBAAC;AAAD,CAAC,AA/JD,CAAkC,+BAAc,GA+J/C;AA/JY,oCAAY"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The details of a single Twitter List.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface IList {
|
|
7
|
+
/** The rest id of the list. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** The name of the list. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** The date and time of creation of the list, int UTC string format. */
|
|
12
|
+
createdAt: string;
|
|
13
|
+
/** The list description. */
|
|
14
|
+
description: string;
|
|
15
|
+
/** The number of memeber of the list. */
|
|
16
|
+
memberCount: number;
|
|
17
|
+
/** The number of subscribers of the list. */
|
|
18
|
+
subscriberCount: number;
|
|
19
|
+
/** The rest id of the user who created the list. */
|
|
20
|
+
createdBy: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../src/types/List.ts"],"names":[],"mappings":""}
|
package/dist/types/Tweet.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IUser } from './User';
|
|
1
2
|
/**
|
|
2
3
|
* The different types parsed entities like urls, media, mentions, hashtags, etc.
|
|
3
4
|
*
|
|
@@ -21,8 +22,8 @@ export interface ITweetEntities {
|
|
|
21
22
|
export interface ITweet {
|
|
22
23
|
/** The rest id of the tweet. */
|
|
23
24
|
id: string;
|
|
24
|
-
/** The
|
|
25
|
-
tweetBy:
|
|
25
|
+
/** The details of the user who made the tweet. */
|
|
26
|
+
tweetBy: IUser;
|
|
26
27
|
/** The date and time of creation of the tweet, in UTC string format. */
|
|
27
28
|
createdAt: string;
|
|
28
29
|
/** Additional tweet entities like urls, mentions, etc. */
|
|
@@ -43,4 +44,8 @@ export interface ITweet {
|
|
|
43
44
|
retweetCount: number;
|
|
44
45
|
/** The number of likes of the tweet. */
|
|
45
46
|
likeCount: number;
|
|
47
|
+
/** The number of views of a tweet. */
|
|
48
|
+
viewCount: number;
|
|
49
|
+
/** The number of bookmarks of a tweet. */
|
|
50
|
+
bookmarkCount: number;
|
|
46
51
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rettiwt-api",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"description": "An API for fetching data from TwitterAPI, without any rate limits!",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"axios": "1.3.2",
|
|
29
29
|
"rettiwt-auth": "1.2.0",
|
|
30
|
-
"rettiwt-core": "3.1.
|
|
30
|
+
"rettiwt-core": "3.1.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "20.4.1",
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './enums/HTTP';
|
|
|
7
7
|
|
|
8
8
|
// Exporting models
|
|
9
9
|
export * from './models/CursoredData';
|
|
10
|
+
export * from './models/List';
|
|
10
11
|
export * from './models/Tweet';
|
|
11
12
|
export * from './models/User';
|
|
12
13
|
|
|
@@ -17,5 +18,6 @@ export * from './services/UserService';
|
|
|
17
18
|
|
|
18
19
|
// Exporting types
|
|
19
20
|
export * from './types/CursoredData';
|
|
21
|
+
export * from './types/List';
|
|
20
22
|
export * from './types/Tweet';
|
|
21
23
|
export * from './types/User';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// PACKAGES
|
|
2
|
+
import { IList as IRawList } from 'rettiwt-core';
|
|
3
|
+
|
|
4
|
+
// TYPES
|
|
5
|
+
import { IList } from '../types/List';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The details of a single Twitter List.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export class List implements IList {
|
|
13
|
+
/** The rest id of the list. */
|
|
14
|
+
id: string;
|
|
15
|
+
|
|
16
|
+
/** The name of the list. */
|
|
17
|
+
name: string;
|
|
18
|
+
|
|
19
|
+
/** The date and time of creation of the list, int UTC string format. */
|
|
20
|
+
createdAt: string;
|
|
21
|
+
|
|
22
|
+
/** The list description. */
|
|
23
|
+
description: string;
|
|
24
|
+
|
|
25
|
+
/** The number of memeber of the list. */
|
|
26
|
+
memberCount: number;
|
|
27
|
+
|
|
28
|
+
/** The number of subscribers of the list. */
|
|
29
|
+
subscriberCount: number;
|
|
30
|
+
|
|
31
|
+
/** The rest id of the user who created the list. */
|
|
32
|
+
createdBy: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Initializes a new Tweet List from the given raw list data.
|
|
36
|
+
*
|
|
37
|
+
* @param list - list The raw tweet list data.
|
|
38
|
+
*/
|
|
39
|
+
constructor(list: IRawList) {
|
|
40
|
+
this.id = list.id_str;
|
|
41
|
+
this.name = list.name;
|
|
42
|
+
this.createdAt = new Date(list.created_at).toISOString();
|
|
43
|
+
this.description = list.description;
|
|
44
|
+
this.memberCount = list.member_count;
|
|
45
|
+
this.subscriberCount = list.subscriber_count;
|
|
46
|
+
this.createdBy = list.user_results.result.id;
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/models/Tweet.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { ITweet, ITweetEntities } from '../types/Tweet';
|
|
3
3
|
import { ITweet as IRawTweet, IEntities as IRawTweetEntities } from 'rettiwt-core';
|
|
4
4
|
|
|
5
|
+
// MODELS
|
|
6
|
+
import { User } from './User';
|
|
7
|
+
|
|
5
8
|
// PARSERS
|
|
6
9
|
import { normalizeText } from '../helper/JsonUtils';
|
|
7
10
|
|
|
@@ -63,8 +66,8 @@ export class Tweet implements ITweet {
|
|
|
63
66
|
/** The rest id of the tweet. */
|
|
64
67
|
id: string;
|
|
65
68
|
|
|
66
|
-
/** The
|
|
67
|
-
tweetBy:
|
|
69
|
+
/** The details of the user who made the tweet. */
|
|
70
|
+
tweetBy: User;
|
|
68
71
|
|
|
69
72
|
/** The date and time of creation of the tweet, in UTC string format. */
|
|
70
73
|
createdAt: string;
|
|
@@ -96,13 +99,21 @@ export class Tweet implements ITweet {
|
|
|
96
99
|
/** The number of likes of the tweet. */
|
|
97
100
|
likeCount: number;
|
|
98
101
|
|
|
102
|
+
/** The number of views of a tweet. */
|
|
103
|
+
viewCount: number;
|
|
104
|
+
|
|
105
|
+
/** The number of bookmarks of a tweet. */
|
|
106
|
+
bookmarkCount: number;
|
|
107
|
+
|
|
99
108
|
/**
|
|
109
|
+
* Initializes a new Tweet from the given raw tweet data.
|
|
110
|
+
*
|
|
100
111
|
* @param tweet - The raw tweet data.
|
|
101
112
|
*/
|
|
102
113
|
constructor(tweet: IRawTweet) {
|
|
103
114
|
this.id = tweet.rest_id;
|
|
104
115
|
this.createdAt = tweet.legacy.created_at;
|
|
105
|
-
this.tweetBy = tweet.
|
|
116
|
+
this.tweetBy = new User(tweet.core.user_results.result);
|
|
106
117
|
this.entities = new TweetEntities(tweet.legacy.entities);
|
|
107
118
|
this.quoted = tweet.legacy.quoted_status_id_str;
|
|
108
119
|
this.fullText = normalizeText(tweet.legacy.full_text);
|
|
@@ -112,5 +123,7 @@ export class Tweet implements ITweet {
|
|
|
112
123
|
this.replyCount = tweet.legacy.reply_count;
|
|
113
124
|
this.retweetCount = tweet.legacy.retweet_count;
|
|
114
125
|
this.likeCount = tweet.legacy.favorite_count;
|
|
126
|
+
this.viewCount = parseInt(tweet.views.count);
|
|
127
|
+
this.bookmarkCount = tweet.legacy.bookmark_count;
|
|
115
128
|
}
|
|
116
129
|
}
|
package/src/models/User.ts
CHANGED
|
@@ -124,17 +124,26 @@ export class FetcherService {
|
|
|
124
124
|
/**
|
|
125
125
|
* The required extracted data.
|
|
126
126
|
*/
|
|
127
|
-
let required = [];
|
|
127
|
+
let required: IRawTweet[] | IRawUser[] = [];
|
|
128
128
|
|
|
129
129
|
if (type == EResourceType.TWEET_DETAILS) {
|
|
130
130
|
required = findByFilter<IRawTweet>(data, '__typename', 'Tweet');
|
|
131
131
|
} else if (type == EResourceType.USER_DETAILS || type == EResourceType.USER_DETAILS_BY_ID) {
|
|
132
132
|
required = findByFilter<IRawUser>(data, '__typename', 'User');
|
|
133
|
-
} else if (
|
|
133
|
+
} else if (
|
|
134
|
+
type == EResourceType.TWEET_SEARCH ||
|
|
135
|
+
type == EResourceType.USER_LIKES ||
|
|
136
|
+
type == EResourceType.LIST_TWEETS
|
|
137
|
+
) {
|
|
134
138
|
required = findByFilter<ITimelineTweet>(data, '__typename', 'TimelineTweet').map(
|
|
135
139
|
(item) => item.tweet_results.result,
|
|
136
140
|
);
|
|
137
|
-
} else
|
|
141
|
+
} else if (
|
|
142
|
+
type == EResourceType.TWEET_FAVORITERS ||
|
|
143
|
+
type == EResourceType.TWEET_RETWEETERS ||
|
|
144
|
+
type == EResourceType.USER_FOLLOWERS ||
|
|
145
|
+
type == EResourceType.USER_FOLLOWING
|
|
146
|
+
) {
|
|
138
147
|
required = findByFilter<ITimelineUser>(data, '__typename', 'TimelineUser').map(
|
|
139
148
|
(item) => item.user_results.result,
|
|
140
149
|
);
|
|
@@ -25,6 +25,21 @@ export class TweetService extends FetcherService {
|
|
|
25
25
|
super(cred);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Get the details of a tweet.
|
|
30
|
+
*
|
|
31
|
+
* @param id - The id of the target tweet.
|
|
32
|
+
* @returns The details of a single tweet with the given tweet id.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
async details(id: string): Promise<Tweet> {
|
|
37
|
+
// Fetching the requested data
|
|
38
|
+
const data = await this.fetch<Tweet>(EResourceType.TWEET_DETAILS, { id: id });
|
|
39
|
+
|
|
40
|
+
return data.list[0];
|
|
41
|
+
}
|
|
42
|
+
|
|
28
43
|
/**
|
|
29
44
|
* Search for tweets using a query.
|
|
30
45
|
*
|
|
@@ -50,18 +65,27 @@ export class TweetService extends FetcherService {
|
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
/**
|
|
53
|
-
* Get the
|
|
68
|
+
* Get the tweets from the tweet list with the given id.
|
|
54
69
|
*
|
|
55
|
-
* @param
|
|
56
|
-
* @
|
|
70
|
+
* @param listId - The id of list from where the tweets are to be fetched.
|
|
71
|
+
* @param count - The number of tweets to fetch, must be \<= 100.
|
|
72
|
+
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
73
|
+
* @returns The list tweets present in the given list.
|
|
57
74
|
*
|
|
58
|
-
* @
|
|
75
|
+
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
59
76
|
*/
|
|
60
|
-
async
|
|
77
|
+
async list(listId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
61
78
|
// Fetching the requested data
|
|
62
|
-
const data = await this.fetch<Tweet>(EResourceType.
|
|
79
|
+
const data = await this.fetch<Tweet>(EResourceType.LIST_TWEETS, {
|
|
80
|
+
id: listId,
|
|
81
|
+
count: count,
|
|
82
|
+
cursor: cursor,
|
|
83
|
+
});
|
|
63
84
|
|
|
64
|
-
|
|
85
|
+
// Sorting the tweets by date, from recent to oldest
|
|
86
|
+
data.list.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
|
|
87
|
+
|
|
88
|
+
return data;
|
|
65
89
|
}
|
|
66
90
|
|
|
67
91
|
/**
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The details of a single Twitter List.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface IList {
|
|
7
|
+
/** The rest id of the list. */
|
|
8
|
+
id: string;
|
|
9
|
+
|
|
10
|
+
/** The name of the list. */
|
|
11
|
+
name: string;
|
|
12
|
+
|
|
13
|
+
/** The date and time of creation of the list, int UTC string format. */
|
|
14
|
+
createdAt: string;
|
|
15
|
+
|
|
16
|
+
/** The list description. */
|
|
17
|
+
description: string;
|
|
18
|
+
|
|
19
|
+
/** The number of memeber of the list. */
|
|
20
|
+
memberCount: number;
|
|
21
|
+
|
|
22
|
+
/** The number of subscribers of the list. */
|
|
23
|
+
subscriberCount: number;
|
|
24
|
+
|
|
25
|
+
/** The rest id of the user who created the list. */
|
|
26
|
+
createdBy: string;
|
|
27
|
+
}
|
package/src/types/Tweet.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// TYPES
|
|
2
|
+
import { IUser } from './User';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* The different types parsed entities like urls, media, mentions, hashtags, etc.
|
|
3
6
|
*
|
|
@@ -26,8 +29,8 @@ export interface ITweet {
|
|
|
26
29
|
/** The rest id of the tweet. */
|
|
27
30
|
id: string;
|
|
28
31
|
|
|
29
|
-
/** The
|
|
30
|
-
tweetBy:
|
|
32
|
+
/** The details of the user who made the tweet. */
|
|
33
|
+
tweetBy: IUser;
|
|
31
34
|
|
|
32
35
|
/** The date and time of creation of the tweet, in UTC string format. */
|
|
33
36
|
createdAt: string;
|
|
@@ -58,4 +61,10 @@ export interface ITweet {
|
|
|
58
61
|
|
|
59
62
|
/** The number of likes of the tweet. */
|
|
60
63
|
likeCount: number;
|
|
64
|
+
|
|
65
|
+
/** The number of views of a tweet. */
|
|
66
|
+
viewCount: number;
|
|
67
|
+
|
|
68
|
+
/** The number of bookmarks of a tweet. */
|
|
69
|
+
bookmarkCount: number;
|
|
61
70
|
}
|
package/.dockerignore
DELETED