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.js
CHANGED
|
@@ -710,6 +710,59 @@ var TweetsClient = class {
|
|
|
710
710
|
};
|
|
711
711
|
yield* paginate(fetchPage, options);
|
|
712
712
|
}
|
|
713
|
+
/**
|
|
714
|
+
* Get the edit history of a tweet.
|
|
715
|
+
*
|
|
716
|
+
* @param tweetId - The tweet ID to get edit history for.
|
|
717
|
+
* @returns Paginated response containing tweet versions.
|
|
718
|
+
*
|
|
719
|
+
* @example
|
|
720
|
+
* ```typescript
|
|
721
|
+
* const history = await client.twitter.tweets.getEditHistory("1234567890");
|
|
722
|
+
* console.log(`${history.data.length} version(s) of this tweet`);
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
async getEditHistory(tweetId) {
|
|
726
|
+
const response = await this.client.request(
|
|
727
|
+
`/v1/twitter/tweets/tweet/${tweetId}/edit_history`
|
|
728
|
+
);
|
|
729
|
+
return createPaginatedResponse(response.data ?? [], void 0);
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Get community notes (Birdwatch) attached to a tweet.
|
|
733
|
+
*
|
|
734
|
+
* @param tweetId - The tweet ID to get community notes for.
|
|
735
|
+
* @returns Paginated response containing community notes.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```typescript
|
|
739
|
+
* const notes = await client.twitter.tweets.getCommunityNotes("1234567890");
|
|
740
|
+
* for (const note of notes.data) {
|
|
741
|
+
* console.log(note.text);
|
|
742
|
+
* }
|
|
743
|
+
* ```
|
|
744
|
+
*/
|
|
745
|
+
async getCommunityNotes(tweetId) {
|
|
746
|
+
const response = await this.client.request(
|
|
747
|
+
`/v1/twitter/tweets/tweet/${tweetId}/community_notes`
|
|
748
|
+
);
|
|
749
|
+
return createPaginatedResponse(response.data ?? [], void 0);
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Get a long-form article by its ID.
|
|
753
|
+
*
|
|
754
|
+
* @param articleId - The article ID to fetch.
|
|
755
|
+
* @returns The article data.
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* ```typescript
|
|
759
|
+
* const article = await client.twitter.tweets.getArticle("abc123");
|
|
760
|
+
* console.log(`${article.title}: ${article.text?.slice(0, 100)}...`);
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
async getArticle(articleId) {
|
|
764
|
+
return this.client.request(`/v1/twitter/tweets/article/${articleId}`);
|
|
765
|
+
}
|
|
713
766
|
};
|
|
714
767
|
|
|
715
768
|
// src/twitter/users.ts
|
|
@@ -1021,6 +1074,92 @@ var UsersClient = class {
|
|
|
1021
1074
|
};
|
|
1022
1075
|
yield* paginate(fetchPage, options);
|
|
1023
1076
|
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Get multiple users by their numeric IDs in a single request.
|
|
1079
|
+
*
|
|
1080
|
+
* @param userIds - List of user IDs to fetch.
|
|
1081
|
+
* @returns Paginated response containing the matching users.
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
* ```typescript
|
|
1085
|
+
* const users = await client.twitter.users.getByIds(["44196397", "783214"]);
|
|
1086
|
+
* for (const user of users.data) {
|
|
1087
|
+
* console.log(`@${user.username}`);
|
|
1088
|
+
* }
|
|
1089
|
+
* ```
|
|
1090
|
+
*/
|
|
1091
|
+
async getByIds(userIds) {
|
|
1092
|
+
const response = await this.client.request(
|
|
1093
|
+
"/v1/twitter/users/batch_by_ids",
|
|
1094
|
+
{ params: { user_ids: userIds.join(",") } }
|
|
1095
|
+
);
|
|
1096
|
+
return createPaginatedResponse(response.data ?? [], void 0);
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Get multiple users by their usernames in a single request.
|
|
1100
|
+
*
|
|
1101
|
+
* @param usernames - List of usernames (without @) to fetch.
|
|
1102
|
+
* @returns Paginated response containing the matching users.
|
|
1103
|
+
*
|
|
1104
|
+
* @example
|
|
1105
|
+
* ```typescript
|
|
1106
|
+
* const users = await client.twitter.users.getByUsernames(["elonmusk", "twitter"]);
|
|
1107
|
+
* for (const user of users.data) {
|
|
1108
|
+
* console.log(`${user.name}: ${user.followers_count?.toLocaleString()} followers`);
|
|
1109
|
+
* }
|
|
1110
|
+
* ```
|
|
1111
|
+
*/
|
|
1112
|
+
async getByUsernames(usernames) {
|
|
1113
|
+
const response = await this.client.request(
|
|
1114
|
+
"/v1/twitter/users/batch_by_usernames",
|
|
1115
|
+
{ params: { usernames: usernames.join(",") } }
|
|
1116
|
+
);
|
|
1117
|
+
return createPaginatedResponse(response.data ?? [], void 0);
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Get tweets that mention a user.
|
|
1121
|
+
*
|
|
1122
|
+
* @param username - The user's username (without @).
|
|
1123
|
+
* @param options - Pagination options with optional count.
|
|
1124
|
+
* @returns Paginated response containing tweets mentioning the user.
|
|
1125
|
+
*
|
|
1126
|
+
* @example
|
|
1127
|
+
* ```typescript
|
|
1128
|
+
* const mentions = await client.twitter.users.getMentions("elonmusk");
|
|
1129
|
+
* for (const tweet of mentions.data) {
|
|
1130
|
+
* console.log(`@${tweet.username}: ${tweet.text.slice(0, 100)}...`);
|
|
1131
|
+
* }
|
|
1132
|
+
* ```
|
|
1133
|
+
*/
|
|
1134
|
+
async getMentions(username, options = {}) {
|
|
1135
|
+
const response = await this.client.request(
|
|
1136
|
+
`/v1/twitter/users/${username}/mentions`,
|
|
1137
|
+
{ params: { count: options.count, cursor: options.cursor } }
|
|
1138
|
+
);
|
|
1139
|
+
return createPaginatedResponse(response.data ?? [], response.next_cursor);
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Get long-form articles authored by a user.
|
|
1143
|
+
*
|
|
1144
|
+
* @param userId - The user's numeric ID.
|
|
1145
|
+
* @param options - Pagination options with optional count.
|
|
1146
|
+
* @returns Paginated response containing the user's articles as tweets.
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```typescript
|
|
1150
|
+
* const articles = await client.twitter.users.getArticles("44196397");
|
|
1151
|
+
* for (const article of articles.data) {
|
|
1152
|
+
* console.log(article.text?.slice(0, 100));
|
|
1153
|
+
* }
|
|
1154
|
+
* ```
|
|
1155
|
+
*/
|
|
1156
|
+
async getArticles(userId, options = {}) {
|
|
1157
|
+
const response = await this.client.request(
|
|
1158
|
+
`/v1/twitter/users/${userId}/articles`,
|
|
1159
|
+
{ params: { count: options.count, cursor: options.cursor } }
|
|
1160
|
+
);
|
|
1161
|
+
return createPaginatedResponse(response.data ?? [], response.next_cursor);
|
|
1162
|
+
}
|
|
1024
1163
|
};
|
|
1025
1164
|
|
|
1026
1165
|
// src/twitter/lists.ts
|
|
@@ -1167,6 +1306,29 @@ var ListsClient = class {
|
|
|
1167
1306
|
);
|
|
1168
1307
|
return createPaginatedResponse(response.data ?? [], response.next_cursor);
|
|
1169
1308
|
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Search tweets within a specific list.
|
|
1311
|
+
*
|
|
1312
|
+
* @param listId - The list ID to search within.
|
|
1313
|
+
* @param query - Search query string.
|
|
1314
|
+
* @param options - Pagination options with optional count.
|
|
1315
|
+
* @returns Paginated response containing matching tweets from the list.
|
|
1316
|
+
*
|
|
1317
|
+
* @example
|
|
1318
|
+
* ```typescript
|
|
1319
|
+
* const results = await client.twitter.lists.searchTweets("123456", "python");
|
|
1320
|
+
* for (const tweet of results.data) {
|
|
1321
|
+
* console.log(`@${tweet.username}: ${tweet.text.slice(0, 100)}...`);
|
|
1322
|
+
* }
|
|
1323
|
+
* ```
|
|
1324
|
+
*/
|
|
1325
|
+
async searchTweets(listId, query, options = {}) {
|
|
1326
|
+
const response = await this.client.request(
|
|
1327
|
+
`/v1/twitter/lists/${listId}/search_tweets`,
|
|
1328
|
+
{ params: { query, count: options.count, cursor: options.cursor } }
|
|
1329
|
+
);
|
|
1330
|
+
return createPaginatedResponse(response.data ?? [], response.next_cursor);
|
|
1331
|
+
}
|
|
1170
1332
|
};
|
|
1171
1333
|
|
|
1172
1334
|
// src/twitter/communities.ts
|
|
@@ -2188,6 +2350,46 @@ function verifyWebhookSignature(secret, body, signatureHeader) {
|
|
|
2188
2350
|
}
|
|
2189
2351
|
}
|
|
2190
2352
|
|
|
2353
|
+
// src/twitter/spaces.ts
|
|
2354
|
+
var SpacesClient = class {
|
|
2355
|
+
client;
|
|
2356
|
+
constructor(client) {
|
|
2357
|
+
this.client = client;
|
|
2358
|
+
}
|
|
2359
|
+
/**
|
|
2360
|
+
* Get details for a specific Twitter Space.
|
|
2361
|
+
*
|
|
2362
|
+
* @param spaceId - The Space ID to fetch.
|
|
2363
|
+
* @returns The Space data.
|
|
2364
|
+
* @throws NotFoundError - If the Space doesn't exist.
|
|
2365
|
+
*
|
|
2366
|
+
* @example
|
|
2367
|
+
* ```typescript
|
|
2368
|
+
* const space = await client.twitter.spaces.getDetail("1eaKbrPPbPwKX");
|
|
2369
|
+
* console.log(`${space.title} — ${space.participant_count} participants`);
|
|
2370
|
+
* ```
|
|
2371
|
+
*/
|
|
2372
|
+
async getDetail(spaceId) {
|
|
2373
|
+
return this.client.request(`/v1/twitter/spaces/${spaceId}`);
|
|
2374
|
+
}
|
|
2375
|
+
/**
|
|
2376
|
+
* Get details for a live video broadcast.
|
|
2377
|
+
*
|
|
2378
|
+
* @param broadcastId - The broadcast ID to fetch.
|
|
2379
|
+
* @returns The broadcast data.
|
|
2380
|
+
* @throws NotFoundError - If the broadcast doesn't exist.
|
|
2381
|
+
*
|
|
2382
|
+
* @example
|
|
2383
|
+
* ```typescript
|
|
2384
|
+
* const broadcast = await client.twitter.spaces.getBroadcast("broadcast123");
|
|
2385
|
+
* console.log(`${broadcast.title}: ${broadcast.total_viewers} viewers`);
|
|
2386
|
+
* ```
|
|
2387
|
+
*/
|
|
2388
|
+
async getBroadcast(broadcastId) {
|
|
2389
|
+
return this.client.request(`/v1/twitter/spaces/broadcast/${broadcastId}`);
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
|
|
2191
2393
|
// src/twitter/client.ts
|
|
2192
2394
|
var TwitterClient = class {
|
|
2193
2395
|
/** Client for tweet operations */
|
|
@@ -2204,6 +2406,8 @@ var TwitterClient = class {
|
|
|
2204
2406
|
geo;
|
|
2205
2407
|
/** Client for real-time stream monitor management and WebSocket streaming */
|
|
2206
2408
|
stream;
|
|
2409
|
+
/** Client for Twitter Spaces and live broadcast operations */
|
|
2410
|
+
spaces;
|
|
2207
2411
|
/**
|
|
2208
2412
|
* Create a new Twitter client.
|
|
2209
2413
|
*
|
|
@@ -2217,6 +2421,7 @@ var TwitterClient = class {
|
|
|
2217
2421
|
this.trends = new TrendsClient(client);
|
|
2218
2422
|
this.geo = new GeoClient(client);
|
|
2219
2423
|
this.stream = new StreamClient(client);
|
|
2424
|
+
this.spaces = new SpacesClient(client);
|
|
2220
2425
|
}
|
|
2221
2426
|
};
|
|
2222
2427
|
|
|
@@ -2377,6 +2582,7 @@ exports.RateLimitError = RateLimitError;
|
|
|
2377
2582
|
exports.ScrapeBadger = ScrapeBadger;
|
|
2378
2583
|
exports.ScrapeBadgerError = ScrapeBadgerError;
|
|
2379
2584
|
exports.ServerError = ServerError;
|
|
2585
|
+
exports.SpacesClient = SpacesClient;
|
|
2380
2586
|
exports.StreamClient = StreamClient;
|
|
2381
2587
|
exports.TimeoutError = TimeoutError;
|
|
2382
2588
|
exports.TrendsClient = TrendsClient;
|