@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/README.md CHANGED
@@ -8,7 +8,7 @@ Official TypeScript SDK for the DealCrawl web scraping and crawling API.
8
8
 
9
9
  ## Features
10
10
 
11
- - 🚀 **Full API Coverage** - Access all 41 DealCrawl API endpoints
11
+ - 🚀 **Full API Coverage** - Access all 45 DealCrawl API endpoints
12
12
  - 📦 **Zero Dependencies** - Uses native `fetch`, works everywhere
13
13
  - 🔒 **Type-Safe** - Complete TypeScript definitions
14
14
  - ⚡ **Automatic Retries** - Built-in retry logic with exponential backoff
@@ -98,6 +98,98 @@ const job = await client.scrape.withScreenshot("https://example.com", {
98
98
  | `excludeTags` | string[] | - | HTML tags to exclude |
99
99
  | `onlyMainContent` | boolean | true | Extract main content only |
100
100
 
101
+ ### Batch Scrape - Bulk URL Scraping (NEW)
102
+
103
+ ```typescript
104
+ // Scrape multiple URLs in one request (1-100 URLs)
105
+ const batch = await client.scrape.batch({
106
+ urls: [
107
+ { url: "https://shop1.com/product1" },
108
+ { url: "https://shop2.com/deal", extractDeal: true },
109
+ { url: "https://shop3.com/sale", screenshot: { enabled: true } },
110
+ ],
111
+ defaults: {
112
+ detectSignals: true,
113
+ timeout: 30000,
114
+ },
115
+ });
116
+
117
+ // Get batch status
118
+ const status = await client.scrape.getBatchStatus(batch.batchId);
119
+
120
+ // Wait for all batch jobs
121
+ const results = await client.waitForAll(batch.jobIds);
122
+ ```
123
+
124
+ **Batch Options:**
125
+ | Option | Type | Default | Description |
126
+ |--------|------|---------|-------------|
127
+ | `urls` | array | required | 1-100 URL objects with optional overrides |
128
+ | `defaults` | object | - | Default options applied to all URLs |
129
+ | `priority` | number | 5 | Priority 1-10 (higher = faster) |
130
+ | `delay` | number | 0 | Delay between URLs (0-5000ms) |
131
+ | `webhookUrl` | string | - | Webhook for batch completion |
132
+ | `ref` | string | - | Custom reference ID for tracking |
133
+
134
+ ### Search - Web Search with AI (NEW)
135
+
136
+ ```typescript
137
+ // Basic search
138
+ const job = await client.search.create({
139
+ query: "laptop deals black friday",
140
+ maxResults: 20,
141
+ });
142
+
143
+ // AI-optimized search with deal scoring
144
+ const job = await client.search.create({
145
+ query: "iPhone discount",
146
+ useAiOptimization: true,
147
+ aiProvider: "openai",
148
+ aiModel: "gpt-4o-mini",
149
+ useDealScoring: true,
150
+ });
151
+
152
+ // Search with auto-scraping of results
153
+ const job = await client.search.create({
154
+ query: "promo codes electronics",
155
+ autoScrape: true,
156
+ autoScrapeLimit: 5,
157
+ });
158
+
159
+ // Filtered search
160
+ const job = await client.search.create({
161
+ query: "software deals",
162
+ filters: {
163
+ location: "fr",
164
+ language: "fr",
165
+ dateRange: "month",
166
+ domains: ["amazon.fr", "cdiscount.com"],
167
+ },
168
+ });
169
+
170
+ // Check search API status
171
+ const status = await client.search.getStatus();
172
+
173
+ // Convenience: search and wait
174
+ const result = await client.searchAndWait({
175
+ query: "gaming laptop deals",
176
+ useDealScoring: true,
177
+ });
178
+ ```
179
+
180
+ **Search Options:**
181
+ | Option | Type | Default | Description |
182
+ |--------|------|---------|-------------|
183
+ | `query` | string | required | Search query |
184
+ | `maxResults` | number | 10 | Results to return (1-100) |
185
+ | `useAiOptimization` | boolean | false | AI-enhance the query |
186
+ | `aiProvider` | string | "openai" | "openai" or "anthropic" |
187
+ | `aiModel` | string | - | Model ID (gpt-4o-mini, claude-3-5-sonnet, etc.) |
188
+ | `useDealScoring` | boolean | false | Score results for deal relevance |
189
+ | `autoScrape` | boolean | false | Auto-scrape top results |
190
+ | `autoScrapeLimit` | number | 3 | Number of results to scrape |
191
+ | `filters` | object | - | Location, language, date, domains |
192
+
101
193
  ### Crawl - Website Crawling
102
194
 
103
195
  ```typescript
@@ -295,8 +387,10 @@ const rotated = await client.keys.rotate(keyId, {
295
387
  newName: "Production Key v2",
296
388
  });
297
389
 
298
- // Revoke a key
299
- await client.keys.revoke(keyId);
390
+ // Revoke a key with reason
391
+ await client.keys.revoke(keyId, {
392
+ reason: "Key compromised - rotating for security",
393
+ });
300
394
 
301
395
  // Get key stats
302
396
  const stats = await client.keys.getStats(keyId, { days: 30 });
@@ -304,17 +398,19 @@ const stats = await client.keys.getStats(keyId, { days: 30 });
304
398
 
305
399
  **Available Scopes:**
306
400
 
307
- | Scope | Endpoint | Description |
308
- | ----------------- | --------------------- | ---------------------- |
309
- | `scrape` | `POST /v1/scrape` | Create scrape jobs |
310
- | `crawl` | `POST /v1/crawl` | Create crawl jobs |
311
- | `dork` | `POST /v1/dork` | Create dork searches |
312
- | `extract` | `POST /v1/extract` | Create extraction jobs |
313
- | `status` | `GET /v1/status/:id` | Read job status |
314
- | `data:read` | `GET /v1/data/*` | Read jobs/deals |
315
- | `data:export` | `GET /v1/data/export` | Export data |
316
- | `keys:manage` | `/v1/keys` | Manage API keys |
317
- | `webhooks:manage` | `/v1/webhooks` | Manage webhooks |
401
+ | Scope | Endpoint | Description |
402
+ | ----------------- | ----------------------- | ------------------------ |
403
+ | `scrape` | `POST /v1/scrape` | Create scrape jobs |
404
+ | `scrape:batch` | `POST /v1/scrape/batch` | Create batch scrape jobs |
405
+ | `search` | `POST /v1/search` | Create search jobs |
406
+ | `crawl` | `POST /v1/crawl` | Create crawl jobs |
407
+ | `dork` | `POST /v1/dork` | Create dork searches |
408
+ | `extract` | `POST /v1/extract` | Create extraction jobs |
409
+ | `status` | `GET /v1/status/:id` | Read job status |
410
+ | `data:read` | `GET /v1/data/*` | Read jobs/deals |
411
+ | `data:export` | `GET /v1/data/export` | Export data |
412
+ | `keys:manage` | `/v1/keys` | Manage API keys |
413
+ | `webhooks:manage` | `/v1/webhooks` | Manage webhooks |
318
414
 
319
415
  **Scope Examples:**
320
416
 
@@ -406,6 +502,43 @@ const result = await client.crawlAndWait({
406
502
  });
407
503
  ```
408
504
 
505
+ ## Field Selection (NEW)
506
+
507
+ Reduce response payload size by selecting only the fields you need:
508
+
509
+ ```typescript
510
+ // Select specific fields from job status
511
+ const status = await client.status.get(jobId, {
512
+ fields: ["id", "status", "progress", "result.title", "result.url"],
513
+ });
514
+
515
+ // Select fields from deals list
516
+ const deals = await client.data.listDeals({
517
+ minScore: 70,
518
+ fields: ["id", "title", "price", "discount", "dealScore"],
519
+ });
520
+
521
+ // Nested field selection
522
+ const jobs = await client.data.listJobs({
523
+ fields: ["id", "status", "result.deals.title", "result.deals.price"],
524
+ });
525
+ ```
526
+
527
+ **Benefits:**
528
+
529
+ - 85-90% payload reduction for large responses
530
+ - Faster API responses
531
+ - Lower bandwidth usage
532
+
533
+ **Supported Endpoints:**
534
+
535
+ - `GET /v1/status/:jobId`
536
+ - `GET /v1/status/:jobId/deals`
537
+ - `GET /v1/status/:jobId/metrics`
538
+ - `GET /v1/data/jobs`
539
+ - `GET /v1/data/deals`
540
+ - `GET /v1/data/:jobId`
541
+
409
542
  ## Error Handling
410
543
 
411
544
  ```typescript