@dealcrawl/sdk 2.1.3 → 2.3.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.d.ts CHANGED
@@ -137,6 +137,15 @@ interface ScrapeResult {
137
137
  signals: Signal[];
138
138
  aiExtraction?: AIExtraction;
139
139
  dealExtraction?: ExtractedDeal;
140
+ /** Multiple deals extracted from list pages */
141
+ multipleDeals?: ExtractedDeal[];
142
+ /** Metadata for multi-deal extraction */
143
+ multiDealMetadata?: {
144
+ totalFound: number;
145
+ category?: string;
146
+ hasNextPage?: boolean;
147
+ extractionConfidence: number;
148
+ };
140
149
  dealScore?: DealScoreSummary;
141
150
  screenshot?: string;
142
151
  screenshotMetadata?: ScreenshotResult;
@@ -285,6 +294,120 @@ interface PaginationInfo {
285
294
  /** Scrape job creation response */
286
295
  interface ScrapeJobResponse extends JobResponse {
287
296
  }
297
+ /** Individual batch scrape result item */
298
+ interface BatchScrapeResultItem {
299
+ /** URL that was scraped */
300
+ url: string;
301
+ /** Reference ID if provided in request */
302
+ ref?: string;
303
+ /** Job ID created for this URL */
304
+ jobId: string;
305
+ /** Status of job creation */
306
+ status: "queued" | "failed";
307
+ /** Error message if job creation failed */
308
+ error?: string;
309
+ }
310
+ /** Batch scrape response */
311
+ interface BatchScrapeResponse {
312
+ /** Batch ID for tracking */
313
+ batchId: string;
314
+ /** Total number of URLs in batch */
315
+ total: number;
316
+ /** Number of jobs successfully queued */
317
+ queued: number;
318
+ /** Number of jobs that failed to queue */
319
+ failed: number;
320
+ /** Individual results per URL */
321
+ results: BatchScrapeResultItem[];
322
+ /** Timestamp when batch was created */
323
+ createdAt: string;
324
+ }
325
+ /** Batch status response */
326
+ interface BatchStatusResponse {
327
+ /** Batch ID */
328
+ batchId: string;
329
+ /** Total URLs in batch */
330
+ total: number;
331
+ /** Number queued */
332
+ queued: number;
333
+ /** Number failed */
334
+ failed: number;
335
+ /** Webhook URL if configured */
336
+ webhookUrl?: string;
337
+ /** Priority level */
338
+ priority: number;
339
+ /** Creation timestamp */
340
+ createdAt: string;
341
+ /** Individual job statuses */
342
+ jobs: Array<{
343
+ id: string;
344
+ status: JobStatus;
345
+ result?: unknown;
346
+ error?: string;
347
+ }>;
348
+ }
349
+ /** Individual search result */
350
+ interface SearchResultItem {
351
+ /** Result title */
352
+ title: string;
353
+ /** Result URL */
354
+ url: string;
355
+ /** Result description/snippet */
356
+ description: string;
357
+ /** Deal score if useDealScoring enabled (0-100) */
358
+ dealScore?: number;
359
+ /** Display URL */
360
+ displayUrl?: string;
361
+ }
362
+ /** Search job response data */
363
+ interface SearchData {
364
+ /** Search results */
365
+ results: SearchResultItem[];
366
+ /** Total results found */
367
+ total: number;
368
+ /** Original query */
369
+ query: string;
370
+ /** AI-optimized query (if useAiOptimization=true) */
371
+ aiOptimizedQuery?: string;
372
+ /** Whether results were from cache */
373
+ cached: boolean;
374
+ /** Search duration in ms */
375
+ durationMs: number;
376
+ /** Job IDs for auto-scraped URLs */
377
+ scrapedJobIds?: string[];
378
+ }
379
+ /** Search job response */
380
+ interface SearchJobResponse {
381
+ /** Success status */
382
+ success: boolean;
383
+ /** Search results data */
384
+ data: SearchData;
385
+ /** Response metadata */
386
+ meta: {
387
+ /** Search provider used */
388
+ provider: "serpapi" | "google";
389
+ /** Number of scrape jobs created */
390
+ scrapeJobsCreated: number;
391
+ };
392
+ }
393
+ /** Search API status response */
394
+ interface SearchStatusResponse {
395
+ /** Whether search is available */
396
+ available: boolean;
397
+ /** Search provider */
398
+ provider: "serpapi" | "google" | "none";
399
+ /** Available features */
400
+ features: {
401
+ /** AI query optimization available */
402
+ aiOptimization: boolean;
403
+ /** Redis caching enabled */
404
+ caching: boolean;
405
+ /** Deal scoring enabled */
406
+ dealScoring: boolean;
407
+ };
408
+ /** Cache TTL */
409
+ cacheTtl: string;
410
+ }
288
411
  /** Crawl job creation response */
289
412
  interface CrawlJobResponse extends JobResponse {
290
413
  }
@@ -514,19 +637,29 @@ interface TestWebhookResponse {
514
637
  interface ApiKeyInfo {
515
638
  id: string;
516
639
  name: string;
517
- prefix: string;
640
+ /** Key prefix (e.g., "sk_dev_abc123") */
641
+ keyPrefix: string;
518
642
  scopes: string[];
519
643
  isActive: boolean;
520
- expiresAt?: string;
521
- lastUsedAt?: string;
644
+ expiresAt: string | null;
645
+ lastUsedAt: string | null;
522
646
  createdAt: string;
647
+ revokedAt: string | null;
648
+ revokedReason: string | null;
523
649
  usageCount: number;
524
- ipAllowlist?: string[];
650
+ ipAllowlist: string[] | null;
525
651
  }
526
652
  /** Created API key (includes secret - only shown once) */
527
- interface CreatedApiKey extends ApiKeyInfo {
653
+ interface CreatedApiKey {
654
+ id: string;
528
655
  /** The full API key - only returned on creation, never stored */
529
- key: string;
656
+ rawKey: string;
657
+ /** Key prefix for identification */
658
+ keyPrefix: string;
659
+ name: string;
660
+ scopes: string[];
661
+ expiresAt: string | null;
662
+ createdAt: string;
530
663
  }
531
664
  /** List keys response */
532
665
  interface ListKeysResponse {
@@ -559,7 +692,9 @@ interface KeyStatsResponse {
559
692
  totalRequests: number;
560
693
  successfulRequests: number;
561
694
  failedRequests: number;
695
+ avgDurationMs: number;
562
696
  byEndpoint: Record<string, number>;
697
+ requestsByDay: Record<string, number>;
563
698
  };
564
699
  }
565
700
  /** Usage stats */
@@ -641,6 +776,69 @@ interface UpdatePreferencesResponse {
641
776
  success: boolean;
642
777
  preferences: ClientPreferences;
643
778
  }
779
+ /** Agent job creation response */
780
+ interface AgentJobResponse extends JobResponse {
781
+ /** Estimated completion time based on maxSteps */
782
+ estimatedTime?: string;
783
+ }
784
+ /** Agent step in execution trace */
785
+ interface AgentStepResponse {
786
+ /** Step number (1-indexed) */
787
+ step: number;
788
+ /** Agent's reasoning before action */
789
+ thought: string;
790
+ /** Type of action taken */
791
+ actionType: string;
792
+ /** Action details */
793
+ action: Record<string, unknown>;
794
+ /** Whether the action succeeded */
795
+ result: "success" | "failed" | "skipped";
796
+ /** Duration of this step in ms */
797
+ durationMs: number;
798
+ /** Error message if failed */
799
+ error?: string;
800
+ /** Screenshot URL if captured */
801
+ screenshotUrl?: string;
802
+ /** Current URL after action */
803
+ currentUrl?: string;
804
+ }
805
+ /** Agent completion reason */
806
+ type AgentCompletionReason = "goal_achieved" | "max_steps_reached" | "stuck" | "error" | "cancelled";
807
+ /** Agent result (from completed job) */
808
+ interface AgentResultResponse {
809
+ /** Extracted/collected data (matches provided schema if given) */
810
+ data: Record<string, unknown>;
811
+ /** Steps executed by the agent */
812
+ steps: AgentStepResponse[];
813
+ /** Final URL after all navigation */
814
+ finalUrl: string;
815
+ /** Credits/tokens used */
816
+ creditsUsed: number;
817
+ /** Total execution time in ms */
818
+ totalDurationMs: number;
819
+ /** Screenshots captured (if takeScreenshots enabled) */
820
+ screenshots?: string[];
821
+ /** Completion reason */
822
+ completionReason: AgentCompletionReason;
823
+ /** Agent metadata */
824
+ metadata: {
825
+ model: string;
826
+ stepsExecuted: number;
827
+ tokensUsed?: number;
828
+ timestamp: string;
829
+ };
830
+ }
831
+ /** Agent status response (extended from JobStatusResponse) */
832
+ interface AgentStatusResponse extends JobStatusResponse {
833
+ /** Partial result with steps so far */
834
+ partialResult?: {
835
+ steps: AgentStepResponse[];
836
+ currentUrl?: string;
837
+ extractedData?: Record<string, unknown>;
838
+ };
839
+ /** Final result when completed */
840
+ result?: AgentResultResponse;
841
+ }
644
842
 
645
843
  /**
646
844
  * Polling Utilities
@@ -727,6 +925,10 @@ interface ScrapeOptions {
727
925
  extractWithAI?: boolean;
728
926
  /** Extract deal-specific information (product, price, discount, urgency) */
729
927
  extractDeal?: boolean;
928
+ /** Extract MULTIPLE deals from list/category pages */
929
+ extractMultipleDeals?: boolean;
930
+ /** Maximum deals to extract from list pages (default: 20, max: 50) */
931
+ maxDeals?: number;
730
932
  /** Use advanced AI model (GPT-4o) for complex pages - higher cost, better quality */
731
933
  useAdvancedModel?: boolean;
732
934
  /** Minimum deal score threshold (0-100) - only returns deals above this score */
@@ -744,6 +946,118 @@ interface ScrapeOptions {
744
946
  /** Timeout in milliseconds (default: 30000, max: 120000) */
745
947
  timeout?: number;
746
948
  }
949
+ /** Individual URL item for batch scraping */
950
+ interface BatchScrapeItem {
951
+ /** URL to scrape */
952
+ url: string;
953
+ /** Optional reference ID for tracking */
954
+ ref?: string;
955
+ /** Override detectSignals for this URL */
956
+ detectSignals?: boolean;
957
+ /** Override extractWithAI for this URL */
958
+ extractWithAI?: boolean;
959
+ /** Override extractDeal for this URL */
960
+ extractDeal?: boolean;
961
+ /** Override screenshot for this URL */
962
+ screenshot?: ScreenshotOptions;
963
+ /** Override headers for this URL */
964
+ headers?: Record<string, string>;
965
+ /** Override timeout for this URL */
966
+ timeout?: number;
967
+ }
968
+ /** Default options applied to all URLs in a batch */
969
+ interface BatchScrapeDefaults {
970
+ /** Don't save scrape results (zero data retention) */
971
+ noStore?: boolean;
972
+ /** Detect signals like prices, discounts, urgency */
973
+ detectSignals?: boolean;
974
+ /** Extract content using AI */
975
+ extractWithAI?: boolean;
976
+ /** Extract deal-specific information */
977
+ extractDeal?: boolean;
978
+ /** Extract multiple deals from list pages */
979
+ extractMultipleDeals?: boolean;
980
+ /** Maximum deals to extract (default: 20, max: 50) */
981
+ maxDeals?: number;
982
+ /** Use advanced AI model (higher cost, better quality) */
983
+ useAdvancedModel?: boolean;
984
+ /** Minimum deal score threshold (0-100) */
985
+ minDealScore?: number;
986
+ /** Screenshot configuration */
987
+ screenshot?: ScreenshotOptions;
988
+ /** HTML tags to exclude */
989
+ excludeTags?: string[];
990
+ /** CSS selectors to exclude */
991
+ excludeSelectors?: string[];
992
+ /** Only extract main content area */
993
+ onlyMainContent?: boolean;
994
+ /** Custom headers for requests */
995
+ headers?: Record<string, string>;
996
+ /** Timeout in milliseconds */
997
+ timeout?: number;
998
+ }
999
+ /** Options for batch scraping multiple URLs */
1000
+ interface BatchScrapeOptions {
1001
+ /** Array of URLs to scrape (1-100) */
1002
+ urls: BatchScrapeItem[];
1003
+ /** Default options applied to all URLs */
1004
+ defaults?: BatchScrapeDefaults;
1005
+ /** Webhook URL for batch completion notification */
1006
+ webhookUrl?: string;
1007
+ /** Priority for batch jobs (1-10, higher = faster) */
1008
+ priority?: number;
1009
+ /** Delay between job submissions in ms (0-5000) */
1010
+ delay?: number;
1011
+ }
1012
+ /** AI provider for search optimization */
1013
+ type SearchAiProvider = "openai" | "anthropic";
1014
+ /** AI model for search optimization */
1015
+ type SearchAiModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4o-2024-11-20" | "o1-mini" | "o1-preview" | "claude-3-5-haiku-20241022" | "claude-3-5-sonnet-20241022" | "claude-3-5-sonnet-20240620" | "claude-3-opus-20240229";
1016
+ /** Date range filter for search */
1017
+ type SearchDateRange = "day" | "week" | "month" | "year" | "all";
1018
+ /** Search filters */
1019
+ interface SearchFilters {
1020
+ /** Country code (e.g., 'fr', 'us') */
1021
+ location?: string;
1022
+ /** Language code (e.g., 'fr', 'en') */
1023
+ language?: string;
1024
+ /** Filter by date range */
1025
+ dateRange?: SearchDateRange;
1026
+ /** Exclude PDF files from results */
1027
+ excludePdf?: boolean;
1028
+ /** Limit to specific domain */
1029
+ domain?: string;
1030
+ /** Must contain these deal keywords (OR logic) */
1031
+ dealKeywords?: string[];
1032
+ }
1033
+ /** Options for web search */
1034
+ interface SearchOptions {
1035
+ /** Search query (required) */
1036
+ query: string;
1037
+ /** Maximum number of results (1-100, default: 10) */
1038
+ maxResults?: number;
1039
+ /** Auto-scrape top results */
1040
+ autoScrape?: boolean;
1041
+ /** Number of results to auto-scrape (1-10, default: 5) */
1042
+ autoScrapeLimit?: number;
1043
+ /** Use AI to optimize the search query */
1044
+ useAiOptimization?: boolean;
1045
+ /** AI provider for query optimization */
1046
+ aiProvider?: SearchAiProvider;
1047
+ /** AI model to use */
1048
+ aiModel?: SearchAiModel;
1049
+ /** Enable deal scoring for results (0-100) */
1050
+ useDealScoring?: boolean;
1051
+ /** Skip cache and force fresh search */
1052
+ skipCache?: boolean;
1053
+ /** Search filters */
1054
+ filters?: SearchFilters;
1055
+ /** Webhook for async notifications */
1056
+ webhook?: {
1057
+ url: string;
1058
+ headers?: Record<string, string>;
1059
+ };
1060
+ }
747
1061
  /** Options for crawling a website */
748
1062
  interface CrawlOptions {
749
1063
  /** Starting URL for the crawl (required) */
@@ -946,7 +1260,15 @@ interface UpdateWebhookOptions {
946
1260
  * API key scope - Must match @dealcrawl/shared/src/types/api-key.types.ts
947
1261
  * These are the actual scopes enforced by the backend via requireScope() middleware
948
1262
  */
949
- type ApiKeyScope = "scrape" | "crawl" | "dork" | "extract" | "status" | "data:read" | "data:export" | "keys:manage" | "webhooks:manage";
1263
+ type ApiKeyScope = "scrape" | "crawl" | "dork" | "extract" | "agent" | "status" | "data:read" | "data:export" | "keys:manage" | "webhooks:manage";
1264
+ /**
1265
+ * All available scopes (for reference and validation)
1266
+ */
1267
+ declare const ALL_API_KEY_SCOPES: ApiKeyScope[];
1268
+ /**
1269
+ * Default scopes for new keys
1270
+ */
1271
+ declare const DEFAULT_API_KEY_SCOPES: ApiKeyScope[];
950
1272
  /** Options for creating an API key */
951
1273
  interface CreateApiKeyOptions {
952
1274
  /** Key name/description */
@@ -968,9 +1290,14 @@ interface ListApiKeysOptions {
968
1290
  /** Include revoked keys */
969
1291
  includeRevoked?: boolean;
970
1292
  }
1293
+ /** Options for revoking an API key */
1294
+ interface RevokeApiKeyOptions {
1295
+ /** Reason for revocation */
1296
+ reason?: string;
1297
+ }
971
1298
  /** Options for getting API key stats */
972
1299
  interface GetApiKeyStatsOptions {
973
- /** Number of days to get stats for (default: 30) */
1300
+ /** Number of days to get stats for (default: 7, max: 30) */
974
1301
  days?: number;
975
1302
  }
976
1303
  /** Product category */
@@ -986,6 +1313,111 @@ interface UpdatePreferencesOptions {
986
1313
  /** Enable webhook notifications */
987
1314
  webhookEnabled?: boolean;
988
1315
  }
1316
+ /** LLM provider for agent */
1317
+ type AgentModel = "openai" | "anthropic";
1318
+ /** Browser action types */
1319
+ type AgentActionType = "click" | "scroll" | "write" | "wait" | "press" | "screenshot" | "hover" | "select";
1320
+ /** Base action interface */
1321
+ interface BaseAgentAction {
1322
+ type: AgentActionType;
1323
+ optional?: boolean;
1324
+ retries?: number;
1325
+ delayBefore?: number;
1326
+ }
1327
+ /** Click action */
1328
+ interface ClickAction extends BaseAgentAction {
1329
+ type: "click";
1330
+ selector: string;
1331
+ waitAfter?: number;
1332
+ button?: "left" | "right" | "middle";
1333
+ clickCount?: number;
1334
+ force?: boolean;
1335
+ }
1336
+ /** Scroll action */
1337
+ interface ScrollAction extends BaseAgentAction {
1338
+ type: "scroll";
1339
+ direction: "up" | "down" | "left" | "right" | "to-element";
1340
+ selector?: string;
1341
+ amount?: number;
1342
+ smooth?: boolean;
1343
+ }
1344
+ /** Write action */
1345
+ interface WriteAction extends BaseAgentAction {
1346
+ type: "write";
1347
+ selector: string;
1348
+ text: string;
1349
+ clearFirst?: boolean;
1350
+ pressEnter?: boolean;
1351
+ typeDelay?: number;
1352
+ }
1353
+ /** Wait action */
1354
+ interface WaitAction extends BaseAgentAction {
1355
+ type: "wait";
1356
+ milliseconds?: number;
1357
+ selector?: string;
1358
+ condition?: "visible" | "hidden" | "attached" | "detached";
1359
+ timeout?: number;
1360
+ }
1361
+ /** Press action */
1362
+ interface PressAction extends BaseAgentAction {
1363
+ type: "press";
1364
+ key: string;
1365
+ modifiers?: Array<"Alt" | "Control" | "Meta" | "Shift">;
1366
+ }
1367
+ /** Screenshot action */
1368
+ interface ScreenshotAgentAction extends BaseAgentAction {
1369
+ type: "screenshot";
1370
+ fullPage?: boolean;
1371
+ selector?: string;
1372
+ format?: "png" | "jpeg";
1373
+ quality?: number;
1374
+ name?: string;
1375
+ }
1376
+ /** Hover action */
1377
+ interface HoverAction extends BaseAgentAction {
1378
+ type: "hover";
1379
+ selector: string;
1380
+ duration?: number;
1381
+ }
1382
+ /** Select action */
1383
+ interface SelectAction extends BaseAgentAction {
1384
+ type: "select";
1385
+ selector: string;
1386
+ value: string | string[];
1387
+ byLabel?: boolean;
1388
+ }
1389
+ /** All agent action types */
1390
+ type AgentAction = ClickAction | ScrollAction | WriteAction | WaitAction | PressAction | ScreenshotAgentAction | HoverAction | SelectAction;
1391
+ /** Options for creating an AI agent job */
1392
+ interface AgentOptions {
1393
+ /** Starting URL for the agent (required) */
1394
+ url: string;
1395
+ /** Additional URLs to process */
1396
+ urls?: string[];
1397
+ /** Natural language instructions for the agent (required, 10-2000 chars) */
1398
+ prompt: string;
1399
+ /** JSON Schema for structured output */
1400
+ schema?: Record<string, unknown>;
1401
+ /** Maximum number of steps (default: 10, max: 25) */
1402
+ maxSteps?: number;
1403
+ /** Preset actions to execute before agent reasoning */
1404
+ actions?: AgentAction[];
1405
+ /** LLM provider (default: openai) */
1406
+ model?: AgentModel;
1407
+ /** Per-step timeout in milliseconds (default: 30000, max: 60000) */
1408
+ timeout?: number;
1409
+ /** Extract only main content area (default: true) */
1410
+ onlyMainContent?: boolean;
1411
+ /** Take screenshots at each step (default: false) */
1412
+ takeScreenshots?: boolean;
1413
+ /** Custom headers for HTTP requests */
1414
+ headers?: Record<string, string>;
1415
+ /** Webhook for async notification */
1416
+ webhook?: {
1417
+ url: string;
1418
+ headers?: Record<string, string>;
1419
+ };
1420
+ }
989
1421
 
990
1422
  /**
991
1423
  * Account Resource
@@ -1128,6 +1560,161 @@ declare class AccountResource {
1128
1560
  isPremium(): Promise<boolean>;
1129
1561
  }
1130
1562
 
1563
+ /**
1564
+ * Agent Resource
1565
+ * Handles AI agent operations for autonomous web navigation and data extraction
1566
+ */
1567
+
1568
+ /**
1569
+ * Agent resource class
1570
+ * Provides methods for creating and managing AI agent jobs
1571
+ *
1572
+ * The agent uses the ReAct pattern (Observation → Thought → Action → Evaluation)
1573
+ * to navigate web pages and extract structured data based on natural language instructions.
1574
+ *
1575
+ * @example
1576
+ * ```ts
1577
+ * // Create an agent to search and extract product info
1578
+ * const job = await client.agent.create({
1579
+ * url: "https://amazon.com",
1580
+ * prompt: "Search for wireless headphones under $50 and extract the top 5 results with name, price, and rating",
1581
+ * schema: {
1582
+ * type: "object",
1583
+ * properties: {
1584
+ * products: {
1585
+ * type: "array",
1586
+ * items: {
1587
+ * type: "object",
1588
+ * properties: {
1589
+ * name: { type: "string" },
1590
+ * price: { type: "number" },
1591
+ * rating: { type: "number" }
1592
+ * }
1593
+ * }
1594
+ * }
1595
+ * }
1596
+ * },
1597
+ * maxSteps: 15
1598
+ * });
1599
+ *
1600
+ * // Wait for result
1601
+ * const result = await client.waitForResult(job.jobId);
1602
+ * ```
1603
+ */
1604
+ declare class AgentResource {
1605
+ private ctx;
1606
+ constructor(ctx: RequestContext);
1607
+ /**
1608
+ * Create a new AI agent job
1609
+ *
1610
+ * @param options - Agent configuration options
1611
+ * @returns Job creation response with jobId and status URL
1612
+ *
1613
+ * @example
1614
+ * ```ts
1615
+ * const job = await client.agent.create({
1616
+ * url: "https://booking.com",
1617
+ * prompt: "Find hotels in Paris for 2 adults, March 15-17, sort by price and extract the 3 cheapest options",
1618
+ * maxSteps: 20,
1619
+ * takeScreenshots: true
1620
+ * });
1621
+ * ```
1622
+ */
1623
+ create(options: AgentOptions): Promise<AgentJobResponse>;
1624
+ /**
1625
+ * Get the status of an agent job
1626
+ *
1627
+ * @param jobId - The job ID to check
1628
+ * @returns Agent status with progress and partial results
1629
+ *
1630
+ * @example
1631
+ * ```ts
1632
+ * const status = await client.agent.getStatus(jobId);
1633
+ * console.log(`Step ${status.partialResult?.steps.length}/${status.totalSteps}`);
1634
+ * ```
1635
+ */
1636
+ getStatus(jobId: string): Promise<AgentStatusResponse>;
1637
+ /**
1638
+ * Create an agent with preset actions
1639
+ * Useful for handling common scenarios like cookie consent, popups, etc.
1640
+ *
1641
+ * @example
1642
+ * ```ts
1643
+ * const job = await client.agent.withPresetActions(
1644
+ * "https://shop.com",
1645
+ * "Find the best discount and extract product details",
1646
+ * [
1647
+ * { type: "click", selector: "#accept-cookies" },
1648
+ * { type: "wait", milliseconds: 1000 }
1649
+ * ]
1650
+ * );
1651
+ * ```
1652
+ */
1653
+ withPresetActions(url: string, prompt: string, actions: AgentOptions["actions"], options?: Omit<AgentOptions, "url" | "prompt" | "actions">): Promise<AgentJobResponse>;
1654
+ /**
1655
+ * Create an agent with a JSON schema for structured output
1656
+ * The agent will extract data matching the provided schema
1657
+ *
1658
+ * @example
1659
+ * ```ts
1660
+ * const job = await client.agent.withSchema(
1661
+ * "https://linkedin.com/company/example",
1662
+ * "Extract company information",
1663
+ * {
1664
+ * type: "object",
1665
+ * properties: {
1666
+ * name: { type: "string" },
1667
+ * employees: { type: "number" },
1668
+ * description: { type: "string" },
1669
+ * website: { type: "string" }
1670
+ * },
1671
+ * required: ["name"]
1672
+ * }
1673
+ * );
1674
+ * ```
1675
+ */
1676
+ withSchema(url: string, prompt: string, schema: Record<string, unknown>, options?: Omit<AgentOptions, "url" | "prompt" | "schema">): Promise<AgentJobResponse>;
1677
+ /**
1678
+ * Create an agent optimized for deal/product extraction
1679
+ * Pre-configured for e-commerce scenarios
1680
+ *
1681
+ * @example
1682
+ * ```ts
1683
+ * const job = await client.agent.forDeals(
1684
+ * "https://slickdeals.net",
1685
+ * "Find the top 10 tech deals posted today"
1686
+ * );
1687
+ * ```
1688
+ */
1689
+ forDeals(url: string, prompt: string, options?: Omit<AgentOptions, "url" | "prompt" | "schema">): Promise<AgentJobResponse>;
1690
+ /**
1691
+ * Create an agent to fill and submit a form
1692
+ * Useful for search forms, login forms, etc.
1693
+ *
1694
+ * @example
1695
+ * ```ts
1696
+ * const job = await client.agent.fillForm(
1697
+ * "https://kayak.com",
1698
+ * "Search for flights from Paris to New York on March 20, return March 27",
1699
+ * { takeScreenshots: true }
1700
+ * );
1701
+ * ```
1702
+ */
1703
+ fillForm(url: string, instructions: string, options?: Omit<AgentOptions, "url" | "prompt">): Promise<AgentJobResponse>;
1704
+ /**
1705
+ * Create an agent using Claude (Anthropic) instead of GPT
1706
+ *
1707
+ * @example
1708
+ * ```ts
1709
+ * const job = await client.agent.withClaude(
1710
+ * "https://complex-site.com",
1711
+ * "Navigate through the multi-step checkout process"
1712
+ * );
1713
+ * ```
1714
+ */
1715
+ withClaude(url: string, prompt: string, options?: Omit<AgentOptions, "url" | "prompt" | "model">): Promise<AgentJobResponse>;
1716
+ }
1717
+
1131
1718
  /**
1132
1719
  * Crawl Resource
1133
1720
  * Handles website crawling operations
@@ -1665,10 +2252,16 @@ declare class KeysResource {
1665
2252
  *
1666
2253
  * @example
1667
2254
  * ```ts
2255
+ * // Simple revoke
1668
2256
  * await client.keys.revoke("key_abc123");
2257
+ *
2258
+ * // With reason
2259
+ * await client.keys.revoke("key_abc123", {
2260
+ * reason: "Key compromised"
2261
+ * });
1669
2262
  * ```
1670
2263
  */
1671
- revoke(keyId: string): Promise<DeleteKeyResponse>;
2264
+ revoke(keyId: string, options?: RevokeApiKeyOptions): Promise<DeleteKeyResponse>;
1672
2265
  /**
1673
2266
  * Revoke all API keys (except the current one)
1674
2267
  *
@@ -1705,7 +2298,7 @@ declare class KeysResource {
1705
2298
 
1706
2299
  /**
1707
2300
  * Scrape Resource
1708
- * Handles single page scraping operations
2301
+ * Handles single page and batch scraping operations
1709
2302
  */
1710
2303
 
1711
2304
  /**
@@ -1739,6 +2332,19 @@ declare class ScrapeResource {
1739
2332
  * ```
1740
2333
  */
1741
2334
  extractDeal(url: string, options?: Omit<ScrapeOptions, "url" | "extractDeal">): Promise<ScrapeJobResponse>;
2335
+ /**
2336
+ * Scrape a list page and extract multiple deals
2337
+ * Use for category pages, deal lists, search results
2338
+ *
2339
+ * @example
2340
+ * ```ts
2341
+ * const job = await client.scrape.extractDeals(
2342
+ * "https://amazon.fr/deals",
2343
+ * { maxDeals: 30, useAdvancedModel: true }
2344
+ * );
2345
+ * ```
2346
+ */
2347
+ extractDeals(url: string, options?: Omit<ScrapeOptions, "url" | "extractMultipleDeals">): Promise<ScrapeJobResponse>;
1742
2348
  /**
1743
2349
  * Scrape a URL with screenshot capture
1744
2350
  * Convenience method for screenshot capture
@@ -1752,6 +2358,122 @@ declare class ScrapeResource {
1752
2358
  * ```
1753
2359
  */
1754
2360
  withScreenshot(url: string, screenshotOptions?: Omit<ScrapeOptions["screenshot"], "enabled">, options?: Omit<ScrapeOptions, "url" | "screenshot">): Promise<ScrapeJobResponse>;
2361
+ /**
2362
+ * Create a batch scrape job for multiple URLs
2363
+ * Scrapes 1-100 URLs in a single request
2364
+ *
2365
+ * @example
2366
+ * ```ts
2367
+ * const batch = await client.scrape.batch({
2368
+ * urls: [
2369
+ * { url: "https://shop1.com/product1" },
2370
+ * { url: "https://shop2.com/deal", extractDeal: true }
2371
+ * ],
2372
+ * defaults: { detectSignals: true }
2373
+ * });
2374
+ * console.log(batch.batchId, batch.results);
2375
+ * ```
2376
+ */
2377
+ batch(options: BatchScrapeOptions): Promise<BatchScrapeResponse>;
2378
+ /**
2379
+ * Get status of a batch scrape operation
2380
+ *
2381
+ * @example
2382
+ * ```ts
2383
+ * const status = await client.scrape.getBatchStatus(batchId);
2384
+ * console.log(`Completed: ${status.completed}/${status.total}`);
2385
+ * ```
2386
+ */
2387
+ getBatchStatus(batchId: string): Promise<BatchStatusResponse>;
2388
+ /**
2389
+ * Batch scrape with deal extraction enabled for all URLs
2390
+ * Convenience method for deal-focused batch scraping
2391
+ *
2392
+ * @example
2393
+ * ```ts
2394
+ * const batch = await client.scrape.batchForDeals([
2395
+ * "https://shop1.com/sale",
2396
+ * "https://shop2.com/deals"
2397
+ * ]);
2398
+ * ```
2399
+ */
2400
+ batchForDeals(urls: string[], options?: Omit<BatchScrapeOptions, "urls">): Promise<BatchScrapeResponse>;
2401
+ }
2402
+
2403
+ /**
2404
+ * Search Resource
2405
+ * Handles web search operations with AI optimization
2406
+ */
2407
+
2408
+ /**
2409
+ * Search resource class
2410
+ * Provides methods for web search with AI optimization
2411
+ */
2412
+ declare class SearchResource {
2413
+ private ctx;
2414
+ constructor(ctx: RequestContext);
2415
+ /**
2416
+ * Create a new search job
2417
+ *
2418
+ * @example
2419
+ * ```ts
2420
+ * const result = await client.search.create({
2421
+ * query: "laptop deals black friday",
2422
+ * maxResults: 20,
2423
+ * useDealScoring: true
2424
+ * });
2425
+ * ```
2426
+ */
2427
+ create(options: SearchOptions): Promise<SearchJobResponse>;
2428
+ /**
2429
+ * Search with AI query optimization
2430
+ * Convenience method for AI-enhanced searches
2431
+ *
2432
+ * @example
2433
+ * ```ts
2434
+ * const result = await client.search.withAI("iphone discount", {
2435
+ * aiProvider: "openai",
2436
+ * aiModel: "gpt-4o-mini"
2437
+ * });
2438
+ * ```
2439
+ */
2440
+ withAI(query: string, options?: Omit<SearchOptions, "query" | "useAiOptimization">): Promise<SearchJobResponse>;
2441
+ /**
2442
+ * Search with deal scoring enabled
2443
+ * Scores each result for deal relevance (0-100)
2444
+ *
2445
+ * @example
2446
+ * ```ts
2447
+ * const result = await client.search.forDeals("gaming laptop");
2448
+ * ```
2449
+ */
2450
+ forDeals(query: string, options?: Omit<SearchOptions, "query" | "useDealScoring">): Promise<SearchJobResponse>;
2451
+ /**
2452
+ * Search and auto-scrape top results
2453
+ * Creates scrape jobs for the best matching URLs
2454
+ *
2455
+ * @example
2456
+ * ```ts
2457
+ * const result = await client.search.andScrape("promo codes", {
2458
+ * autoScrapeLimit: 5
2459
+ * });
2460
+ * console.log(result.data.scrapedJobIds);
2461
+ * ```
2462
+ */
2463
+ andScrape(query: string, options?: Omit<SearchOptions, "query" | "autoScrape">): Promise<SearchJobResponse>;
2464
+ /**
2465
+ * Check search API status
2466
+ * Returns availability and features info
2467
+ *
2468
+ * @example
2469
+ * ```ts
2470
+ * const status = await client.search.getStatus();
2471
+ * if (status.available) {
2472
+ * console.log(`Provider: ${status.provider}`);
2473
+ * }
2474
+ * ```
2475
+ */
2476
+ getStatus(): Promise<SearchStatusResponse>;
1755
2477
  }
1756
2478
 
1757
2479
  /**
@@ -2032,17 +2754,38 @@ declare class DealCrawl {
2032
2754
  /** Internal request context */
2033
2755
  private readonly ctx;
2034
2756
  /**
2035
- * Scrape resource - Single page scraping
2757
+ * Scrape resource - Single page and batch scraping
2036
2758
  *
2037
2759
  * @example
2038
2760
  * ```ts
2761
+ * // Single page
2039
2762
  * const job = await client.scrape.create({
2040
2763
  * url: "https://example.com",
2041
2764
  * extractDeal: true
2042
2765
  * });
2766
+ *
2767
+ * // Batch scraping
2768
+ * const batch = await client.scrape.batch({
2769
+ * urls: [{ url: "https://shop1.com" }, { url: "https://shop2.com" }]
2770
+ * });
2043
2771
  * ```
2044
2772
  */
2045
2773
  readonly scrape: ScrapeResource;
2774
+ /**
2775
+ * Search resource - Web search with AI optimization
2776
+ *
2777
+ * @example
2778
+ * ```ts
2779
+ * const result = await client.search.create({
2780
+ * query: "laptop deals",
2781
+ * useDealScoring: true
2782
+ * });
2783
+ *
2784
+ * // With AI optimization
2785
+ * const result = await client.search.withAI("iphone discount");
2786
+ * ```
2787
+ */
2788
+ readonly search: SearchResource;
2046
2789
  /**
2047
2790
  * Crawl resource - Website crawling
2048
2791
  *
@@ -2084,6 +2827,29 @@ declare class DealCrawl {
2084
2827
  * ```
2085
2828
  */
2086
2829
  readonly dork: DorkResource;
2830
+ /**
2831
+ * Agent resource - AI-powered autonomous web navigation
2832
+ *
2833
+ * The agent uses ReAct pattern (Observation → Thought → Action → Evaluation)
2834
+ * to navigate web pages and extract structured data based on natural language.
2835
+ *
2836
+ * @example
2837
+ * ```ts
2838
+ * const job = await client.agent.create({
2839
+ * url: "https://amazon.com",
2840
+ * prompt: "Search for wireless headphones under $50 and extract top 5 results",
2841
+ * maxSteps: 15
2842
+ * });
2843
+ *
2844
+ * // With schema for structured output
2845
+ * const job = await client.agent.withSchema(
2846
+ * "https://example.com",
2847
+ * "Extract product info",
2848
+ * { type: "object", properties: {...} }
2849
+ * );
2850
+ * ```
2851
+ */
2852
+ readonly agent: AgentResource;
2087
2853
  /**
2088
2854
  * Status resource - Job status management
2089
2855
  *
@@ -2249,6 +3015,35 @@ declare class DealCrawl {
2249
3015
  * ```
2250
3016
  */
2251
3017
  extractAndWait<T = unknown>(options: Parameters<ExtractResource["create"]>[0], waitOptions?: WaitOptions): Promise<WaitResult<T>>;
3018
+ /**
3019
+ * Search and return results directly
3020
+ * Note: Search is synchronous, no waiting needed
3021
+ *
3022
+ * @example
3023
+ * ```ts
3024
+ * const result = await client.searchAndWait({
3025
+ * query: "gaming laptop deals",
3026
+ * useDealScoring: true
3027
+ * });
3028
+ * console.log(result.data.results);
3029
+ * ```
3030
+ */
3031
+ searchAndWait(options: Parameters<SearchResource["create"]>[0]): Promise<ReturnType<SearchResource["create"]>>;
3032
+ /**
3033
+ * Create an agent job and wait for result
3034
+ * Combines create and waitForResult
3035
+ *
3036
+ * @example
3037
+ * ```ts
3038
+ * const result = await client.agentAndWait({
3039
+ * url: "https://booking.com",
3040
+ * prompt: "Find hotels in Paris for March 15-17",
3041
+ * maxSteps: 20
3042
+ * });
3043
+ * console.log(result.data);
3044
+ * ```
3045
+ */
3046
+ agentAndWait<T = unknown>(options: Parameters<AgentResource["create"]>[0], waitOptions?: WaitOptions): Promise<WaitResult<T>>;
2252
3047
  }
2253
3048
 
2254
3049
  /**
@@ -2332,4 +3127,4 @@ declare class DealCrawlError extends Error {
2332
3127
  }, retryAfter?: number | string | null): DealCrawlError;
2333
3128
  }
2334
3129
 
2335
- export { type AccountInfoResponse, type AccountMetricsResponse, AccountResource, type ApiError, type ApiKeyInfo, type ApiKeyScope, type ApiResponse, type CancelJobResponse, type CheckpointInfo, type ClientPreferences, type ClientStatsResponse, type CrawlAnalysisResponse, type CrawlJobResponse, type CrawlOptions, type CrawlRecommendation, CrawlResource, type CrawlResult, type CrawlTemplate, type CrawlTemplateId, type CreateApiKeyOptions, type CreateKeyResponse, type CreateWebhookOptions, type CreateWebhookResponse, type CreatedApiKey, DEFAULT_CONFIG, DataResource, DealCrawl, type DealCrawlConfig, DealCrawlError, type DealDetails, type DealItem, type DealMetrics, type DealScoreSummary, type DealSummary, type DealUpMetrics, type DealUpMetricsResponse, type DeleteKeyResponse, type DeleteWebhookResponse, type DiscountSignal, type DorkJobResponse, type DorkOptions, DorkResource, type DorkResult, ERROR_CODES, type ErrorCode, type ExportDealsOptions, type ExportFormat, type ExportJobsOptions, type ExtractJobResponse, type ExtractModel, type ExtractOptions, ExtractResource, type ExtractedDeal, type GetApiKeyStatsOptions, type GetDealsOptions, type JobDealsResponse, type JobMetricsResponse, type JobResponse, type JobStatus, type JobStatusFilter, type JobStatusResponse, type JobSummary, type JobTypeFilter, type KeyStatsResponse, KeysResource, type ListApiKeysOptions, type ListDealsOptions, type ListDealsResponse, type ListJobsOptions, type ListJobsResponse, type ListKeysResponse, type ListWebhooksResponse, type PaginatedResponse, type PaginationInfo, type ParsedPage, type PreferencesResponse, type PriceSignal, type PricingInfo, type ProductCategory, type ProductInfo, type RateLimitInfo, type RecommendationsResponse, type RequestContext, type ResumeJobResponse, type RotateApiKeyOptions, type RotateKeyResponse, type ScrapeJobResponse, type ScrapeOptions, ScrapeResource, type ScrapeResult, type ScreenshotOptions, type Signal, type SortOrder, StatusResource, type TestWebhookResponse, type UpdatePreferencesOptions, type UpdatePreferencesResponse, type UpdateWebhookOptions, type UpdateWebhookResponse, type UsageStats, type WaitOptions, type WaitResult, type WebhookEvent, type WebhookItem, WebhooksResource, DealCrawl as default, pollUntil, waitForAll, waitForAny, waitForResult };
3130
+ export { ALL_API_KEY_SCOPES, type AccountInfoResponse, type AccountMetricsResponse, AccountResource, type AgentAction, type AgentActionType, type AgentCompletionReason, type AgentJobResponse, type AgentModel, type AgentOptions, AgentResource, type AgentResultResponse, type AgentStatusResponse, type AgentStepResponse, type ApiError, type ApiKeyInfo, type ApiKeyScope, type ApiResponse, type BatchScrapeDefaults, type BatchScrapeItem, type BatchScrapeOptions, type BatchScrapeResponse, type BatchScrapeResultItem, type BatchStatusResponse, type CancelJobResponse, type CheckpointInfo, type ClickAction, type ClientPreferences, type ClientStatsResponse, type CrawlAnalysisResponse, type CrawlJobResponse, type CrawlOptions, type CrawlRecommendation, CrawlResource, type CrawlResult, type CrawlTemplate, type CrawlTemplateId, type CreateApiKeyOptions, type CreateKeyResponse, type CreateWebhookOptions, type CreateWebhookResponse, type CreatedApiKey, DEFAULT_API_KEY_SCOPES, DEFAULT_CONFIG, DataResource, DealCrawl, type DealCrawlConfig, DealCrawlError, type DealDetails, type DealItem, type DealMetrics, type DealScoreSummary, type DealSummary, type DealUpMetrics, type DealUpMetricsResponse, type DeleteKeyResponse, type DeleteWebhookResponse, type DiscountSignal, type DorkJobResponse, type DorkOptions, DorkResource, type DorkResult, ERROR_CODES, type ErrorCode, type ExportDealsOptions, type ExportFormat, type ExportJobsOptions, type ExtractJobResponse, type ExtractModel, type ExtractOptions, ExtractResource, type ExtractedDeal, type GetApiKeyStatsOptions, type GetDealsOptions, type HoverAction, type JobDealsResponse, type JobMetricsResponse, type JobResponse, type JobStatus, type JobStatusFilter, type JobStatusResponse, type JobSummary, type JobTypeFilter, type KeyStatsResponse, KeysResource, type ListApiKeysOptions, type ListDealsOptions, type ListDealsResponse, type ListJobsOptions, type ListJobsResponse, type ListKeysResponse, type ListWebhooksResponse, type PaginatedResponse, type PaginationInfo, type ParsedPage, type PreferencesResponse, type PressAction, type PriceSignal, type PricingInfo, type ProductCategory, type ProductInfo, type RateLimitInfo, type RecommendationsResponse, type RequestContext, type ResumeJobResponse, type RevokeApiKeyOptions, type RotateApiKeyOptions, type RotateKeyResponse, type ScrapeJobResponse, type ScrapeOptions, ScrapeResource, type ScrapeResult, type ScreenshotAgentAction, type ScreenshotOptions, type ScrollAction, type SearchAiModel, type SearchAiProvider, type SearchData, type SearchDateRange, type SearchFilters, type SearchJobResponse, type SearchOptions, SearchResource, type SearchResultItem, type SearchStatusResponse, type SelectAction, type Signal, type SortOrder, StatusResource, type TestWebhookResponse, type UpdatePreferencesOptions, type UpdatePreferencesResponse, type UpdateWebhookOptions, type UpdateWebhookResponse, type UsageStats, type WaitAction, type WaitOptions, type WaitResult, type WebhookEvent, type WebhookItem, WebhooksResource, type WriteAction, DealCrawl as default, pollUntil, waitForAll, waitForAny, waitForResult };