@decodo/sdk-ts 1.2.0 → 2.0.1

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
@@ -1,3 +1,536 @@
1
- # @decodo/sdk-ts
1
+ # Decodo TypeScript SDK
2
2
 
3
- Official Decodo Typescript SDK for helping integrate with Decodo services.
3
+ ![Node.js](https://img.shields.io/badge/node-%3E%3D18-green)
4
+ ![License](https://img.shields.io/badge/license-MIT-blue)
5
+
6
+ [![](https://dcbadge.limes.pink/api/server/https://discord.gg/Ja8dqKgvbZ)](https://discord.gg/Ja8dqKgvbZ)
7
+
8
+ <p align="center">
9
+ <a href="https://dashboard.decodo.com/integrations?utm_source=github&utm_medium=social&utm_campaign=mcp_server"> <img src="https://github.com/user-attachments/assets/a1e52a9e-3da1-4081-b3c6-053aafb8f196"/></a>
10
+
11
+ The official TypeScript SDK for the Decodo Web Scraping API.
12
+
13
+ Build strongly typed scraping workflows for search engines, eCommerce platforms, social media, AI tools, and more using the Decodo Web Scraping API.
14
+
15
+ - Fully typed targets and parameters with IDE autocomplete
16
+ - Sync, async, and batch scraping methods
17
+ - Native `fetch` support, Node.js 18+
18
+ - Typed error hierarchy for safer integrations
19
+ - Built for TypeScript and modern JavaScript runtimes
20
+
21
+ # What is Decodo TypeScript SDK?
22
+
23
+ Decodo TypeScript SDK is the official TypeScript SDK for the Decodo Web Scraping API. It provides a typed interface for interacting with Decodo targets like Google, Amazon, TikTok, Reddit, YouTube, ChatGPT, Perplexity, and more.
24
+
25
+ Instead of manually constructing HTTP requests and validating payloads, you can work with fully typed methods and target-specific parameters directly in your editor.
26
+
27
+ # Why use the SDK?
28
+
29
+ - **Strong typing and autocomplete**. Target parameters are fully typed for better DX and fewer mistakes.
30
+ - **Unified scraping interface**. Work with search engines, eCommerce platforms, social media, and AI tools through one SDK.
31
+ - **Async and batch workflows**. Create scraping tasks, poll statuses, and process batches at scale.
32
+ - **Typed errors**. Handle authentication, validation, timeout, and rate-limit failures safely.
33
+ - **Minimal setup**. Uses native `fetch`, no additional HTTP client required.
34
+
35
+ ## Requirements
36
+
37
+ - Node.js 18+ (for native `fetch`)
38
+ - TypeScript 5.0+ (recommended for best type inference)
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install --save @decodo/sdk-ts
44
+ ```
45
+
46
+ ## Quick start
47
+
48
+ Create a new project:
49
+
50
+ ```sh
51
+ mkdir scrape-with-decodo
52
+ cd scrape-with-decodo
53
+
54
+ npm init -y
55
+ npm install --save @decodo/sdk-ts
56
+
57
+ touch main.js
58
+ ```
59
+
60
+ <details>
61
+ <summary>Optional: prevent module type warning</summary>
62
+ Run the following script to switch to ESM modules:
63
+ <br />
64
+
65
+ ```sh
66
+ node -e "let p=require('./package.json'); p.type='module'; require('fs').writeFileSync('./package.json', JSON.stringify(p, null, 2))"
67
+ ```
68
+
69
+ </details>
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:
72
+
73
+ ```typescript
74
+ // main.js
75
+ import { DecodoClient, Target } from '@decodo/sdk-ts';
76
+
77
+ const client = new DecodoClient({
78
+ webScrapingApi: {
79
+ token: '<basic_auth_token>',
80
+ },
81
+ });
82
+
83
+ const result = await client.webScrapingApi.scrape({
84
+ target: Target.GoogleSearch,
85
+ query: 'coffee shops',
86
+ geo: 'United States',
87
+ parse: true,
88
+ });
89
+ console.log(JSON.stringify(result, null, 2));
90
+ ```
91
+
92
+ Run the script:
93
+
94
+ ```
95
+ node main.js
96
+ ```
97
+
98
+ <details>
99
+ <summary>Example response</summary>
100
+
101
+ ```json
102
+ {
103
+ "results": [
104
+ {
105
+ "content": {
106
+ "results": {
107
+ "last_visible_page": 10,
108
+ "page": 1,
109
+ "parse_status_code": 12000,
110
+ "results": {
111
+ "local_pack": [
112
+ {
113
+ "items": [
114
+ {
115
+ "address": "Rochester, NY",
116
+ "paid": false,
117
+ "pos": 1,
118
+ "rating": 4.9,
119
+ "rating_count": 1700,
120
+ "subtitle": "Coffee shop",
121
+ "title": "Albunn Coffee House"
122
+ },
123
+ {
124
+ "address": "Rochester, NY",
125
+ "paid": false,
126
+ "pos": 2,
127
+ "rating": 4.8,
128
+ "rating_count": 937,
129
+ "subtitle": "Coffee shop",
130
+ "title": "Layali Coffee House"
131
+ },
132
+ {
133
+ "address": "Ocean Township, NJ",
134
+ "paid": false,
135
+ "pos": 3,
136
+ "rating": 4.9,
137
+ "rating_count": 124,
138
+ "subtitle": "Coffee shop",
139
+ "title": "Ocean Brew Co."
140
+ }
141
+ ],
142
+ "pos_overall": 1
143
+ }
144
+ ],
145
+ "navigation": [
146
+ {
147
+ "pos": 1,
148
+ "title": "AI Mode",
149
+ "url": "/search?q=coffee+shops&sca_esv=525e608177515078&hl=en&gl=us&udm=50&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&aep=1&ntc=1&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ2J8OegQIEhAD"
150
+ },
151
+ {
152
+ "pos": 2,
153
+ "title": "All"
154
+ },
155
+ {
156
+ "pos": 3,
157
+ "title": "Shopping",
158
+ "url": "/search?sca_esv=525e608177515078&hl=en&gl=us&udm=28&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&q=coffee+shops&ved=1t:220175&ictx=111"
159
+ },
160
+ {
161
+ "pos": 4,
162
+ "title": "Maps",
163
+ "url": "https://maps.google.com/maps?sca_esv=525e608177515078&hl=en&gl=us&output=search&q=coffee+shops&source=lnms&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&entry=mc&ved=1t:200715&ictx=111"
164
+ },
165
+ {
166
+ "pos": 5,
167
+ "title": "Images",
168
+ "url": "/search?sca_esv=525e608177515078&hl=en&gl=us&udm=2&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&q=coffee+shops&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQtKgLegQIFhAB"
169
+ },
170
+ {
171
+ "pos": 6,
172
+ "title": "Short videos",
173
+ "url": "/search?sca_esv=525e608177515078&hl=en&gl=us&udm=39&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&q=coffee+shops&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQs6gLegQIFxAB"
174
+ },
175
+ {
176
+ "pos": 7,
177
+ "title": "Videos",
178
+ "url": "/search?sca_esv=525e608177515078&hl=en&gl=us&udm=7&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&q=coffee+shops&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQtKgLegQIGBAB"
179
+ },
180
+ {
181
+ "pos": 8,
182
+ "title": "Forums",
183
+ "url": "/search?sca_esv=525e608177515078&hl=en&gl=us&udm=18&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&q=coffee+shops&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQs6gLegUIuQEQAQ"
184
+ },
185
+ {
186
+ "pos": 9,
187
+ "title": "News",
188
+ "url": "/search?sca_esv=525e608177515078&hl=en&gl=us&q=coffee+shops&tbm=nws&source=lnms&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ0pQJegUItwEQAQ"
189
+ },
190
+ {
191
+ "pos": 10,
192
+ "title": "Web",
193
+ "url": "/search?sca_esv=525e608177515078&hl=en&gl=us&udm=web&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&q=coffee+shops&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQs6gLegUIugEQAQ"
194
+ },
195
+ {
196
+ "pos": 11,
197
+ "title": "Books",
198
+ "url": "/search?sca_esv=525e608177515078&hl=en&gl=us&q=coffee+shops&udm=36&source=lnms&fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKp9lEhFAN_4ain3HSNQWw-mOdEry7qMdvK9DVYTQhhmGPzdLibceP-axzNRyypn83aa9v77RK3nAyJbS7Ww3c5hEZ41MHuBwA1cj9fLdcvZl39JyX99GA6dTRuy8597fUa5gVhW6ji9TQaHsuXH4CUtx2nUSCgjR6EycjMi9JpkD60fmHj94qqvvZFpMtWVwcBzf9XLw&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ0pQJegUIuAEQAQ"
199
+ }
200
+ ],
201
+ "organic": [
202
+ {
203
+ "desc": "For an alternate, local view, Eater has an interesting list of what it considers Philadelphia's 21 Essential Coffee Shops. Header image: Penn's Landing and ...Read more",
204
+ "favicon_text": "Brian's Coffee Spot",
205
+ "pos": 1,
206
+ "pos_overall": 2,
207
+ "title": "Philadelphia",
208
+ "url": "https://www.brian-coffee-spot.com/the-coffee-spot-guide-to/usa-canada/philadelphia/",
209
+ "url_shown": "https://www.brian-coffee-spot.com› usa-canada › phila..."
210
+ },
211
+ {
212
+ "desc": "Which Pittsburgh coffee shops are worth your time? Our ever-expanding guide gets to the bottom of that question.Read more",
213
+ "favicon_text": "Discover the Burgh",
214
+ "pos": 2,
215
+ "pos_overall": 3,
216
+ "title": "48 Pittsburgh Coffee Shops to Grab a Delicious Brew",
217
+ "url": "https://www.discovertheburgh.com/pittsburgh-coffee-shops/",
218
+ "url_shown": "https://www.discovertheburgh.com› ... › Coffee"
219
+ },
220
+ {
221
+ "desc": "Sep 29, 2016 — Best Coffee Shops in Atlanta · Octane · Dancing Goats Coffee Bar · Chrome Yellow Trading Co. · Revelator Coffee Company. Brash isn't the only ...Read more",
222
+ "favicon_text": "ATL Bucket List",
223
+ "pos": 3,
224
+ "pos_overall": 4,
225
+ "title": "Best Coffee Shops in Atlanta",
226
+ "url": "https://www.atlbucketlist.com/2016/09/29/best-coffee-shops-in-atlanta/",
227
+ "url_shown": "https://www.atlbucketlist.com› Food & Drink"
228
+ },
229
+ {
230
+ "desc": "Atticus Coffee & Gifts (222 N Howard St, Spokane, WA // 509.747.0336) There is a lot to love about downtown's Atticus. Firstly, it's one of the most ...Read more",
231
+ "favicon_text": "Spokane Eats",
232
+ "pos": 4,
233
+ "pos_overall": 6,
234
+ "title": "BEST COFFEE IN SPOKANE",
235
+ "url": "https://spokaneeats.net/best-coffee-in-spokane/",
236
+ "url_shown": "https://spokaneeats.net› Blog"
237
+ },
238
+ {
239
+ "desc": "Tucson has many excellent coffee shops including Exo Roast Co., Ren Coffeehouse, Presta Coffee Roasters and Ombre Coffee.",
240
+ "favicon_text": "Globalphile",
241
+ "pos": 5,
242
+ "pos_overall": 7,
243
+ "title": "The Best Coffee Shops in Tucson, AZ",
244
+ "url": "https://globalphile.com/the-best-coffee-shops-in-tucson-az/",
245
+ "url_shown": "https://globalphile.com› the-best-coffee-shops-in-tucson..."
246
+ },
247
+ {
248
+ "desc": "Oct 30, 2025 — The Best Coffee Shops in Orange County, California: A Local's Guide · Brot Coffee Co. · Daydream Surf Shop – Newport Beach · Hidden House Coffee ...Read more",
249
+ "favicon_text": "Lauren Belzer",
250
+ "pos": 6,
251
+ "pos_overall": 8,
252
+ "title": "The Best Coffee Shops in Orange County, California",
253
+ "url": "https://laurenbelz.com/best-coffee-orange-county/",
254
+ "url_shown": "https://laurenbelz.com› best-coffee-orange-county"
255
+ },
256
+ {
257
+ "desc": "Sep 11, 2024 — Writer Gene Kahane names his top five favorite local coffee shops around the island of Alameda, including LazyBird and The Local.",
258
+ "favicon_text": "Alameda Post",
259
+ "pos": 7,
260
+ "pos_overall": 9,
261
+ "title": "Five Favorite Coffee Shops",
262
+ "url": "https://alamedapost.com/features/alameda-life/five-favorite-coffee-shops/",
263
+ "url_shown": "https://alamedapost.com› Features › Alameda Life"
264
+ },
265
+ {
266
+ "desc": "Jun 24, 2025 — 1. Royal Flamingo Coffee -> I Like It Like That · 2. Roosevelt Coffeehouse -> Olentangy River Brewing Company · 3. Ravello's Coffee -> The Daily ...Read more",
267
+ "favicon_text": "Breakfast With Nick",
268
+ "pos": 8,
269
+ "pos_overall": 10,
270
+ "title": "Columbus' Best Coffee Shops in Bars",
271
+ "url": "https://breakfastwithnick.com/2025/06/24/the-best-coffee-shops-in-bars-columbus-ohio/",
272
+ "url_shown": "https://breakfastwithnick.com› 2025/06/24 › the-best-c..."
273
+ }
274
+ ],
275
+ "paid": [],
276
+ "related_searches": [
277
+ {
278
+ "pos_overall": 11,
279
+ "related_searches": [
280
+ "Best coffee shops",
281
+ "Coffee shops Pittsburgh",
282
+ "Coffee shops Strip District",
283
+ "Coffee shops Philadelphia",
284
+ "Coffee shops downtown Pittsburgh",
285
+ "Best coffee shops Pittsburgh",
286
+ "Best coffee shops in Philadelphia for working",
287
+ "Coffee Shops Sewickley"
288
+ ],
289
+ "related_searches_urls": [
290
+ "https://www.google.com/search?sca_esv=525e608177515078&hl=en&gl=us&q=Best+coffee+shops&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ1QJ6BAg1EAE",
291
+ "https://www.google.com/search?sca_esv=525e608177515078&hl=en&gl=us&q=Coffee+shops+Pittsburgh&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ1QJ6BAg8EAE",
292
+ "https://www.google.com/search?sca_esv=525e608177515078&hl=en&gl=us&q=Coffee+shops+Strip+District&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ1QJ6BAg_EAE",
293
+ "https://www.google.com/search?sca_esv=525e608177515078&hl=en&gl=us&q=Coffee+shops+Philadelphia&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ1QJ6BAhBEAE",
294
+ "https://www.google.com/search?sca_esv=525e608177515078&hl=en&gl=us&q=Coffee+shops+downtown+Pittsburgh&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ1QJ6BAg-EAE",
295
+ "https://www.google.com/search?sca_esv=525e608177515078&hl=en&gl=us&q=Best+coffee+shops+Pittsburgh&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ1QJ6BAg6EAE",
296
+ "https://www.google.com/search?sca_esv=525e608177515078&hl=en&gl=us&q=Best+coffee+shops+in+Philadelphia+for+working&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ1QJ6BAg7EAE",
297
+ "https://www.google.com/search?sca_esv=525e608177515078&hl=en&gl=us&q=Coffee+Shops+Sewickley&sa=X&ved=2ahUKEwiq0P6Xv8yUAxUPNvsDHaaIEQsQ1QJ6BAg5EAE"
298
+ ]
299
+ }
300
+ ],
301
+ "search_information": {
302
+ "no_results_for_original_query_found": false,
303
+ "query": "coffee shops",
304
+ "showing_results_for": "coffee shops",
305
+ "time_taken_displayed": null,
306
+ "total_results_count": 403000000
307
+ },
308
+ "total_results_count": 403000000,
309
+ "what_people_are_saying": {
310
+ "items": [
311
+ {
312
+ "engagement_timeframe": "2 reactions, 3 days ago",
313
+ "pos": 1,
314
+ "source": "Facebook",
315
+ "title": "Will be working in Frederick every Monday for the foreseeable future (driving from Westminster)...what's your fave coffee shop in the area?",
316
+ "url": "https://www.facebook.com/groups/366748512662939/posts/968510169153434/"
317
+ },
318
+ {
319
+ "engagement_timeframe": "90+ comments, 18 hours ago",
320
+ "pos": 2,
321
+ "source": "Reddit",
322
+ "title": "Portland coffee roaster scoops up another empty Starbucks cafe",
323
+ "url": "https://www.reddit.com/r/Portland/comments/1tjmv4s/portland_coffee_roaster_scoops_up_another_empty/"
324
+ },
325
+ {
326
+ "engagement_timeframe": "1.5M+ views, 1 week ago",
327
+ "pos": 3,
328
+ "source": "Los Angeles",
329
+ "title": "Auntie Nid Coffee Shop 🇹🇭 aka ร้านป้านิดปากแดง กาแฟโบราณ (Pa Nid Pak Daeng Kafaeboran) #auntienidcoffeeshop #auntienid",
330
+ "url": "https://www.tiktok.com/@janiedevours/video/7640013933008440606"
331
+ }
332
+ ],
333
+ "pos_overall": 5
334
+ }
335
+ },
336
+ "url": "https://www.google.com/search?q=coffee+shops&hl=en&gl=us"
337
+ },
338
+ "errors": [],
339
+ "status_code": 12000,
340
+ "task_id": "7463508496927950850"
341
+ },
342
+ "headers": {},
343
+ "status_code": 200,
344
+ "url": "https://www.google.com/search?q=coffee+shops&hl=en&gl=us",
345
+ "query": "coffee shops",
346
+ "task_id": "7463508496927950850",
347
+ "created_at": "2026-05-22 08:38:10",
348
+ "updated_at": "2026-05-22 08:38:13"
349
+ }
350
+ ]
351
+ }
352
+ ```
353
+
354
+ </details>
355
+
356
+ ## Configuration
357
+
358
+ ```typescript
359
+ const client = new DecodoClient({
360
+ webScrapingApi: {
361
+ token: '<basic_auth_token>',
362
+ },
363
+ timeoutMs: 120_000, // optional, request timeout in ms (default: 180s)
364
+ });
365
+ ```
366
+
367
+ | Parameter | Description |
368
+ | --- | --- |
369
+ | `token` | Web Scraping API basic authentication token |
370
+ | `timeoutMs` | Request timeout in milliseconds (default: 180000) |
371
+
372
+ ## Web Scraping API
373
+
374
+ Access the API via `client.webScrapingApi`.
375
+
376
+ The snippets below assume you have already imported `Target` (and `DecodoClient` where a client is constructed), for example:
377
+
378
+ ```typescript
379
+ import { DecodoClient, Target } from '@decodo/sdk-ts';
380
+ ```
381
+
382
+ ### Sync scrape
383
+
384
+ Waits for the scraping result before returning:
385
+
386
+ ```typescript
387
+ const result = await client.webScrapingApi.scrape({
388
+ target: Target.AmazonProduct,
389
+ query: 'B09H74FXNW',
390
+ parse: true,
391
+ });
392
+ ```
393
+
394
+ ### Async scrape
395
+
396
+ Creates a scraping task and returns immediately. Poll separately for task status and results:
397
+
398
+ ```typescript
399
+ const task = await client.webScrapingApi.scrapeAsync({
400
+ target: Target.GoogleSearch,
401
+ query: 'laptop reviews',
402
+ parse: true,
403
+ });
404
+
405
+ const meta = await client.webScrapingApi.getStatus(task.id);
406
+ console.log(meta.status); // 'pending' | 'done' | 'faulted'
407
+
408
+ const results = await client.webScrapingApi.getResults(task.id);
409
+ ```
410
+
411
+ ### Batch scrape
412
+
413
+ Send multiple queries or URLs in a single request:
414
+
415
+ ```typescript
416
+ const batch = await client.webScrapingApi.scrapeBatch({
417
+ target: Target.GoogleSearch,
418
+ query: ['coffee', 'tea', 'juice'],
419
+ parse: true,
420
+ });
421
+
422
+ const coffeeTaskId = batch.queries[0].id;
423
+
424
+ await client.webScrapingApi.getResults(coffeeTaskId);
425
+ ```
426
+
427
+ ## Supported targets
428
+
429
+ Each target accepts one primary input parameter (`url`, `query`, `product_id`, or `prompt`) together with optional configuration. The examples below show the minimum payload to call `client.webScrapingApi.scrape(...)`.
430
+
431
+ ### Search engines
432
+
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" }` |
441
+
442
+ ### eCommerce
443
+
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" }` |
452
+
453
+ ### Social media
454
+
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/..." }` |
462
+
463
+ ### AI tools
464
+
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.GoogleAiMode` | Google AI Mode response | `{ target: Target.GoogleAiMode, query: "What are the top three dog breeds?" }` |
470
+
471
+ ### Universal scraping
472
+
473
+ | Target | Description | Example |
474
+ | --- | --- | --- |
475
+ | `Target.Universal` | Any URL via the universal scraper | `{ target: Target.Universal, url: "https://example.com" }` |
476
+ | `Target.Google` | Raw Google URL scraping | `{ target: Target.Google, url: "https://google.com/search?q=laptop" }` |
477
+ | `Target.Amazon` | Raw Amazon URL scraping | `{ target: Target.Amazon, url: "https://amazon.com/dp/B09H74FXNW" }` |
478
+
479
+ > `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`.
480
+
481
+ For the full target list and parameter details, see the API documentation:
482
+
483
+ - [Target list](https://help.decodo.com/docs/web-scraping-api-targets)
484
+ - [Parameters](https://help.decodo.com/docs/web-scraping-api-parameters)
485
+
486
+ ## Error handling
487
+
488
+ The SDK throws typed errors that map to API error codes:
489
+
490
+ ```typescript
491
+ import {
492
+ DecodoError,
493
+ AuthenticationError,
494
+ RateLimitError,
495
+ ValidationError,
496
+ TimeoutError,
497
+ Target,
498
+ } from '@decodo/sdk-ts';
499
+
500
+ try {
501
+ await client.webScrapingApi.scrape({
502
+ target: Target.GoogleSearch,
503
+ query: 'test',
504
+ parse: true,
505
+ });
506
+ } catch (err) {
507
+ if (err instanceof AuthenticationError) {
508
+ // 401/403 — bad credentials
509
+ } else if (err instanceof RateLimitError) {
510
+ // 429 — too many requests
511
+ } else if (err instanceof ValidationError) {
512
+ // 422 — invalid parameters
513
+ console.log(err.errors);
514
+ } else if (err instanceof TimeoutError) {
515
+ // request timed out
516
+ }
517
+ }
518
+ ```
519
+
520
+ ## Related repositories
521
+
522
+ - [Web Scraping API](https://github.com/Decodo/Web-Scraping-API)
523
+ - [Decodo MCP Server](https://github.com/Decodo/mcp-server)
524
+ - [Decodo OpenClaw Skill](https://github.com/Decodo/decodo-openclaw-skill)
525
+
526
+ ## Get started
527
+
528
+ Build scraping workflows with the Decodo Web Scraping API:
529
+
530
+ - [Start free plan](https://dashboard.decodo.com/)
531
+ - [Documentation](https://help.decodo.com/docs/introduction)
532
+ - [Discord](https://discord.gg/Ja8dqKgvbZ)
533
+
534
+ ## License
535
+
536
+ Released under the [MIT License](https://github.com/Decodo/Decodo/blob/master/LICENSE).
package/package.json CHANGED
@@ -1,58 +1,49 @@
1
1
  {
2
2
  "name": "@decodo/sdk-ts",
3
- "version": "1.2.0",
4
- "description": "",
3
+ "version": "2.0.1",
4
+ "description": "Official TypeScript SDK for the Decodo APIs",
5
5
  "type": "module",
6
- "main": "lib/cjs/index.js",
7
- "module": "lib/esm/index.js",
8
- "types": "lib/types/index.d.ts",
6
+ "main": "./build/cjs/index.cjs",
7
+ "module": "./build/esm/index.js",
8
+ "types": "./build/esm/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./build/esm/index.d.ts",
13
+ "default": "./build/esm/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./build/cjs/index.d.cts",
17
+ "default": "./build/cjs/index.cjs"
18
+ }
19
+ }
20
+ },
9
21
  "files": [
10
- "lib/*",
11
- "CHANGELOG.md",
12
- "README.md"
22
+ "build"
13
23
  ],
14
24
  "scripts": {
15
- "build": "npm run lint && rm -rf lib && rollup -c",
16
- "lint": "npm run lint:es && npm run lint:ts",
17
- "lint:es": "eslint .",
18
- "lint:ts": "tsc --noEmit",
19
- "test": "echo \"No tests specified\" && exit 0"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/Decodo/sdk-ts.git"
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": "tsc -p tsconfig.build.cjs.json",
29
+ "typecheck": "tsc --noEmit",
30
+ "lint": "eslint .",
31
+ "lint:fix": "eslint . --fix"
24
32
  },
25
- "keywords": [],
26
- "author": "",
27
- "license": "ISC",
28
- "bugs": {
29
- "url": "https://github.com/Decodo/sdk/issues"
30
- },
31
- "homepage": "https://github.com/Decodo/sdk#readme",
32
- "dependencies": {
33
- "rollup": "^4.45.1",
34
- "typescript": "^5.8.3"
33
+ "engines": {
34
+ "node": ">=18.0.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/preset-typescript": "^7.27.1",
38
- "@rollup/plugin-babel": "^6.0.4",
39
- "@rollup/plugin-json": "^6.1.0",
40
- "@rollup/plugin-node-resolve": "^16.0.1",
41
- "@rollup/plugin-typescript": "^12.1.4",
42
- "@semantic-release/changelog": "^6.0.3",
43
- "@semantic-release/git": "^10.0.1",
44
- "@semantic-release/github": "^11.0.0",
45
- "@semantic-release/npm": "^12.0.1",
46
- "@typescript-eslint/eslint-plugin": "^8.38.0",
47
- "eslint": "^8.0.0",
48
- "rollup-plugin-dts": "^6.2.1",
49
- "semantic-release": "^24.0.0",
50
- "tslib": "^2.8.1"
51
- },
52
- "publishConfig": {
53
- "access": "public"
37
+ "@eslint/js": "^9.39.1",
38
+ "@types/json-schema": "^7.0.15",
39
+ "@types/node": "^25.7.0",
40
+ "eslint": "^9.39.1",
41
+ "tsx": "^4.19.0",
42
+ "typescript": "^5.3.3",
43
+ "typescript-eslint": "^8.40.0"
54
44
  },
55
- "engines": {
56
- "node": ">=22"
45
+ "dependencies": {
46
+ "json-schema-to-typescript": "^15.0.4",
47
+ "zod": "^4"
57
48
  }
58
49
  }