@crawlgate/sdk 1.0.1 → 1.0.2
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 +9 -31
- package/dist/index.cjs +0 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -156
- package/dist/index.d.ts +4 -156
- package/dist/index.js +0 -108
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,18 +2,11 @@ import { ZodTypeAny } from 'zod';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Scraping engine selection
|
|
5
|
-
* - `static`:
|
|
6
|
-
* - `dynamic`:
|
|
7
|
-
* - `smart`: Auto-selects
|
|
5
|
+
* - `static`: Fast HTTP-based scraping (no JavaScript rendering)
|
|
6
|
+
* - `dynamic`: Full browser scraping with JavaScript support
|
|
7
|
+
* - `smart`: Auto-selects the best engine based on the target page
|
|
8
8
|
*/
|
|
9
9
|
type Engine = "static" | "dynamic" | "smart";
|
|
10
|
-
/**
|
|
11
|
-
* Proxy options
|
|
12
|
-
* - `iproyal`: IPRoyal residential proxy
|
|
13
|
-
* - `tor`: Tor network proxy
|
|
14
|
-
* - `stealth`: Stealth mode with residential proxy (dynamic engine only)
|
|
15
|
-
*/
|
|
16
|
-
type ProxyOption = "iproyal" | "tor" | "stealth" | string;
|
|
17
10
|
/**
|
|
18
11
|
* Output format types
|
|
19
12
|
*/
|
|
@@ -125,10 +118,6 @@ interface ScrapeOptions {
|
|
|
125
118
|
* Request timeout in milliseconds
|
|
126
119
|
*/
|
|
127
120
|
timeout?: number;
|
|
128
|
-
/**
|
|
129
|
-
* Proxy configuration
|
|
130
|
-
*/
|
|
131
|
-
proxy?: ProxyOption;
|
|
132
121
|
/**
|
|
133
122
|
* LLM extraction configuration
|
|
134
123
|
*/
|
|
@@ -250,10 +239,6 @@ interface CrawlOptions {
|
|
|
250
239
|
* HTML tags to exclude
|
|
251
240
|
*/
|
|
252
241
|
excludeTags?: string[];
|
|
253
|
-
/**
|
|
254
|
-
* Proxy configuration
|
|
255
|
-
*/
|
|
256
|
-
proxy?: ProxyOption;
|
|
257
242
|
/**
|
|
258
243
|
* Project ID for usage tracking
|
|
259
244
|
*/
|
|
@@ -333,10 +318,6 @@ interface MapOptions {
|
|
|
333
318
|
* Scraping engine to use
|
|
334
319
|
*/
|
|
335
320
|
engine?: Engine;
|
|
336
|
-
/**
|
|
337
|
-
* Proxy configuration
|
|
338
|
-
*/
|
|
339
|
-
proxy?: ProxyOption;
|
|
340
321
|
/**
|
|
341
322
|
* Project ID for usage tracking
|
|
342
323
|
*/
|
|
@@ -714,90 +695,6 @@ interface ExtractResponse {
|
|
|
714
695
|
*/
|
|
715
696
|
creditsUsed?: number;
|
|
716
697
|
}
|
|
717
|
-
/**
|
|
718
|
-
* Concurrency usage information
|
|
719
|
-
*/
|
|
720
|
-
interface ConcurrencyInfo {
|
|
721
|
-
/**
|
|
722
|
-
* Current active requests
|
|
723
|
-
*/
|
|
724
|
-
concurrency: number;
|
|
725
|
-
/**
|
|
726
|
-
* Maximum allowed concurrent requests
|
|
727
|
-
*/
|
|
728
|
-
maxConcurrency: number;
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* Credit usage information
|
|
732
|
-
*/
|
|
733
|
-
interface CreditUsage {
|
|
734
|
-
/**
|
|
735
|
-
* Remaining credits
|
|
736
|
-
*/
|
|
737
|
-
remainingCredits: number;
|
|
738
|
-
/**
|
|
739
|
-
* Total plan credits
|
|
740
|
-
*/
|
|
741
|
-
planCredits?: number;
|
|
742
|
-
/**
|
|
743
|
-
* Billing period start date
|
|
744
|
-
*/
|
|
745
|
-
billingPeriodStart?: string | null;
|
|
746
|
-
/**
|
|
747
|
-
* Billing period end date
|
|
748
|
-
*/
|
|
749
|
-
billingPeriodEnd?: string | null;
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Token usage information
|
|
753
|
-
*/
|
|
754
|
-
interface TokenUsage {
|
|
755
|
-
/**
|
|
756
|
-
* Remaining tokens
|
|
757
|
-
*/
|
|
758
|
-
remainingTokens: number;
|
|
759
|
-
/**
|
|
760
|
-
* Total plan tokens
|
|
761
|
-
*/
|
|
762
|
-
planTokens?: number;
|
|
763
|
-
/**
|
|
764
|
-
* Billing period start date
|
|
765
|
-
*/
|
|
766
|
-
billingPeriodStart?: string | null;
|
|
767
|
-
/**
|
|
768
|
-
* Billing period end date
|
|
769
|
-
*/
|
|
770
|
-
billingPeriodEnd?: string | null;
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Queue status information
|
|
774
|
-
*/
|
|
775
|
-
interface QueueStatus {
|
|
776
|
-
/**
|
|
777
|
-
* Whether the request was successful
|
|
778
|
-
*/
|
|
779
|
-
success: boolean;
|
|
780
|
-
/**
|
|
781
|
-
* Total jobs in queue
|
|
782
|
-
*/
|
|
783
|
-
jobsInQueue: number;
|
|
784
|
-
/**
|
|
785
|
-
* Active jobs currently processing
|
|
786
|
-
*/
|
|
787
|
-
activeJobsInQueue: number;
|
|
788
|
-
/**
|
|
789
|
-
* Jobs waiting to be processed
|
|
790
|
-
*/
|
|
791
|
-
waitingJobsInQueue: number;
|
|
792
|
-
/**
|
|
793
|
-
* Maximum concurrency
|
|
794
|
-
*/
|
|
795
|
-
maxConcurrency: number;
|
|
796
|
-
/**
|
|
797
|
-
* Timestamp of most recent successful job
|
|
798
|
-
*/
|
|
799
|
-
mostRecentSuccess: string | null;
|
|
800
|
-
}
|
|
801
698
|
/**
|
|
802
699
|
* Crawl error information
|
|
803
700
|
*/
|
|
@@ -1231,55 +1128,6 @@ declare class CrawlGateClient {
|
|
|
1231
1128
|
* ```
|
|
1232
1129
|
*/
|
|
1233
1130
|
search(query: string, options?: SearchOptions): Promise<SearchResponse>;
|
|
1234
|
-
/**
|
|
1235
|
-
* Get current concurrency usage
|
|
1236
|
-
*
|
|
1237
|
-
* @returns Current and max concurrency
|
|
1238
|
-
*
|
|
1239
|
-
* @example
|
|
1240
|
-
* ```typescript
|
|
1241
|
-
* const { concurrency, maxConcurrency } = await client.getConcurrency();
|
|
1242
|
-
* console.log(`Using ${concurrency}/${maxConcurrency} concurrent requests`);
|
|
1243
|
-
* ```
|
|
1244
|
-
*/
|
|
1245
|
-
getConcurrency(): Promise<ConcurrencyInfo>;
|
|
1246
|
-
/**
|
|
1247
|
-
* Get current credit usage
|
|
1248
|
-
*
|
|
1249
|
-
* @returns Credit usage information
|
|
1250
|
-
*
|
|
1251
|
-
* @example
|
|
1252
|
-
* ```typescript
|
|
1253
|
-
* const credits = await client.getCreditUsage();
|
|
1254
|
-
* console.log(`Remaining credits: ${credits.remainingCredits}`);
|
|
1255
|
-
* ```
|
|
1256
|
-
*/
|
|
1257
|
-
getCreditUsage(): Promise<CreditUsage>;
|
|
1258
|
-
/**
|
|
1259
|
-
* Get current token usage (for LLM extraction)
|
|
1260
|
-
*
|
|
1261
|
-
* @returns Token usage information
|
|
1262
|
-
*
|
|
1263
|
-
* @example
|
|
1264
|
-
* ```typescript
|
|
1265
|
-
* const tokens = await client.getTokenUsage();
|
|
1266
|
-
* console.log(`Remaining tokens: ${tokens.remainingTokens}`);
|
|
1267
|
-
* ```
|
|
1268
|
-
*/
|
|
1269
|
-
getTokenUsage(): Promise<TokenUsage>;
|
|
1270
|
-
/**
|
|
1271
|
-
* Get queue status information
|
|
1272
|
-
*
|
|
1273
|
-
* @returns Queue status metrics
|
|
1274
|
-
*
|
|
1275
|
-
* @example
|
|
1276
|
-
* ```typescript
|
|
1277
|
-
* const queue = await client.getQueueStatus();
|
|
1278
|
-
* console.log(`Jobs in queue: ${queue.jobsInQueue}`);
|
|
1279
|
-
* console.log(`Active: ${queue.activeJobsInQueue}, Waiting: ${queue.waitingJobsInQueue}`);
|
|
1280
|
-
* ```
|
|
1281
|
-
*/
|
|
1282
|
-
getQueueStatus(): Promise<QueueStatus>;
|
|
1283
1131
|
}
|
|
1284
1132
|
|
|
1285
1133
|
/**
|
|
@@ -1353,4 +1201,4 @@ declare class ExtractionError extends CrawlGateError {
|
|
|
1353
1201
|
constructor(message: string, provider?: string);
|
|
1354
1202
|
}
|
|
1355
1203
|
|
|
1356
|
-
export { AuthenticationError, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse, type
|
|
1204
|
+
export { AuthenticationError, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse, type CrawlError, type CrawlErrorsResponse, CrawlGateClient, type CrawlGateClientOptions, CrawlGateError, type CrawlJob, type CrawlOptions, type CrawlResponse, type CrawlStatus, type Document, type DocumentMetadata, type Engine, type ExtractOptions, type ExtractRequestOptions, type ExtractResponse, type ExtractResult, type ExtractStatus, ExtractionError, type FormatType, JobTimeoutError, type JsonSchema, type LLMProvider, type MapOptions, type MapResponse, type PaginationConfig, RateLimitError, type ScrapeOptions, type ScrapeResponse, type SearchOptions, type SearchResponse, type SearchResult, ServiceUnavailableError, ValidationError, type WebhookConfig, CrawlGateClient as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,18 +2,11 @@ import { ZodTypeAny } from 'zod';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Scraping engine selection
|
|
5
|
-
* - `static`:
|
|
6
|
-
* - `dynamic`:
|
|
7
|
-
* - `smart`: Auto-selects
|
|
5
|
+
* - `static`: Fast HTTP-based scraping (no JavaScript rendering)
|
|
6
|
+
* - `dynamic`: Full browser scraping with JavaScript support
|
|
7
|
+
* - `smart`: Auto-selects the best engine based on the target page
|
|
8
8
|
*/
|
|
9
9
|
type Engine = "static" | "dynamic" | "smart";
|
|
10
|
-
/**
|
|
11
|
-
* Proxy options
|
|
12
|
-
* - `iproyal`: IPRoyal residential proxy
|
|
13
|
-
* - `tor`: Tor network proxy
|
|
14
|
-
* - `stealth`: Stealth mode with residential proxy (dynamic engine only)
|
|
15
|
-
*/
|
|
16
|
-
type ProxyOption = "iproyal" | "tor" | "stealth" | string;
|
|
17
10
|
/**
|
|
18
11
|
* Output format types
|
|
19
12
|
*/
|
|
@@ -125,10 +118,6 @@ interface ScrapeOptions {
|
|
|
125
118
|
* Request timeout in milliseconds
|
|
126
119
|
*/
|
|
127
120
|
timeout?: number;
|
|
128
|
-
/**
|
|
129
|
-
* Proxy configuration
|
|
130
|
-
*/
|
|
131
|
-
proxy?: ProxyOption;
|
|
132
121
|
/**
|
|
133
122
|
* LLM extraction configuration
|
|
134
123
|
*/
|
|
@@ -250,10 +239,6 @@ interface CrawlOptions {
|
|
|
250
239
|
* HTML tags to exclude
|
|
251
240
|
*/
|
|
252
241
|
excludeTags?: string[];
|
|
253
|
-
/**
|
|
254
|
-
* Proxy configuration
|
|
255
|
-
*/
|
|
256
|
-
proxy?: ProxyOption;
|
|
257
242
|
/**
|
|
258
243
|
* Project ID for usage tracking
|
|
259
244
|
*/
|
|
@@ -333,10 +318,6 @@ interface MapOptions {
|
|
|
333
318
|
* Scraping engine to use
|
|
334
319
|
*/
|
|
335
320
|
engine?: Engine;
|
|
336
|
-
/**
|
|
337
|
-
* Proxy configuration
|
|
338
|
-
*/
|
|
339
|
-
proxy?: ProxyOption;
|
|
340
321
|
/**
|
|
341
322
|
* Project ID for usage tracking
|
|
342
323
|
*/
|
|
@@ -714,90 +695,6 @@ interface ExtractResponse {
|
|
|
714
695
|
*/
|
|
715
696
|
creditsUsed?: number;
|
|
716
697
|
}
|
|
717
|
-
/**
|
|
718
|
-
* Concurrency usage information
|
|
719
|
-
*/
|
|
720
|
-
interface ConcurrencyInfo {
|
|
721
|
-
/**
|
|
722
|
-
* Current active requests
|
|
723
|
-
*/
|
|
724
|
-
concurrency: number;
|
|
725
|
-
/**
|
|
726
|
-
* Maximum allowed concurrent requests
|
|
727
|
-
*/
|
|
728
|
-
maxConcurrency: number;
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* Credit usage information
|
|
732
|
-
*/
|
|
733
|
-
interface CreditUsage {
|
|
734
|
-
/**
|
|
735
|
-
* Remaining credits
|
|
736
|
-
*/
|
|
737
|
-
remainingCredits: number;
|
|
738
|
-
/**
|
|
739
|
-
* Total plan credits
|
|
740
|
-
*/
|
|
741
|
-
planCredits?: number;
|
|
742
|
-
/**
|
|
743
|
-
* Billing period start date
|
|
744
|
-
*/
|
|
745
|
-
billingPeriodStart?: string | null;
|
|
746
|
-
/**
|
|
747
|
-
* Billing period end date
|
|
748
|
-
*/
|
|
749
|
-
billingPeriodEnd?: string | null;
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Token usage information
|
|
753
|
-
*/
|
|
754
|
-
interface TokenUsage {
|
|
755
|
-
/**
|
|
756
|
-
* Remaining tokens
|
|
757
|
-
*/
|
|
758
|
-
remainingTokens: number;
|
|
759
|
-
/**
|
|
760
|
-
* Total plan tokens
|
|
761
|
-
*/
|
|
762
|
-
planTokens?: number;
|
|
763
|
-
/**
|
|
764
|
-
* Billing period start date
|
|
765
|
-
*/
|
|
766
|
-
billingPeriodStart?: string | null;
|
|
767
|
-
/**
|
|
768
|
-
* Billing period end date
|
|
769
|
-
*/
|
|
770
|
-
billingPeriodEnd?: string | null;
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Queue status information
|
|
774
|
-
*/
|
|
775
|
-
interface QueueStatus {
|
|
776
|
-
/**
|
|
777
|
-
* Whether the request was successful
|
|
778
|
-
*/
|
|
779
|
-
success: boolean;
|
|
780
|
-
/**
|
|
781
|
-
* Total jobs in queue
|
|
782
|
-
*/
|
|
783
|
-
jobsInQueue: number;
|
|
784
|
-
/**
|
|
785
|
-
* Active jobs currently processing
|
|
786
|
-
*/
|
|
787
|
-
activeJobsInQueue: number;
|
|
788
|
-
/**
|
|
789
|
-
* Jobs waiting to be processed
|
|
790
|
-
*/
|
|
791
|
-
waitingJobsInQueue: number;
|
|
792
|
-
/**
|
|
793
|
-
* Maximum concurrency
|
|
794
|
-
*/
|
|
795
|
-
maxConcurrency: number;
|
|
796
|
-
/**
|
|
797
|
-
* Timestamp of most recent successful job
|
|
798
|
-
*/
|
|
799
|
-
mostRecentSuccess: string | null;
|
|
800
|
-
}
|
|
801
698
|
/**
|
|
802
699
|
* Crawl error information
|
|
803
700
|
*/
|
|
@@ -1231,55 +1128,6 @@ declare class CrawlGateClient {
|
|
|
1231
1128
|
* ```
|
|
1232
1129
|
*/
|
|
1233
1130
|
search(query: string, options?: SearchOptions): Promise<SearchResponse>;
|
|
1234
|
-
/**
|
|
1235
|
-
* Get current concurrency usage
|
|
1236
|
-
*
|
|
1237
|
-
* @returns Current and max concurrency
|
|
1238
|
-
*
|
|
1239
|
-
* @example
|
|
1240
|
-
* ```typescript
|
|
1241
|
-
* const { concurrency, maxConcurrency } = await client.getConcurrency();
|
|
1242
|
-
* console.log(`Using ${concurrency}/${maxConcurrency} concurrent requests`);
|
|
1243
|
-
* ```
|
|
1244
|
-
*/
|
|
1245
|
-
getConcurrency(): Promise<ConcurrencyInfo>;
|
|
1246
|
-
/**
|
|
1247
|
-
* Get current credit usage
|
|
1248
|
-
*
|
|
1249
|
-
* @returns Credit usage information
|
|
1250
|
-
*
|
|
1251
|
-
* @example
|
|
1252
|
-
* ```typescript
|
|
1253
|
-
* const credits = await client.getCreditUsage();
|
|
1254
|
-
* console.log(`Remaining credits: ${credits.remainingCredits}`);
|
|
1255
|
-
* ```
|
|
1256
|
-
*/
|
|
1257
|
-
getCreditUsage(): Promise<CreditUsage>;
|
|
1258
|
-
/**
|
|
1259
|
-
* Get current token usage (for LLM extraction)
|
|
1260
|
-
*
|
|
1261
|
-
* @returns Token usage information
|
|
1262
|
-
*
|
|
1263
|
-
* @example
|
|
1264
|
-
* ```typescript
|
|
1265
|
-
* const tokens = await client.getTokenUsage();
|
|
1266
|
-
* console.log(`Remaining tokens: ${tokens.remainingTokens}`);
|
|
1267
|
-
* ```
|
|
1268
|
-
*/
|
|
1269
|
-
getTokenUsage(): Promise<TokenUsage>;
|
|
1270
|
-
/**
|
|
1271
|
-
* Get queue status information
|
|
1272
|
-
*
|
|
1273
|
-
* @returns Queue status metrics
|
|
1274
|
-
*
|
|
1275
|
-
* @example
|
|
1276
|
-
* ```typescript
|
|
1277
|
-
* const queue = await client.getQueueStatus();
|
|
1278
|
-
* console.log(`Jobs in queue: ${queue.jobsInQueue}`);
|
|
1279
|
-
* console.log(`Active: ${queue.activeJobsInQueue}, Waiting: ${queue.waitingJobsInQueue}`);
|
|
1280
|
-
* ```
|
|
1281
|
-
*/
|
|
1282
|
-
getQueueStatus(): Promise<QueueStatus>;
|
|
1283
1131
|
}
|
|
1284
1132
|
|
|
1285
1133
|
/**
|
|
@@ -1353,4 +1201,4 @@ declare class ExtractionError extends CrawlGateError {
|
|
|
1353
1201
|
constructor(message: string, provider?: string);
|
|
1354
1202
|
}
|
|
1355
1203
|
|
|
1356
|
-
export { AuthenticationError, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse, type
|
|
1204
|
+
export { AuthenticationError, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse, type CrawlError, type CrawlErrorsResponse, CrawlGateClient, type CrawlGateClientOptions, CrawlGateError, type CrawlJob, type CrawlOptions, type CrawlResponse, type CrawlStatus, type Document, type DocumentMetadata, type Engine, type ExtractOptions, type ExtractRequestOptions, type ExtractResponse, type ExtractResult, type ExtractStatus, ExtractionError, type FormatType, JobTimeoutError, type JsonSchema, type LLMProvider, type MapOptions, type MapResponse, type PaginationConfig, RateLimitError, type ScrapeOptions, type ScrapeResponse, type SearchOptions, type SearchResponse, type SearchResult, ServiceUnavailableError, ValidationError, type WebhookConfig, CrawlGateClient as default };
|
package/dist/index.js
CHANGED
|
@@ -248,9 +248,6 @@ function buildScrapeBody(url, options) {
|
|
|
248
248
|
if (options?.timeout !== void 0) {
|
|
249
249
|
body.timeout = options.timeout;
|
|
250
250
|
}
|
|
251
|
-
if (options?.proxy) {
|
|
252
|
-
body.proxy = options.proxy;
|
|
253
|
-
}
|
|
254
251
|
if (options?.projectId) {
|
|
255
252
|
body.project_id = options.projectId;
|
|
256
253
|
}
|
|
@@ -307,9 +304,6 @@ function buildCrawlBody(url, options) {
|
|
|
307
304
|
if (options?.excludeTags) {
|
|
308
305
|
body.excludeTags = options.excludeTags;
|
|
309
306
|
}
|
|
310
|
-
if (options?.proxy) {
|
|
311
|
-
body.proxy = options.proxy;
|
|
312
|
-
}
|
|
313
307
|
if (options?.projectId) {
|
|
314
308
|
body.project_id = options.projectId;
|
|
315
309
|
}
|
|
@@ -406,9 +400,6 @@ function buildMapBody(url, options) {
|
|
|
406
400
|
if (options?.engine) {
|
|
407
401
|
body.engine = options.engine;
|
|
408
402
|
}
|
|
409
|
-
if (options?.proxy) {
|
|
410
|
-
body.proxy = options.proxy;
|
|
411
|
-
}
|
|
412
403
|
if (options?.projectId) {
|
|
413
404
|
body.project_id = options.projectId;
|
|
414
405
|
}
|
|
@@ -509,7 +500,6 @@ function buildBatchBody(urls, options) {
|
|
|
509
500
|
if (scrapeOpts.excludeTags) body.excludeTags = scrapeOpts.excludeTags;
|
|
510
501
|
if (scrapeOpts.waitFor !== void 0) body.waitFor = scrapeOpts.waitFor;
|
|
511
502
|
if (scrapeOpts.timeout !== void 0) body.timeout = scrapeOpts.timeout;
|
|
512
|
-
if (scrapeOpts.proxy) body.proxy = scrapeOpts.proxy;
|
|
513
503
|
}
|
|
514
504
|
if (options?.webhook != null) {
|
|
515
505
|
body.webhook = options.webhook;
|
|
@@ -745,44 +735,6 @@ async function extract(http, options) {
|
|
|
745
735
|
return waitForExtractCompletion(http, started.id, pollInterval, timeout);
|
|
746
736
|
}
|
|
747
737
|
|
|
748
|
-
// src/methods/usage.ts
|
|
749
|
-
async function getConcurrency(http) {
|
|
750
|
-
const response = await http.get("/v1/concurrency");
|
|
751
|
-
return {
|
|
752
|
-
concurrency: response.data.concurrency ?? 0,
|
|
753
|
-
maxConcurrency: response.data.maxConcurrency ?? 0
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
async function getCreditUsage(http) {
|
|
757
|
-
const response = await http.get("/v1/credits");
|
|
758
|
-
return {
|
|
759
|
-
remainingCredits: response.data.remainingCredits ?? 0,
|
|
760
|
-
planCredits: response.data.planCredits,
|
|
761
|
-
billingPeriodStart: response.data.billingPeriodStart,
|
|
762
|
-
billingPeriodEnd: response.data.billingPeriodEnd
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
async function getTokenUsage(http) {
|
|
766
|
-
const response = await http.get("/v1/tokens");
|
|
767
|
-
return {
|
|
768
|
-
remainingTokens: response.data.remainingTokens ?? 0,
|
|
769
|
-
planTokens: response.data.planTokens,
|
|
770
|
-
billingPeriodStart: response.data.billingPeriodStart,
|
|
771
|
-
billingPeriodEnd: response.data.billingPeriodEnd
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
async function getQueueStatus(http) {
|
|
775
|
-
const response = await http.get("/v1/queue");
|
|
776
|
-
return {
|
|
777
|
-
success: response.data.success ?? true,
|
|
778
|
-
jobsInQueue: response.data.jobsInQueue ?? 0,
|
|
779
|
-
activeJobsInQueue: response.data.activeJobsInQueue ?? 0,
|
|
780
|
-
waitingJobsInQueue: response.data.waitingJobsInQueue ?? 0,
|
|
781
|
-
maxConcurrency: response.data.maxConcurrency ?? 0,
|
|
782
|
-
mostRecentSuccess: response.data.mostRecentSuccess
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
|
|
786
738
|
// src/client.ts
|
|
787
739
|
var CrawlGateClient = class {
|
|
788
740
|
http;
|
|
@@ -1181,66 +1133,6 @@ var CrawlGateClient = class {
|
|
|
1181
1133
|
async search(query, options) {
|
|
1182
1134
|
return search(this.http, query, options);
|
|
1183
1135
|
}
|
|
1184
|
-
// ==========================================================================
|
|
1185
|
-
// Usage & Monitoring Methods
|
|
1186
|
-
// ==========================================================================
|
|
1187
|
-
/**
|
|
1188
|
-
* Get current concurrency usage
|
|
1189
|
-
*
|
|
1190
|
-
* @returns Current and max concurrency
|
|
1191
|
-
*
|
|
1192
|
-
* @example
|
|
1193
|
-
* ```typescript
|
|
1194
|
-
* const { concurrency, maxConcurrency } = await client.getConcurrency();
|
|
1195
|
-
* console.log(`Using ${concurrency}/${maxConcurrency} concurrent requests`);
|
|
1196
|
-
* ```
|
|
1197
|
-
*/
|
|
1198
|
-
async getConcurrency() {
|
|
1199
|
-
return getConcurrency(this.http);
|
|
1200
|
-
}
|
|
1201
|
-
/**
|
|
1202
|
-
* Get current credit usage
|
|
1203
|
-
*
|
|
1204
|
-
* @returns Credit usage information
|
|
1205
|
-
*
|
|
1206
|
-
* @example
|
|
1207
|
-
* ```typescript
|
|
1208
|
-
* const credits = await client.getCreditUsage();
|
|
1209
|
-
* console.log(`Remaining credits: ${credits.remainingCredits}`);
|
|
1210
|
-
* ```
|
|
1211
|
-
*/
|
|
1212
|
-
async getCreditUsage() {
|
|
1213
|
-
return getCreditUsage(this.http);
|
|
1214
|
-
}
|
|
1215
|
-
/**
|
|
1216
|
-
* Get current token usage (for LLM extraction)
|
|
1217
|
-
*
|
|
1218
|
-
* @returns Token usage information
|
|
1219
|
-
*
|
|
1220
|
-
* @example
|
|
1221
|
-
* ```typescript
|
|
1222
|
-
* const tokens = await client.getTokenUsage();
|
|
1223
|
-
* console.log(`Remaining tokens: ${tokens.remainingTokens}`);
|
|
1224
|
-
* ```
|
|
1225
|
-
*/
|
|
1226
|
-
async getTokenUsage() {
|
|
1227
|
-
return getTokenUsage(this.http);
|
|
1228
|
-
}
|
|
1229
|
-
/**
|
|
1230
|
-
* Get queue status information
|
|
1231
|
-
*
|
|
1232
|
-
* @returns Queue status metrics
|
|
1233
|
-
*
|
|
1234
|
-
* @example
|
|
1235
|
-
* ```typescript
|
|
1236
|
-
* const queue = await client.getQueueStatus();
|
|
1237
|
-
* console.log(`Jobs in queue: ${queue.jobsInQueue}`);
|
|
1238
|
-
* console.log(`Active: ${queue.activeJobsInQueue}, Waiting: ${queue.waitingJobsInQueue}`);
|
|
1239
|
-
* ```
|
|
1240
|
-
*/
|
|
1241
|
-
async getQueueStatus() {
|
|
1242
|
-
return getQueueStatus(this.http);
|
|
1243
|
-
}
|
|
1244
1136
|
};
|
|
1245
1137
|
export {
|
|
1246
1138
|
AuthenticationError,
|