scrapebadger 0.3.1 → 0.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/dist/{index-Cg0sNluO.d.cts → index-CIZUd1Zr.d.cts} +319 -1
- package/dist/{index-Cg0sNluO.d.ts → index-CIZUd1Zr.d.ts} +319 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +206 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +206 -1
- package/dist/index.mjs.map +1 -1
- package/dist/twitter/index.d.cts +1 -1
- package/dist/twitter/index.d.ts +1 -1
- package/dist/twitter/index.js +206 -0
- package/dist/twitter/index.js.map +1 -1
- package/dist/twitter/index.mjs +206 -1
- package/dist/twitter/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -704,6 +704,59 @@ var TweetsClient = class {
|
|
|
704
704
|
};
|
|
705
705
|
yield* paginate(fetchPage, options);
|
|
706
706
|
}
|
|
707
|
+
/**
|
|
708
|
+
* Get the edit history of a tweet.
|
|
709
|
+
*
|
|
710
|
+
* @param tweetId - The tweet ID to get edit history for.
|
|
711
|
+
* @returns Paginated response containing tweet versions.
|
|
712
|
+
*
|
|
713
|
+
* @example
|
|
714
|
+
* ```typescript
|
|
715
|
+
* const history = await client.twitter.tweets.getEditHistory("1234567890");
|
|
716
|
+
* console.log(`${history.data.length} version(s) of this tweet`);
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
719
|
+
async getEditHistory(tweetId) {
|
|
720
|
+
const response = await this.client.request(
|
|
721
|
+
`/v1/twitter/tweets/tweet/${tweetId}/edit_history`
|
|
722
|
+
);
|
|
723
|
+
return createPaginatedResponse(response.data ?? [], void 0);
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Get community notes (Birdwatch) attached to a tweet.
|
|
727
|
+
*
|
|
728
|
+
* @param tweetId - The tweet ID to get community notes for.
|
|
729
|
+
* @returns Paginated response containing community notes.
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
* ```typescript
|
|
733
|
+
* const notes = await client.twitter.tweets.getCommunityNotes("1234567890");
|
|
734
|
+
* for (const note of notes.data) {
|
|
735
|
+
* console.log(note.text);
|
|
736
|
+
* }
|
|
737
|
+
* ```
|
|
738
|
+
*/
|
|
739
|
+
async getCommunityNotes(tweetId) {
|
|
740
|
+
const response = await this.client.request(
|
|
741
|
+
`/v1/twitter/tweets/tweet/${tweetId}/community_notes`
|
|
742
|
+
);
|
|
743
|
+
return createPaginatedResponse(response.data ?? [], void 0);
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Get a long-form article by its ID.
|
|
747
|
+
*
|
|
748
|
+
* @param articleId - The article ID to fetch.
|
|
749
|
+
* @returns The article data.
|
|
750
|
+
*
|
|
751
|
+
* @example
|
|
752
|
+
* ```typescript
|
|
753
|
+
* const article = await client.twitter.tweets.getArticle("abc123");
|
|
754
|
+
* console.log(`${article.title}: ${article.text?.slice(0, 100)}...`);
|
|
755
|
+
* ```
|
|
756
|
+
*/
|
|
757
|
+
async getArticle(articleId) {
|
|
758
|
+
return this.client.request(`/v1/twitter/tweets/article/${articleId}`);
|
|
759
|
+
}
|
|
707
760
|
};
|
|
708
761
|
|
|
709
762
|
// src/twitter/users.ts
|
|
@@ -1015,6 +1068,92 @@ var UsersClient = class {
|
|
|
1015
1068
|
};
|
|
1016
1069
|
yield* paginate(fetchPage, options);
|
|
1017
1070
|
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Get multiple users by their numeric IDs in a single request.
|
|
1073
|
+
*
|
|
1074
|
+
* @param userIds - List of user IDs to fetch.
|
|
1075
|
+
* @returns Paginated response containing the matching users.
|
|
1076
|
+
*
|
|
1077
|
+
* @example
|
|
1078
|
+
* ```typescript
|
|
1079
|
+
* const users = await client.twitter.users.getByIds(["44196397", "783214"]);
|
|
1080
|
+
* for (const user of users.data) {
|
|
1081
|
+
* console.log(`@${user.username}`);
|
|
1082
|
+
* }
|
|
1083
|
+
* ```
|
|
1084
|
+
*/
|
|
1085
|
+
async getByIds(userIds) {
|
|
1086
|
+
const response = await this.client.request(
|
|
1087
|
+
"/v1/twitter/users/batch_by_ids",
|
|
1088
|
+
{ params: { user_ids: userIds.join(",") } }
|
|
1089
|
+
);
|
|
1090
|
+
return createPaginatedResponse(response.data ?? [], void 0);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Get multiple users by their usernames in a single request.
|
|
1094
|
+
*
|
|
1095
|
+
* @param usernames - List of usernames (without @) to fetch.
|
|
1096
|
+
* @returns Paginated response containing the matching users.
|
|
1097
|
+
*
|
|
1098
|
+
* @example
|
|
1099
|
+
* ```typescript
|
|
1100
|
+
* const users = await client.twitter.users.getByUsernames(["elonmusk", "twitter"]);
|
|
1101
|
+
* for (const user of users.data) {
|
|
1102
|
+
* console.log(`${user.name}: ${user.followers_count?.toLocaleString()} followers`);
|
|
1103
|
+
* }
|
|
1104
|
+
* ```
|
|
1105
|
+
*/
|
|
1106
|
+
async getByUsernames(usernames) {
|
|
1107
|
+
const response = await this.client.request(
|
|
1108
|
+
"/v1/twitter/users/batch_by_usernames",
|
|
1109
|
+
{ params: { usernames: usernames.join(",") } }
|
|
1110
|
+
);
|
|
1111
|
+
return createPaginatedResponse(response.data ?? [], void 0);
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Get tweets that mention a user.
|
|
1115
|
+
*
|
|
1116
|
+
* @param username - The user's username (without @).
|
|
1117
|
+
* @param options - Pagination options with optional count.
|
|
1118
|
+
* @returns Paginated response containing tweets mentioning the user.
|
|
1119
|
+
*
|
|
1120
|
+
* @example
|
|
1121
|
+
* ```typescript
|
|
1122
|
+
* const mentions = await client.twitter.users.getMentions("elonmusk");
|
|
1123
|
+
* for (const tweet of mentions.data) {
|
|
1124
|
+
* console.log(`@${tweet.username}: ${tweet.text.slice(0, 100)}...`);
|
|
1125
|
+
* }
|
|
1126
|
+
* ```
|
|
1127
|
+
*/
|
|
1128
|
+
async getMentions(username, options = {}) {
|
|
1129
|
+
const response = await this.client.request(
|
|
1130
|
+
`/v1/twitter/users/${username}/mentions`,
|
|
1131
|
+
{ params: { count: options.count, cursor: options.cursor } }
|
|
1132
|
+
);
|
|
1133
|
+
return createPaginatedResponse(response.data ?? [], response.next_cursor);
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Get long-form articles authored by a user.
|
|
1137
|
+
*
|
|
1138
|
+
* @param userId - The user's numeric ID.
|
|
1139
|
+
* @param options - Pagination options with optional count.
|
|
1140
|
+
* @returns Paginated response containing the user's articles as tweets.
|
|
1141
|
+
*
|
|
1142
|
+
* @example
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* const articles = await client.twitter.users.getArticles("44196397");
|
|
1145
|
+
* for (const article of articles.data) {
|
|
1146
|
+
* console.log(article.text?.slice(0, 100));
|
|
1147
|
+
* }
|
|
1148
|
+
* ```
|
|
1149
|
+
*/
|
|
1150
|
+
async getArticles(userId, options = {}) {
|
|
1151
|
+
const response = await this.client.request(
|
|
1152
|
+
`/v1/twitter/users/${userId}/articles`,
|
|
1153
|
+
{ params: { count: options.count, cursor: options.cursor } }
|
|
1154
|
+
);
|
|
1155
|
+
return createPaginatedResponse(response.data ?? [], response.next_cursor);
|
|
1156
|
+
}
|
|
1018
1157
|
};
|
|
1019
1158
|
|
|
1020
1159
|
// src/twitter/lists.ts
|
|
@@ -1161,6 +1300,29 @@ var ListsClient = class {
|
|
|
1161
1300
|
);
|
|
1162
1301
|
return createPaginatedResponse(response.data ?? [], response.next_cursor);
|
|
1163
1302
|
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Search tweets within a specific list.
|
|
1305
|
+
*
|
|
1306
|
+
* @param listId - The list ID to search within.
|
|
1307
|
+
* @param query - Search query string.
|
|
1308
|
+
* @param options - Pagination options with optional count.
|
|
1309
|
+
* @returns Paginated response containing matching tweets from the list.
|
|
1310
|
+
*
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```typescript
|
|
1313
|
+
* const results = await client.twitter.lists.searchTweets("123456", "python");
|
|
1314
|
+
* for (const tweet of results.data) {
|
|
1315
|
+
* console.log(`@${tweet.username}: ${tweet.text.slice(0, 100)}...`);
|
|
1316
|
+
* }
|
|
1317
|
+
* ```
|
|
1318
|
+
*/
|
|
1319
|
+
async searchTweets(listId, query, options = {}) {
|
|
1320
|
+
const response = await this.client.request(
|
|
1321
|
+
`/v1/twitter/lists/${listId}/search_tweets`,
|
|
1322
|
+
{ params: { query, count: options.count, cursor: options.cursor } }
|
|
1323
|
+
);
|
|
1324
|
+
return createPaginatedResponse(response.data ?? [], response.next_cursor);
|
|
1325
|
+
}
|
|
1164
1326
|
};
|
|
1165
1327
|
|
|
1166
1328
|
// src/twitter/communities.ts
|
|
@@ -2182,6 +2344,46 @@ function verifyWebhookSignature(secret, body, signatureHeader) {
|
|
|
2182
2344
|
}
|
|
2183
2345
|
}
|
|
2184
2346
|
|
|
2347
|
+
// src/twitter/spaces.ts
|
|
2348
|
+
var SpacesClient = class {
|
|
2349
|
+
client;
|
|
2350
|
+
constructor(client) {
|
|
2351
|
+
this.client = client;
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Get details for a specific Twitter Space.
|
|
2355
|
+
*
|
|
2356
|
+
* @param spaceId - The Space ID to fetch.
|
|
2357
|
+
* @returns The Space data.
|
|
2358
|
+
* @throws NotFoundError - If the Space doesn't exist.
|
|
2359
|
+
*
|
|
2360
|
+
* @example
|
|
2361
|
+
* ```typescript
|
|
2362
|
+
* const space = await client.twitter.spaces.getDetail("1eaKbrPPbPwKX");
|
|
2363
|
+
* console.log(`${space.title} — ${space.participant_count} participants`);
|
|
2364
|
+
* ```
|
|
2365
|
+
*/
|
|
2366
|
+
async getDetail(spaceId) {
|
|
2367
|
+
return this.client.request(`/v1/twitter/spaces/${spaceId}`);
|
|
2368
|
+
}
|
|
2369
|
+
/**
|
|
2370
|
+
* Get details for a live video broadcast.
|
|
2371
|
+
*
|
|
2372
|
+
* @param broadcastId - The broadcast ID to fetch.
|
|
2373
|
+
* @returns The broadcast data.
|
|
2374
|
+
* @throws NotFoundError - If the broadcast doesn't exist.
|
|
2375
|
+
*
|
|
2376
|
+
* @example
|
|
2377
|
+
* ```typescript
|
|
2378
|
+
* const broadcast = await client.twitter.spaces.getBroadcast("broadcast123");
|
|
2379
|
+
* console.log(`${broadcast.title}: ${broadcast.total_viewers} viewers`);
|
|
2380
|
+
* ```
|
|
2381
|
+
*/
|
|
2382
|
+
async getBroadcast(broadcastId) {
|
|
2383
|
+
return this.client.request(`/v1/twitter/spaces/broadcast/${broadcastId}`);
|
|
2384
|
+
}
|
|
2385
|
+
};
|
|
2386
|
+
|
|
2185
2387
|
// src/twitter/client.ts
|
|
2186
2388
|
var TwitterClient = class {
|
|
2187
2389
|
/** Client for tweet operations */
|
|
@@ -2198,6 +2400,8 @@ var TwitterClient = class {
|
|
|
2198
2400
|
geo;
|
|
2199
2401
|
/** Client for real-time stream monitor management and WebSocket streaming */
|
|
2200
2402
|
stream;
|
|
2403
|
+
/** Client for Twitter Spaces and live broadcast operations */
|
|
2404
|
+
spaces;
|
|
2201
2405
|
/**
|
|
2202
2406
|
* Create a new Twitter client.
|
|
2203
2407
|
*
|
|
@@ -2211,6 +2415,7 @@ var TwitterClient = class {
|
|
|
2211
2415
|
this.trends = new TrendsClient(client);
|
|
2212
2416
|
this.geo = new GeoClient(client);
|
|
2213
2417
|
this.stream = new StreamClient(client);
|
|
2418
|
+
this.spaces = new SpacesClient(client);
|
|
2214
2419
|
}
|
|
2215
2420
|
};
|
|
2216
2421
|
|
|
@@ -2359,6 +2564,6 @@ var ScrapeBadger = class {
|
|
|
2359
2564
|
}
|
|
2360
2565
|
};
|
|
2361
2566
|
|
|
2362
|
-
export { AccountRestrictedError, AuthenticationError, CommunitiesClient, ConflictError, GeoClient, InsufficientCreditsError, ListsClient, NotFoundError, RateLimitError, ScrapeBadger, ScrapeBadgerError, ServerError, StreamClient, TimeoutError, TrendsClient, TweetsClient, TwitterClient, UsersClient, ValidationError, WebClient, WebSocketStreamError, collectAll, verifyWebhookSignature };
|
|
2567
|
+
export { AccountRestrictedError, AuthenticationError, CommunitiesClient, ConflictError, GeoClient, InsufficientCreditsError, ListsClient, NotFoundError, RateLimitError, ScrapeBadger, ScrapeBadgerError, ServerError, SpacesClient, StreamClient, TimeoutError, TrendsClient, TweetsClient, TwitterClient, UsersClient, ValidationError, WebClient, WebSocketStreamError, collectAll, verifyWebhookSignature };
|
|
2363
2568
|
//# sourceMappingURL=index.mjs.map
|
|
2364
2569
|
//# sourceMappingURL=index.mjs.map
|