@crawlgate/sdk 1.0.0 → 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/dist/index.d.cts CHANGED
@@ -2,18 +2,11 @@ import { ZodTypeAny } from 'zod';
2
2
 
3
3
  /**
4
4
  * Scraping engine selection
5
- * - `static`: Axios + Cheerio (fast, no JS rendering)
6
- * - `dynamic`: Playwright headless browser (full JS support)
7
- * - `smart`: Auto-selects static first, falls back to dynamic if needed
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 ConcurrencyInfo, type CrawlError, type CrawlErrorsResponse, CrawlGateClient, type CrawlGateClientOptions, CrawlGateError, type CrawlJob, type CrawlOptions, type CrawlResponse, type CrawlStatus, type CreditUsage, 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, type ProxyOption, type QueueStatus, RateLimitError, type ScrapeOptions, type ScrapeResponse, type SearchOptions, type SearchResponse, type SearchResult, ServiceUnavailableError, type TokenUsage, ValidationError, type WebhookConfig, CrawlGateClient as default };
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`: Axios + Cheerio (fast, no JS rendering)
6
- * - `dynamic`: Playwright headless browser (full JS support)
7
- * - `smart`: Auto-selects static first, falls back to dynamic if needed
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 ConcurrencyInfo, type CrawlError, type CrawlErrorsResponse, CrawlGateClient, type CrawlGateClientOptions, CrawlGateError, type CrawlJob, type CrawlOptions, type CrawlResponse, type CrawlStatus, type CreditUsage, 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, type ProxyOption, type QueueStatus, RateLimitError, type ScrapeOptions, type ScrapeResponse, type SearchOptions, type SearchResponse, type SearchResult, ServiceUnavailableError, type TokenUsage, ValidationError, type WebhookConfig, CrawlGateClient as default };
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
  }
@@ -272,20 +269,21 @@ function buildScrapeBody(url, options) {
272
269
  async function scrape(http, url, options) {
273
270
  const body = buildScrapeBody(url, options);
274
271
  const response = await http.post("/v1/scrape", body);
275
- if (!response.data.success) {
272
+ const data = response.data;
273
+ if (data.success === false) {
276
274
  throw new CrawlGateError(
277
- response.data.error || "Scrape failed",
275
+ data.error || "Scrape failed",
278
276
  void 0,
279
- "SCRAPE_ERROR"
277
+ data.code || "SCRAPE_ERROR"
280
278
  );
281
279
  }
282
- if (!response.data.data) {
283
- throw new CrawlGateError("No data returned from scrape", void 0, "NO_DATA");
280
+ if (data.success === true && data.data) {
281
+ return data.data;
284
282
  }
285
- const document = {
286
- ...response.data.data
287
- };
288
- return document;
283
+ if (data.url || data.markdown || data.html) {
284
+ return data;
285
+ }
286
+ throw new CrawlGateError("No data returned from scrape", void 0, "NO_DATA");
289
287
  }
290
288
 
291
289
  // src/methods/crawl.ts
@@ -306,9 +304,6 @@ function buildCrawlBody(url, options) {
306
304
  if (options?.excludeTags) {
307
305
  body.excludeTags = options.excludeTags;
308
306
  }
309
- if (options?.proxy) {
310
- body.proxy = options.proxy;
311
- }
312
307
  if (options?.projectId) {
313
308
  body.project_id = options.projectId;
314
309
  }
@@ -405,9 +400,6 @@ function buildMapBody(url, options) {
405
400
  if (options?.engine) {
406
401
  body.engine = options.engine;
407
402
  }
408
- if (options?.proxy) {
409
- body.proxy = options.proxy;
410
- }
411
403
  if (options?.projectId) {
412
404
  body.project_id = options.projectId;
413
405
  }
@@ -508,7 +500,6 @@ function buildBatchBody(urls, options) {
508
500
  if (scrapeOpts.excludeTags) body.excludeTags = scrapeOpts.excludeTags;
509
501
  if (scrapeOpts.waitFor !== void 0) body.waitFor = scrapeOpts.waitFor;
510
502
  if (scrapeOpts.timeout !== void 0) body.timeout = scrapeOpts.timeout;
511
- if (scrapeOpts.proxy) body.proxy = scrapeOpts.proxy;
512
503
  }
513
504
  if (options?.webhook != null) {
514
505
  body.webhook = options.webhook;
@@ -744,44 +735,6 @@ async function extract(http, options) {
744
735
  return waitForExtractCompletion(http, started.id, pollInterval, timeout);
745
736
  }
746
737
 
747
- // src/methods/usage.ts
748
- async function getConcurrency(http) {
749
- const response = await http.get("/v1/concurrency");
750
- return {
751
- concurrency: response.data.concurrency ?? 0,
752
- maxConcurrency: response.data.maxConcurrency ?? 0
753
- };
754
- }
755
- async function getCreditUsage(http) {
756
- const response = await http.get("/v1/credits");
757
- return {
758
- remainingCredits: response.data.remainingCredits ?? 0,
759
- planCredits: response.data.planCredits,
760
- billingPeriodStart: response.data.billingPeriodStart,
761
- billingPeriodEnd: response.data.billingPeriodEnd
762
- };
763
- }
764
- async function getTokenUsage(http) {
765
- const response = await http.get("/v1/tokens");
766
- return {
767
- remainingTokens: response.data.remainingTokens ?? 0,
768
- planTokens: response.data.planTokens,
769
- billingPeriodStart: response.data.billingPeriodStart,
770
- billingPeriodEnd: response.data.billingPeriodEnd
771
- };
772
- }
773
- async function getQueueStatus(http) {
774
- const response = await http.get("/v1/queue");
775
- return {
776
- success: response.data.success ?? true,
777
- jobsInQueue: response.data.jobsInQueue ?? 0,
778
- activeJobsInQueue: response.data.activeJobsInQueue ?? 0,
779
- waitingJobsInQueue: response.data.waitingJobsInQueue ?? 0,
780
- maxConcurrency: response.data.maxConcurrency ?? 0,
781
- mostRecentSuccess: response.data.mostRecentSuccess
782
- };
783
- }
784
-
785
738
  // src/client.ts
786
739
  var CrawlGateClient = class {
787
740
  http;
@@ -1180,66 +1133,6 @@ var CrawlGateClient = class {
1180
1133
  async search(query, options) {
1181
1134
  return search(this.http, query, options);
1182
1135
  }
1183
- // ==========================================================================
1184
- // Usage & Monitoring Methods
1185
- // ==========================================================================
1186
- /**
1187
- * Get current concurrency usage
1188
- *
1189
- * @returns Current and max concurrency
1190
- *
1191
- * @example
1192
- * ```typescript
1193
- * const { concurrency, maxConcurrency } = await client.getConcurrency();
1194
- * console.log(`Using ${concurrency}/${maxConcurrency} concurrent requests`);
1195
- * ```
1196
- */
1197
- async getConcurrency() {
1198
- return getConcurrency(this.http);
1199
- }
1200
- /**
1201
- * Get current credit usage
1202
- *
1203
- * @returns Credit usage information
1204
- *
1205
- * @example
1206
- * ```typescript
1207
- * const credits = await client.getCreditUsage();
1208
- * console.log(`Remaining credits: ${credits.remainingCredits}`);
1209
- * ```
1210
- */
1211
- async getCreditUsage() {
1212
- return getCreditUsage(this.http);
1213
- }
1214
- /**
1215
- * Get current token usage (for LLM extraction)
1216
- *
1217
- * @returns Token usage information
1218
- *
1219
- * @example
1220
- * ```typescript
1221
- * const tokens = await client.getTokenUsage();
1222
- * console.log(`Remaining tokens: ${tokens.remainingTokens}`);
1223
- * ```
1224
- */
1225
- async getTokenUsage() {
1226
- return getTokenUsage(this.http);
1227
- }
1228
- /**
1229
- * Get queue status information
1230
- *
1231
- * @returns Queue status metrics
1232
- *
1233
- * @example
1234
- * ```typescript
1235
- * const queue = await client.getQueueStatus();
1236
- * console.log(`Jobs in queue: ${queue.jobsInQueue}`);
1237
- * console.log(`Active: ${queue.activeJobsInQueue}, Waiting: ${queue.waitingJobsInQueue}`);
1238
- * ```
1239
- */
1240
- async getQueueStatus() {
1241
- return getQueueStatus(this.http);
1242
- }
1243
1136
  };
1244
1137
  export {
1245
1138
  AuthenticationError,