scrapebadger 0.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/LICENSE +21 -0
- package/README.md +295 -0
- package/dist/index-B3rJn_Jw.d.cts +1739 -0
- package/dist/index-B3rJn_Jw.d.ts +1739 -0
- package/dist/index.d.cts +156 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.js +1433 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1414 -0
- package/dist/index.mjs.map +1 -0
- package/dist/twitter/index.d.cts +1 -0
- package/dist/twitter/index.d.ts +1 -0
- package/dist/twitter/index.js +1113 -0
- package/dist/twitter/index.js.map +1 -0
- package/dist/twitter/index.mjs +1105 -0
- package/dist/twitter/index.mjs.map +1 -0
- package/package.json +86 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { T as TwitterClient, S as ScrapeBadgerConfig } from './index-B3rJn_Jw.cjs';
|
|
2
|
+
export { A as ApiResponse, C as CommunitiesClient, t as Community, r as CommunityBanner, u as CommunityMember, s as CommunityRule, g as CommunityTweetType, G as GeoClient, e as GeoSearchOptions, H as Hashtag, I as IteratorOptions, q as List, z as ListResponse, L as ListsClient, w as Location, M as Media, P as PaginatedResponse, a as PaginationOptions, y as Place, x as PlaceTrends, i as Poll, h as PollOption, Q as QueryType, R as ResolvedConfig, v as Trend, f as TrendCategory, d as TrendsClient, m as Tweet, l as TweetPlace, b as TweetsClient, j as Url, n as User, o as UserAbout, p as UserIds, k as UserMention, U as UsersClient, c as collectAll } from './index-B3rJn_Jw.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main ScrapeBadger client.
|
|
6
|
+
*
|
|
7
|
+
* This is the primary entry point for the ScrapeBadger SDK.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* ScrapeBadger API client.
|
|
12
|
+
*
|
|
13
|
+
* The main client for interacting with the ScrapeBadger API.
|
|
14
|
+
* Provides access to all available scrapers through typed sub-clients.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { ScrapeBadger } from "scrapebadger";
|
|
19
|
+
*
|
|
20
|
+
* // Create client with API key
|
|
21
|
+
* const client = new ScrapeBadger({ apiKey: "your-api-key" });
|
|
22
|
+
*
|
|
23
|
+
* // Or use environment variable (SCRAPEBADGER_API_KEY)
|
|
24
|
+
* const client = new ScrapeBadger();
|
|
25
|
+
*
|
|
26
|
+
* // Access Twitter API
|
|
27
|
+
* const tweet = await client.twitter.tweets.getById("1234567890");
|
|
28
|
+
* const user = await client.twitter.users.getByUsername("elonmusk");
|
|
29
|
+
*
|
|
30
|
+
* // Search with automatic pagination
|
|
31
|
+
* for await (const tweet of client.twitter.tweets.searchAll("python")) {
|
|
32
|
+
* console.log(tweet.text);
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // Collect all results into an array
|
|
36
|
+
* import { collectAll } from "scrapebadger";
|
|
37
|
+
* const tweets = await collectAll(
|
|
38
|
+
* client.twitter.tweets.searchAll("python", { maxItems: 100 })
|
|
39
|
+
* );
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare class ScrapeBadger {
|
|
43
|
+
private readonly baseClient;
|
|
44
|
+
/** Twitter API client */
|
|
45
|
+
readonly twitter: TwitterClient;
|
|
46
|
+
/**
|
|
47
|
+
* Create a new ScrapeBadger client.
|
|
48
|
+
*
|
|
49
|
+
* @param config - Configuration options. If apiKey is not provided,
|
|
50
|
+
* it will be read from the SCRAPEBADGER_API_KEY environment variable.
|
|
51
|
+
* @throws Error if no API key is provided or found in environment.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // With explicit API key
|
|
56
|
+
* const client = new ScrapeBadger({ apiKey: "your-api-key" });
|
|
57
|
+
*
|
|
58
|
+
* // With custom options
|
|
59
|
+
* const client = new ScrapeBadger({
|
|
60
|
+
* apiKey: "your-api-key",
|
|
61
|
+
* baseUrl: "https://custom.api.com",
|
|
62
|
+
* timeout: 60000,
|
|
63
|
+
* maxRetries: 5
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // Using environment variable
|
|
67
|
+
* // Set SCRAPEBADGER_API_KEY=your-api-key
|
|
68
|
+
* const client = new ScrapeBadger();
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
constructor(config?: Partial<ScrapeBadgerConfig>);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Custom exceptions for the ScrapeBadger SDK.
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* Base error class for all ScrapeBadger errors.
|
|
79
|
+
*/
|
|
80
|
+
declare class ScrapeBadgerError extends Error {
|
|
81
|
+
constructor(message: string);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Raised when authentication fails (invalid or missing API key).
|
|
85
|
+
*/
|
|
86
|
+
declare class AuthenticationError extends ScrapeBadgerError {
|
|
87
|
+
constructor(message?: string);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Raised when rate limit is exceeded.
|
|
91
|
+
*/
|
|
92
|
+
declare class RateLimitError extends ScrapeBadgerError {
|
|
93
|
+
/** Unix timestamp when the rate limit resets */
|
|
94
|
+
readonly retryAfter: number | undefined;
|
|
95
|
+
/** Maximum requests per minute for this tier */
|
|
96
|
+
readonly limit: number | undefined;
|
|
97
|
+
/** Remaining requests in the current window */
|
|
98
|
+
readonly remaining: number | undefined;
|
|
99
|
+
constructor(message?: string, options?: {
|
|
100
|
+
retryAfter?: number;
|
|
101
|
+
limit?: number;
|
|
102
|
+
remaining?: number;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Raised when the requested resource is not found.
|
|
107
|
+
*/
|
|
108
|
+
declare class NotFoundError extends ScrapeBadgerError {
|
|
109
|
+
/** The resource type that was not found */
|
|
110
|
+
readonly resourceType: string | undefined;
|
|
111
|
+
/** The resource ID that was not found */
|
|
112
|
+
readonly resourceId: string | undefined;
|
|
113
|
+
constructor(message?: string, resourceType?: string, resourceId?: string);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Raised when the request is invalid.
|
|
117
|
+
*/
|
|
118
|
+
declare class ValidationError extends ScrapeBadgerError {
|
|
119
|
+
/** Validation errors by field */
|
|
120
|
+
readonly errors: Record<string, string[]> | undefined;
|
|
121
|
+
constructor(message?: string, errors?: Record<string, string[]>);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Raised when an internal server error occurs.
|
|
125
|
+
*/
|
|
126
|
+
declare class ServerError extends ScrapeBadgerError {
|
|
127
|
+
/** HTTP status code */
|
|
128
|
+
readonly statusCode: number;
|
|
129
|
+
constructor(message?: string, statusCode?: number);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Raised when the request times out.
|
|
133
|
+
*/
|
|
134
|
+
declare class TimeoutError extends ScrapeBadgerError {
|
|
135
|
+
/** Timeout duration in milliseconds */
|
|
136
|
+
readonly timeout: number;
|
|
137
|
+
constructor(message: string | undefined, timeout: number);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Raised when the account has insufficient credits.
|
|
141
|
+
*/
|
|
142
|
+
declare class InsufficientCreditsError extends ScrapeBadgerError {
|
|
143
|
+
/** Current credit balance */
|
|
144
|
+
readonly creditsBalance: number | undefined;
|
|
145
|
+
constructor(message?: string, creditsBalance?: number);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Raised when the account is restricted.
|
|
149
|
+
*/
|
|
150
|
+
declare class AccountRestrictedError extends ScrapeBadgerError {
|
|
151
|
+
/** Reason for the restriction */
|
|
152
|
+
readonly reason: string | undefined;
|
|
153
|
+
constructor(message?: string, reason?: string);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export { AccountRestrictedError, AuthenticationError, InsufficientCreditsError, NotFoundError, RateLimitError, ScrapeBadger, ScrapeBadgerConfig, ScrapeBadgerError, ServerError, TimeoutError, TwitterClient, ValidationError };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { T as TwitterClient, S as ScrapeBadgerConfig } from './index-B3rJn_Jw.js';
|
|
2
|
+
export { A as ApiResponse, C as CommunitiesClient, t as Community, r as CommunityBanner, u as CommunityMember, s as CommunityRule, g as CommunityTweetType, G as GeoClient, e as GeoSearchOptions, H as Hashtag, I as IteratorOptions, q as List, z as ListResponse, L as ListsClient, w as Location, M as Media, P as PaginatedResponse, a as PaginationOptions, y as Place, x as PlaceTrends, i as Poll, h as PollOption, Q as QueryType, R as ResolvedConfig, v as Trend, f as TrendCategory, d as TrendsClient, m as Tweet, l as TweetPlace, b as TweetsClient, j as Url, n as User, o as UserAbout, p as UserIds, k as UserMention, U as UsersClient, c as collectAll } from './index-B3rJn_Jw.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main ScrapeBadger client.
|
|
6
|
+
*
|
|
7
|
+
* This is the primary entry point for the ScrapeBadger SDK.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* ScrapeBadger API client.
|
|
12
|
+
*
|
|
13
|
+
* The main client for interacting with the ScrapeBadger API.
|
|
14
|
+
* Provides access to all available scrapers through typed sub-clients.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { ScrapeBadger } from "scrapebadger";
|
|
19
|
+
*
|
|
20
|
+
* // Create client with API key
|
|
21
|
+
* const client = new ScrapeBadger({ apiKey: "your-api-key" });
|
|
22
|
+
*
|
|
23
|
+
* // Or use environment variable (SCRAPEBADGER_API_KEY)
|
|
24
|
+
* const client = new ScrapeBadger();
|
|
25
|
+
*
|
|
26
|
+
* // Access Twitter API
|
|
27
|
+
* const tweet = await client.twitter.tweets.getById("1234567890");
|
|
28
|
+
* const user = await client.twitter.users.getByUsername("elonmusk");
|
|
29
|
+
*
|
|
30
|
+
* // Search with automatic pagination
|
|
31
|
+
* for await (const tweet of client.twitter.tweets.searchAll("python")) {
|
|
32
|
+
* console.log(tweet.text);
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // Collect all results into an array
|
|
36
|
+
* import { collectAll } from "scrapebadger";
|
|
37
|
+
* const tweets = await collectAll(
|
|
38
|
+
* client.twitter.tweets.searchAll("python", { maxItems: 100 })
|
|
39
|
+
* );
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare class ScrapeBadger {
|
|
43
|
+
private readonly baseClient;
|
|
44
|
+
/** Twitter API client */
|
|
45
|
+
readonly twitter: TwitterClient;
|
|
46
|
+
/**
|
|
47
|
+
* Create a new ScrapeBadger client.
|
|
48
|
+
*
|
|
49
|
+
* @param config - Configuration options. If apiKey is not provided,
|
|
50
|
+
* it will be read from the SCRAPEBADGER_API_KEY environment variable.
|
|
51
|
+
* @throws Error if no API key is provided or found in environment.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // With explicit API key
|
|
56
|
+
* const client = new ScrapeBadger({ apiKey: "your-api-key" });
|
|
57
|
+
*
|
|
58
|
+
* // With custom options
|
|
59
|
+
* const client = new ScrapeBadger({
|
|
60
|
+
* apiKey: "your-api-key",
|
|
61
|
+
* baseUrl: "https://custom.api.com",
|
|
62
|
+
* timeout: 60000,
|
|
63
|
+
* maxRetries: 5
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // Using environment variable
|
|
67
|
+
* // Set SCRAPEBADGER_API_KEY=your-api-key
|
|
68
|
+
* const client = new ScrapeBadger();
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
constructor(config?: Partial<ScrapeBadgerConfig>);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Custom exceptions for the ScrapeBadger SDK.
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* Base error class for all ScrapeBadger errors.
|
|
79
|
+
*/
|
|
80
|
+
declare class ScrapeBadgerError extends Error {
|
|
81
|
+
constructor(message: string);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Raised when authentication fails (invalid or missing API key).
|
|
85
|
+
*/
|
|
86
|
+
declare class AuthenticationError extends ScrapeBadgerError {
|
|
87
|
+
constructor(message?: string);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Raised when rate limit is exceeded.
|
|
91
|
+
*/
|
|
92
|
+
declare class RateLimitError extends ScrapeBadgerError {
|
|
93
|
+
/** Unix timestamp when the rate limit resets */
|
|
94
|
+
readonly retryAfter: number | undefined;
|
|
95
|
+
/** Maximum requests per minute for this tier */
|
|
96
|
+
readonly limit: number | undefined;
|
|
97
|
+
/** Remaining requests in the current window */
|
|
98
|
+
readonly remaining: number | undefined;
|
|
99
|
+
constructor(message?: string, options?: {
|
|
100
|
+
retryAfter?: number;
|
|
101
|
+
limit?: number;
|
|
102
|
+
remaining?: number;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Raised when the requested resource is not found.
|
|
107
|
+
*/
|
|
108
|
+
declare class NotFoundError extends ScrapeBadgerError {
|
|
109
|
+
/** The resource type that was not found */
|
|
110
|
+
readonly resourceType: string | undefined;
|
|
111
|
+
/** The resource ID that was not found */
|
|
112
|
+
readonly resourceId: string | undefined;
|
|
113
|
+
constructor(message?: string, resourceType?: string, resourceId?: string);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Raised when the request is invalid.
|
|
117
|
+
*/
|
|
118
|
+
declare class ValidationError extends ScrapeBadgerError {
|
|
119
|
+
/** Validation errors by field */
|
|
120
|
+
readonly errors: Record<string, string[]> | undefined;
|
|
121
|
+
constructor(message?: string, errors?: Record<string, string[]>);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Raised when an internal server error occurs.
|
|
125
|
+
*/
|
|
126
|
+
declare class ServerError extends ScrapeBadgerError {
|
|
127
|
+
/** HTTP status code */
|
|
128
|
+
readonly statusCode: number;
|
|
129
|
+
constructor(message?: string, statusCode?: number);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Raised when the request times out.
|
|
133
|
+
*/
|
|
134
|
+
declare class TimeoutError extends ScrapeBadgerError {
|
|
135
|
+
/** Timeout duration in milliseconds */
|
|
136
|
+
readonly timeout: number;
|
|
137
|
+
constructor(message: string | undefined, timeout: number);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Raised when the account has insufficient credits.
|
|
141
|
+
*/
|
|
142
|
+
declare class InsufficientCreditsError extends ScrapeBadgerError {
|
|
143
|
+
/** Current credit balance */
|
|
144
|
+
readonly creditsBalance: number | undefined;
|
|
145
|
+
constructor(message?: string, creditsBalance?: number);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Raised when the account is restricted.
|
|
149
|
+
*/
|
|
150
|
+
declare class AccountRestrictedError extends ScrapeBadgerError {
|
|
151
|
+
/** Reason for the restriction */
|
|
152
|
+
readonly reason: string | undefined;
|
|
153
|
+
constructor(message?: string, reason?: string);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export { AccountRestrictedError, AuthenticationError, InsufficientCreditsError, NotFoundError, RateLimitError, ScrapeBadger, ScrapeBadgerConfig, ScrapeBadgerError, ServerError, TimeoutError, TwitterClient, ValidationError };
|