@decodo/sdk-ts 2.4.0 → 2.5.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
@@ -68,7 +68,7 @@ node -e "let p=require('./package.json'); p.type='module'; require('fs').writeFi
68
68
 
69
69
  </details>
70
70
 
71
- Get a Web Scraping API basic authentication token from the [Decodo dashboard](https://dashboard.decodo.com/welcome) and use it in the following example:
71
+ Copy your Web Data API key from your Web Data API subscription on the [Decodo dashboard](https://dashboard.decodo.com/web-data/playground) and use it in the following example. Older plans only have a basic authentication token, which you can pass as `token` instead (see [Configuration](#configuration)).
72
72
 
73
73
  ```typescript
74
74
  // main.js
@@ -76,7 +76,7 @@ import { DecodoClient, Target } from '@decodo/sdk-ts';
76
76
 
77
77
  const client = new DecodoClient({
78
78
  webScrapingApi: {
79
- token: '<basic_auth_token>',
79
+ apiKey: '<api_key>',
80
80
  },
81
81
  });
82
82
 
@@ -358,16 +358,28 @@ node main.js
358
358
  ```typescript
359
359
  const client = new DecodoClient({
360
360
  webScrapingApi: {
361
- token: '<basic_auth_token>',
361
+ apiKey: '<api_key>',
362
362
  },
363
363
  timeoutMs: 120_000, // optional, request timeout in ms (default: 180s)
364
364
  });
365
365
  ```
366
366
 
367
- | Parameter | Description |
368
- | --- | --- |
369
- | `token` | Web Scraping API basic authentication token |
370
- | `timeoutMs` | Request timeout in milliseconds (default: 180000) |
367
+ Pass either `apiKey` or `token`, not both. The client throws if you set both.
368
+
369
+ ```typescript
370
+ // Basic authentication token (older plans)
371
+ const client = new DecodoClient({
372
+ webScrapingApi: {
373
+ token: '<basic_auth_token>',
374
+ },
375
+ });
376
+ ```
377
+
378
+ | Parameter | Description |
379
+ | ----------- | ---------------------------------------------------------------------------------------- |
380
+ | `apiKey` | Web Data API key. Recommended |
381
+ | `token` | Web Scraping API basic authentication token, for older plans. Use it instead of `apiKey` |
382
+ | `timeoutMs` | Request timeout in milliseconds (default: 180000) |
371
383
 
372
384
  ## Web Scraping API
373
385
 
@@ -430,52 +442,52 @@ Each target accepts one primary input parameter (`url`, `query`, `product_id`, o
430
442
 
431
443
  ### Search engines
432
444
 
433
- | Target | Description | Example |
434
- | --- | --- | --- |
435
- | `Target.GoogleSearch` | Google Search results for a query | `{ target: Target.GoogleSearch, query: "coffee shops" }` |
436
- | `Target.GoogleMaps` | Google Maps search results | `{ target: Target.GoogleMaps, query: "coffee shops brooklyn" }` |
437
- | `Target.GoogleShoppingSearch` | Google Shopping search results | `{ target: Target.GoogleShoppingSearch, query: "laptop" }` |
438
- | `Target.GoogleSuggest` | Google Autocomplete suggestions | `{ target: Target.GoogleSuggest, query: "coffee" }` |
439
- | `Target.GoogleLens` | Google Lens reverse image search | `{ target: Target.GoogleLens, query: "https://example.com/cat.jpg" }` |
440
- | `Target.BingSearch` | Bing Search results | `{ target: Target.BingSearch, query: "electric vehicles" }` |
445
+ | Target | Description | Example |
446
+ | ----------------------------- | --------------------------------- | --------------------------------------------------------------------- |
447
+ | `Target.GoogleSearch` | Google Search results for a query | `{ target: Target.GoogleSearch, query: "coffee shops" }` |
448
+ | `Target.GoogleMaps` | Google Maps search results | `{ target: Target.GoogleMaps, query: "coffee shops brooklyn" }` |
449
+ | `Target.GoogleShoppingSearch` | Google Shopping search results | `{ target: Target.GoogleShoppingSearch, query: "laptop" }` |
450
+ | `Target.GoogleSuggest` | Google Autocomplete suggestions | `{ target: Target.GoogleSuggest, query: "coffee" }` |
451
+ | `Target.GoogleLens` | Google Lens reverse image search | `{ target: Target.GoogleLens, query: "https://example.com/cat.jpg" }` |
452
+ | `Target.BingSearch` | Bing Search results | `{ target: Target.BingSearch, query: "electric vehicles" }` |
441
453
 
442
454
  ### eCommerce
443
455
 
444
- | Target | Description | Example |
445
- | --- | --- | --- |
446
- | `Target.AmazonProduct` | Amazon product detail page by ASIN | `{ target: Target.AmazonProduct, query: "B09H74FXNW" }` |
447
- | `Target.AmazonSearch` | Amazon search results | `{ target: Target.AmazonSearch, query: "laptop" }` |
448
- | `Target.AmazonPricing` | Amazon pricing and offers | `{ target: Target.AmazonPricing, query: "B09H74FXNW" }` |
449
- | `Target.WalmartProduct` | Walmart product page by product ID | `{ target: Target.WalmartProduct, product_id: "15296401808" }` |
450
- | `Target.TargetProduct` | Target.com product page by product ID | `{ target: Target.TargetProduct, product_id: "92186007" }` |
451
- | `Target.Ecommerce` | Generic eCommerce page with parser | `{ target: Target.Ecommerce, url: "https://example.com/product/123" }` |
456
+ | Target | Description | Example |
457
+ | ----------------------- | ------------------------------------- | ---------------------------------------------------------------------- |
458
+ | `Target.AmazonProduct` | Amazon product detail page by ASIN | `{ target: Target.AmazonProduct, query: "B09H74FXNW" }` |
459
+ | `Target.AmazonSearch` | Amazon search results | `{ target: Target.AmazonSearch, query: "laptop" }` |
460
+ | `Target.AmazonPricing` | Amazon pricing and offers | `{ target: Target.AmazonPricing, query: "B09H74FXNW" }` |
461
+ | `Target.WalmartProduct` | Walmart product page by product ID | `{ target: Target.WalmartProduct, product_id: "15296401808" }` |
462
+ | `Target.TargetProduct` | Target.com product page by product ID | `{ target: Target.TargetProduct, product_id: "92186007" }` |
463
+ | `Target.Ecommerce` | Generic eCommerce page with parser | `{ target: Target.Ecommerce, url: "https://example.com/product/123" }` |
452
464
 
453
465
  ### Social media
454
466
 
455
- | Target | Description | Example |
456
- | --- | --- | --- |
457
- | `Target.RedditPost` | Reddit post by URL | `{ target: Target.RedditPost, url: "https://reddit.com/r/nba/..." }` |
458
- | `Target.RedditSubreddit` | Reddit subreddit by URL | `{ target: Target.RedditSubreddit, url: "https://reddit.com/r/nba/" }` |
459
- | `Target.YoutubeVideo` | YouTube video by ID | `{ target: Target.YoutubeVideo, query: "dFu9aKJoqGg" }` |
460
- | `Target.YoutubeSearch` | YouTube search results | `{ target: Target.YoutubeSearch, query: "ambient music" }` |
461
- | `Target.TiktokPost` | TikTok post by URL | `{ target: Target.TiktokPost, url: "https://www.tiktok.com/@nba/video/..." }` |
467
+ | Target | Description | Example |
468
+ | ------------------------ | ----------------------- | ----------------------------------------------------------------------------- |
469
+ | `Target.RedditPost` | Reddit post by URL | `{ target: Target.RedditPost, url: "https://reddit.com/r/nba/..." }` |
470
+ | `Target.RedditSubreddit` | Reddit subreddit by URL | `{ target: Target.RedditSubreddit, url: "https://reddit.com/r/nba/" }` |
471
+ | `Target.YoutubeVideo` | YouTube video by ID | `{ target: Target.YoutubeVideo, query: "dFu9aKJoqGg" }` |
472
+ | `Target.YoutubeSearch` | YouTube search results | `{ target: Target.YoutubeSearch, query: "ambient music" }` |
473
+ | `Target.TiktokPost` | TikTok post by URL | `{ target: Target.TiktokPost, url: "https://www.tiktok.com/@nba/video/..." }` |
462
474
 
463
475
  ### AI tools
464
476
 
465
- | Target | Description | Example |
466
- | --- | --- | --- |
467
- | `Target.Chatgpt` | ChatGPT response for a prompt | `{ target: Target.Chatgpt, prompt: "What are the top three dog breeds?" }` |
468
- | `Target.Perplexity` | Perplexity response for a prompt | `{ target: Target.Perplexity, prompt: "What causes seasonal allergies?" }` |
469
- | `Target.Gemini` | Gemini response for a prompt | `{ target: Target.Gemini, prompt: "What are the top three dog breeds?" }` |
470
- | `Target.GoogleAiMode` | Google AI Mode response | `{ target: Target.GoogleAiMode, query: "What are the top three dog breeds?" }` |
477
+ | Target | Description | Example |
478
+ | --------------------- | -------------------------------- | ------------------------------------------------------------------------------ |
479
+ | `Target.Chatgpt` | ChatGPT response for a prompt | `{ target: Target.Chatgpt, prompt: "What are the top three dog breeds?" }` |
480
+ | `Target.Perplexity` | Perplexity response for a prompt | `{ target: Target.Perplexity, prompt: "What causes seasonal allergies?" }` |
481
+ | `Target.Gemini` | Gemini response for a prompt | `{ target: Target.Gemini, prompt: "What are the top three dog breeds?" }` |
482
+ | `Target.GoogleAiMode` | Google AI Mode response | `{ target: Target.GoogleAiMode, query: "What are the top three dog breeds?" }` |
471
483
 
472
484
  ### Universal scraping
473
485
 
474
- | Target | Description | Example |
475
- | --- | --- | --- |
476
- | `Target.Universal` | Any URL via the universal scraper | `{ target: Target.Universal, url: "https://example.com" }` |
477
- | `Target.Google` | Raw Google URL scraping | `{ target: Target.Google, url: "https://google.com/search?q=laptop" }` |
478
- | `Target.Amazon` | Raw Amazon URL scraping | `{ target: Target.Amazon, url: "https://amazon.com/dp/B09H74FXNW" }` |
486
+ | Target | Description | Example |
487
+ | ------------------ | --------------------------------- | ---------------------------------------------------------------------- |
488
+ | `Target.Universal` | Any URL via the universal scraper | `{ target: Target.Universal, url: "https://example.com" }` |
489
+ | `Target.Google` | Raw Google URL scraping | `{ target: Target.Google, url: "https://google.com/search?q=laptop" }` |
490
+ | `Target.Amazon` | Raw Amazon URL scraping | `{ target: Target.Amazon, url: "https://amazon.com/dp/B09H74FXNW" }` |
479
491
 
480
492
  > `Target.UniversalEcommerce` isn't listed above because it doesn't accept a primary input parameter like `url`, `query`, `product_id`, or `prompt`. It only accepts optional configuration fields such as `callback_url`.
481
493
 
@@ -2849,7 +2849,7 @@ var resolveTransport = (config) => {
2849
2849
  routes: SCRAPER_API_ROUTES
2850
2850
  };
2851
2851
  }
2852
- throw new Error("webScrapingApi requires token in DecodoConfig.");
2852
+ throw new Error("webScrapingApi requires apiKey or token in DecodoConfig.");
2853
2853
  };
2854
2854
  var DecodoClient = class {
2855
2855
  webScrapingApi;
@@ -2873,7 +2873,7 @@ var DecodoClient = class {
2873
2873
  get() {
2874
2874
  notConfigured(
2875
2875
  "webScrapingApi",
2876
- "Provide webScrapingApi.token in DecodoConfig."
2876
+ "Provide webScrapingApi.apiKey or webScrapingApi.token in DecodoConfig."
2877
2877
  );
2878
2878
  }
2879
2879
  });
@@ -44,7 +44,7 @@ const resolveTransport = (config) => {
44
44
  routes: SCRAPER_API_ROUTES,
45
45
  };
46
46
  }
47
- throw new Error('webScrapingApi requires token in DecodoConfig.');
47
+ throw new Error('webScrapingApi requires apiKey or token in DecodoConfig.');
48
48
  };
49
49
  export class DecodoClient {
50
50
  webScrapingApi;
@@ -63,7 +63,7 @@ export class DecodoClient {
63
63
  else {
64
64
  this.webScrapingApi = new Proxy({}, {
65
65
  get() {
66
- notConfigured('webScrapingApi', 'Provide webScrapingApi.token in DecodoConfig.');
66
+ notConfigured('webScrapingApi', 'Provide webScrapingApi.apiKey or webScrapingApi.token in DecodoConfig.');
67
67
  },
68
68
  });
69
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decodo/sdk-ts",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Official TypeScript SDK for the Decodo APIs",
5
5
  "type": "module",
6
6
  "main": "./build/cjs/index.cjs",
@@ -21,6 +21,18 @@
21
21
  "files": [
22
22
  "build"
23
23
  ],
24
+ "scripts": {
25
+ "codegen": "tsx src/codegen/codegen.ts",
26
+ "build": "pnpm run codegen && pnpm run build:esm && pnpm run build:cjs",
27
+ "build:esm": "tsc -p tsconfig.build.json",
28
+ "build:cjs": "rm -rf build/cjs && mkdir -p build/cjs && esbuild src/index.ts --bundle --platform=node --format=cjs --external:zod --outfile=build/cjs/index.cjs && dts-bundle-generator -o build/cjs/index.d.cts --project tsconfig.build.json build/esm/index.d.ts",
29
+ "typecheck": "tsc --noEmit",
30
+ "lint": "eslint .",
31
+ "lint:fix": "eslint . --fix",
32
+ "test": "vitest run",
33
+ "test:watch": "vitest",
34
+ "prepack": "pnpm run build:esm && pnpm run build:cjs"
35
+ },
24
36
  "engines": {
25
37
  "node": ">=18.0.0"
26
38
  },
@@ -40,16 +52,5 @@
40
52
  "dependencies": {
41
53
  "zod": "^4"
42
54
  },
43
- "license": "MIT",
44
- "scripts": {
45
- "codegen": "tsx src/codegen/codegen.ts",
46
- "build": "pnpm run codegen && pnpm run build:esm && pnpm run build:cjs",
47
- "build:esm": "tsc -p tsconfig.build.json",
48
- "build:cjs": "rm -rf build/cjs && mkdir -p build/cjs && esbuild src/index.ts --bundle --platform=node --format=cjs --external:zod --outfile=build/cjs/index.cjs && dts-bundle-generator -o build/cjs/index.d.cts --project tsconfig.build.json build/esm/index.d.ts",
49
- "typecheck": "tsc --noEmit",
50
- "lint": "eslint .",
51
- "lint:fix": "eslint . --fix",
52
- "test": "vitest run",
53
- "test:watch": "vitest"
54
- }
55
- }
55
+ "license": "MIT"
56
+ }