@decodo/sdk-ts 2.6.1 → 3.0.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 +31 -25
- package/build/cjs/index.cjs +31 -565
- package/build/cjs/index.d.cts +147 -155
- package/build/esm/api/web-scraping-api.d.ts +3 -2
- package/build/esm/api/web-scraping-api.js +21 -0
- package/build/esm/generated/data-api.d.ts +156 -0
- package/build/esm/generated/parameters.js +3 -13
- package/build/esm/generated/request-schemas.d.ts +0 -427
- package/build/esm/generated/request-schemas.js +0 -478
- package/build/esm/generated/targets.d.ts +1 -144
- package/build/esm/generated/targets.js +1 -73
- package/build/esm/http.js +1 -1
- package/build/esm/index.d.ts +2 -2
- package/build/esm/types/requests.d.ts +3 -0
- package/build/esm/types/responses.d.ts +8 -2
- package/package.json +17 -13
package/build/cjs/index.d.cts
CHANGED
|
@@ -31,35 +31,26 @@ declare class HttpClient {
|
|
|
31
31
|
* Scrape target discriminator (wire string values).
|
|
32
32
|
*/
|
|
33
33
|
export declare enum Target {
|
|
34
|
-
UniversalEcommerce = "universal_ecommerce",
|
|
35
34
|
GoogleSearch = "google_search",
|
|
36
35
|
GoogleTravelHotels = "google_travel_hotels",
|
|
37
|
-
GoogleTrendsExplore = "google_trends_explore",
|
|
38
|
-
GoogleShoppingSearch = "google_shopping_search",
|
|
39
|
-
GoogleShoppingProduct = "google_shopping_product",
|
|
40
36
|
Google = "google",
|
|
41
|
-
GoogleSuggest = "google_suggest",
|
|
42
|
-
GoogleMaps = "google_maps",
|
|
43
37
|
GoogleAiMode = "google_ai_mode",
|
|
44
38
|
GoogleAds = "google_ads",
|
|
45
39
|
GoogleLens = "google_lens",
|
|
46
40
|
BingSearch = "bing_search",
|
|
47
41
|
Bing = "bing",
|
|
48
|
-
YoutubeTranscript = "youtube_transcript",
|
|
49
42
|
AmazonProduct = "amazon_product",
|
|
50
43
|
AmazonPricing = "amazon_pricing",
|
|
51
44
|
AmazonSearch = "amazon_search",
|
|
52
45
|
AmazonSellers = "amazon_sellers",
|
|
53
46
|
AmazonBestsellers = "amazon_bestsellers",
|
|
54
47
|
Amazon = "amazon",
|
|
55
|
-
Ecommerce = "ecommerce",
|
|
56
48
|
WalmartProduct = "walmart_product",
|
|
57
49
|
WalmartSearch = "walmart_search",
|
|
58
50
|
Walmart = "walmart",
|
|
59
51
|
TargetProduct = "target_product",
|
|
60
52
|
TargetSearch = "target_search",
|
|
61
53
|
Target = "target",
|
|
62
|
-
LowesSearch = "lowes_search",
|
|
63
54
|
Universal = "universal",
|
|
64
55
|
Chatgpt = "chatgpt",
|
|
65
56
|
Perplexity = "perplexity",
|
|
@@ -69,7 +60,6 @@ export declare enum Target {
|
|
|
69
60
|
Mobile = "mobile",
|
|
70
61
|
Airbnb = "airbnb",
|
|
71
62
|
AppleAppStore = "apple_app_store",
|
|
72
|
-
InstagramGraphqlProfile = "instagram_graphql_profile",
|
|
73
63
|
TiktokPost = "tiktok_post",
|
|
74
64
|
TiktokShopSearch = "tiktok_shop_search",
|
|
75
65
|
TiktokShopProduct = "tiktok_shop_product",
|
|
@@ -77,45 +67,34 @@ export declare enum Target {
|
|
|
77
67
|
RedditPost = "reddit_post",
|
|
78
68
|
RedditSubreddit = "reddit_subreddit",
|
|
79
69
|
RedditUser = "reddit_user",
|
|
80
|
-
YoutubeVideo = "youtube_video",
|
|
81
70
|
YoutubeMetadata = "youtube_metadata",
|
|
82
71
|
YoutubeSearch = "youtube_search",
|
|
83
|
-
YoutubeSearchMax = "youtube_search_max",
|
|
84
72
|
YoutubeSubtitles = "youtube_subtitles",
|
|
85
73
|
YoutubeChannel = "youtube_channel"
|
|
86
74
|
}
|
|
87
75
|
/** API discriminator string literals (same values as {@link Target}). */
|
|
88
76
|
export type TargetString = (typeof Target)[keyof typeof Target];
|
|
89
77
|
export declare const targets: readonly [
|
|
90
|
-
Target.UniversalEcommerce,
|
|
91
78
|
Target.GoogleSearch,
|
|
92
79
|
Target.GoogleTravelHotels,
|
|
93
|
-
Target.GoogleTrendsExplore,
|
|
94
|
-
Target.GoogleShoppingSearch,
|
|
95
|
-
Target.GoogleShoppingProduct,
|
|
96
80
|
Target.Google,
|
|
97
|
-
Target.GoogleSuggest,
|
|
98
|
-
Target.GoogleMaps,
|
|
99
81
|
Target.GoogleAiMode,
|
|
100
82
|
Target.GoogleAds,
|
|
101
83
|
Target.GoogleLens,
|
|
102
84
|
Target.BingSearch,
|
|
103
85
|
Target.Bing,
|
|
104
|
-
Target.YoutubeTranscript,
|
|
105
86
|
Target.AmazonProduct,
|
|
106
87
|
Target.AmazonPricing,
|
|
107
88
|
Target.AmazonSearch,
|
|
108
89
|
Target.AmazonSellers,
|
|
109
90
|
Target.AmazonBestsellers,
|
|
110
91
|
Target.Amazon,
|
|
111
|
-
Target.Ecommerce,
|
|
112
92
|
Target.WalmartProduct,
|
|
113
93
|
Target.WalmartSearch,
|
|
114
94
|
Target.Walmart,
|
|
115
95
|
Target.TargetProduct,
|
|
116
96
|
Target.TargetSearch,
|
|
117
97
|
Target.Target,
|
|
118
|
-
Target.LowesSearch,
|
|
119
98
|
Target.Universal,
|
|
120
99
|
Target.Chatgpt,
|
|
121
100
|
Target.Perplexity,
|
|
@@ -125,7 +104,6 @@ export declare const targets: readonly [
|
|
|
125
104
|
Target.Mobile,
|
|
126
105
|
Target.Airbnb,
|
|
127
106
|
Target.AppleAppStore,
|
|
128
|
-
Target.InstagramGraphqlProfile,
|
|
129
107
|
Target.TiktokPost,
|
|
130
108
|
Target.TiktokShopSearch,
|
|
131
109
|
Target.TiktokShopProduct,
|
|
@@ -133,16 +111,11 @@ export declare const targets: readonly [
|
|
|
133
111
|
Target.RedditPost,
|
|
134
112
|
Target.RedditSubreddit,
|
|
135
113
|
Target.RedditUser,
|
|
136
|
-
Target.YoutubeVideo,
|
|
137
114
|
Target.YoutubeMetadata,
|
|
138
115
|
Target.YoutubeSearch,
|
|
139
|
-
Target.YoutubeSearchMax,
|
|
140
116
|
Target.YoutubeSubtitles,
|
|
141
117
|
Target.YoutubeChannel
|
|
142
118
|
];
|
|
143
|
-
export interface UniversalEcommerceParams {
|
|
144
|
-
callback_url?: string;
|
|
145
|
-
}
|
|
146
119
|
export interface GoogleSearchParams {
|
|
147
120
|
query?: string;
|
|
148
121
|
headless?: "html" | "png";
|
|
@@ -176,43 +149,6 @@ export interface GoogleTravelHotelsParams {
|
|
|
176
149
|
markdown?: boolean;
|
|
177
150
|
callback_url?: string;
|
|
178
151
|
}
|
|
179
|
-
export interface GoogleTrendsExploreParams {
|
|
180
|
-
query?: string;
|
|
181
|
-
geo?: string;
|
|
182
|
-
device_type?: string;
|
|
183
|
-
search_type?: string;
|
|
184
|
-
date_start?: string;
|
|
185
|
-
date_end?: string;
|
|
186
|
-
callback_url?: string;
|
|
187
|
-
}
|
|
188
|
-
export interface GoogleShoppingSearchParams {
|
|
189
|
-
query?: string;
|
|
190
|
-
headless?: "html" | "png";
|
|
191
|
-
locale?: string;
|
|
192
|
-
geo?: string;
|
|
193
|
-
device_type?: string;
|
|
194
|
-
page_from?: number;
|
|
195
|
-
google_tbs?: string;
|
|
196
|
-
parse?: boolean;
|
|
197
|
-
session_id?: string;
|
|
198
|
-
google_results_language?: string;
|
|
199
|
-
markdown?: boolean;
|
|
200
|
-
callback_url?: string;
|
|
201
|
-
}
|
|
202
|
-
export interface GoogleShoppingProductParams {
|
|
203
|
-
query?: string;
|
|
204
|
-
headless?: "html" | "png";
|
|
205
|
-
locale?: string;
|
|
206
|
-
geo?: string;
|
|
207
|
-
device_type?: string;
|
|
208
|
-
page_from?: number;
|
|
209
|
-
parse?: boolean;
|
|
210
|
-
session_id?: string;
|
|
211
|
-
google_results_language?: string;
|
|
212
|
-
markdown?: boolean;
|
|
213
|
-
xhr?: boolean;
|
|
214
|
-
callback_url?: string;
|
|
215
|
-
}
|
|
216
152
|
export interface GoogleParams {
|
|
217
153
|
url?: string;
|
|
218
154
|
headless?: "html" | "png";
|
|
@@ -225,29 +161,6 @@ export interface GoogleParams {
|
|
|
225
161
|
page_count?: number;
|
|
226
162
|
callback_url?: string;
|
|
227
163
|
}
|
|
228
|
-
export interface GoogleSuggestParams {
|
|
229
|
-
query?: string;
|
|
230
|
-
device_type?: string;
|
|
231
|
-
geo?: string;
|
|
232
|
-
locale?: string;
|
|
233
|
-
session_id?: string;
|
|
234
|
-
callback_url?: string;
|
|
235
|
-
}
|
|
236
|
-
export interface GoogleMapsParams {
|
|
237
|
-
query?: string;
|
|
238
|
-
headless?: "html" | "png";
|
|
239
|
-
geo?: string;
|
|
240
|
-
locale?: string;
|
|
241
|
-
page_from?: number;
|
|
242
|
-
device_type?: string;
|
|
243
|
-
session_id?: string;
|
|
244
|
-
google_results_language?: string;
|
|
245
|
-
google_nfpr?: boolean;
|
|
246
|
-
hotel_occupancy?: string;
|
|
247
|
-
date_range?: string;
|
|
248
|
-
markdown?: boolean;
|
|
249
|
-
callback_url?: string;
|
|
250
|
-
}
|
|
251
164
|
export interface GoogleAiModeParams {
|
|
252
165
|
query?: string;
|
|
253
166
|
geo?: string;
|
|
@@ -312,12 +225,6 @@ export interface BingParams {
|
|
|
312
225
|
xhr?: boolean;
|
|
313
226
|
callback_url?: string;
|
|
314
227
|
}
|
|
315
|
-
export interface YoutubeTranscriptParams {
|
|
316
|
-
query?: string;
|
|
317
|
-
language_code?: string;
|
|
318
|
-
transcript_origin?: string;
|
|
319
|
-
callback_url?: string;
|
|
320
|
-
}
|
|
321
228
|
export interface AmazonProductParams {
|
|
322
229
|
query?: string;
|
|
323
230
|
headless?: "html" | "png";
|
|
@@ -400,16 +307,6 @@ export interface AmazonParams {
|
|
|
400
307
|
xhr?: boolean;
|
|
401
308
|
callback_url?: string;
|
|
402
309
|
}
|
|
403
|
-
export interface EcommerceParams {
|
|
404
|
-
url?: string;
|
|
405
|
-
headless?: "html" | "png";
|
|
406
|
-
locale?: string;
|
|
407
|
-
geo?: string;
|
|
408
|
-
device_type?: string;
|
|
409
|
-
parse?: boolean;
|
|
410
|
-
parser_type?: string;
|
|
411
|
-
callback_url?: string;
|
|
412
|
-
}
|
|
413
310
|
export interface WalmartProductParams {
|
|
414
311
|
product_id?: string;
|
|
415
312
|
headless?: "html" | "png";
|
|
@@ -475,17 +372,6 @@ export interface TargetParams {
|
|
|
475
372
|
target_store_id?: string;
|
|
476
373
|
callback_url?: string;
|
|
477
374
|
}
|
|
478
|
-
export interface LowesSearchParams {
|
|
479
|
-
query?: string;
|
|
480
|
-
lowes_store_id?: string;
|
|
481
|
-
headless?: "html" | "png";
|
|
482
|
-
delivery_zip?: string;
|
|
483
|
-
user_agent_type?: string;
|
|
484
|
-
free_delivery?: boolean;
|
|
485
|
-
pickup_today?: boolean;
|
|
486
|
-
delivery_today_tomorrow?: boolean;
|
|
487
|
-
callback_url?: string;
|
|
488
|
-
}
|
|
489
375
|
export interface UniversalParams {
|
|
490
376
|
url?: string;
|
|
491
377
|
payload?: string;
|
|
@@ -580,10 +466,6 @@ export interface AppleAppStoreParams {
|
|
|
580
466
|
xhr?: boolean;
|
|
581
467
|
callback_url?: string;
|
|
582
468
|
}
|
|
583
|
-
export interface InstagramGraphqlProfileParams {
|
|
584
|
-
query?: string;
|
|
585
|
-
callback_url?: string;
|
|
586
|
-
}
|
|
587
469
|
export interface TiktokPostParams {
|
|
588
470
|
url?: string;
|
|
589
471
|
xhr?: boolean;
|
|
@@ -631,11 +513,6 @@ export interface RedditUserParams {
|
|
|
631
513
|
sort?: string;
|
|
632
514
|
callback_url?: string;
|
|
633
515
|
}
|
|
634
|
-
export interface YoutubeVideoParams {
|
|
635
|
-
query?: string;
|
|
636
|
-
geo?: string;
|
|
637
|
-
callback_url?: string;
|
|
638
|
-
}
|
|
639
516
|
export interface YoutubeMetadataParams {
|
|
640
517
|
query?: string;
|
|
641
518
|
callback_url?: string;
|
|
@@ -659,26 +536,6 @@ export interface YoutubeSearchParams {
|
|
|
659
536
|
subtitles?: boolean;
|
|
660
537
|
callback_url?: string;
|
|
661
538
|
}
|
|
662
|
-
export interface YoutubeSearchMaxParams {
|
|
663
|
-
"360"?: boolean;
|
|
664
|
-
query?: string;
|
|
665
|
-
upload_date?: string;
|
|
666
|
-
type?: string;
|
|
667
|
-
duration?: string;
|
|
668
|
-
video_sort_by?: string;
|
|
669
|
-
"3d"?: boolean;
|
|
670
|
-
"4k"?: boolean;
|
|
671
|
-
creative_commons?: boolean;
|
|
672
|
-
hd?: boolean;
|
|
673
|
-
hdr?: boolean;
|
|
674
|
-
vr180?: boolean;
|
|
675
|
-
live?: boolean;
|
|
676
|
-
location?: boolean;
|
|
677
|
-
purchased?: boolean;
|
|
678
|
-
subtitles?: boolean;
|
|
679
|
-
markdown?: boolean;
|
|
680
|
-
callback_url?: string;
|
|
681
|
-
}
|
|
682
539
|
export interface YoutubeSubtitlesParams {
|
|
683
540
|
query?: string;
|
|
684
541
|
language_code?: string;
|
|
@@ -693,35 +550,26 @@ export interface YoutubeChannelParams {
|
|
|
693
550
|
callback_url?: string;
|
|
694
551
|
}
|
|
695
552
|
export type TargetParamsMap = {
|
|
696
|
-
[Target.UniversalEcommerce]: UniversalEcommerceParams;
|
|
697
553
|
[Target.GoogleSearch]: GoogleSearchParams;
|
|
698
554
|
[Target.GoogleTravelHotels]: GoogleTravelHotelsParams;
|
|
699
|
-
[Target.GoogleTrendsExplore]: GoogleTrendsExploreParams;
|
|
700
|
-
[Target.GoogleShoppingSearch]: GoogleShoppingSearchParams;
|
|
701
|
-
[Target.GoogleShoppingProduct]: GoogleShoppingProductParams;
|
|
702
555
|
[Target.Google]: GoogleParams;
|
|
703
|
-
[Target.GoogleSuggest]: GoogleSuggestParams;
|
|
704
|
-
[Target.GoogleMaps]: GoogleMapsParams;
|
|
705
556
|
[Target.GoogleAiMode]: GoogleAiModeParams;
|
|
706
557
|
[Target.GoogleAds]: GoogleAdsParams;
|
|
707
558
|
[Target.GoogleLens]: GoogleLensParams;
|
|
708
559
|
[Target.BingSearch]: BingSearchParams;
|
|
709
560
|
[Target.Bing]: BingParams;
|
|
710
|
-
[Target.YoutubeTranscript]: YoutubeTranscriptParams;
|
|
711
561
|
[Target.AmazonProduct]: AmazonProductParams;
|
|
712
562
|
[Target.AmazonPricing]: AmazonPricingParams;
|
|
713
563
|
[Target.AmazonSearch]: AmazonSearchParams;
|
|
714
564
|
[Target.AmazonSellers]: AmazonSellersParams;
|
|
715
565
|
[Target.AmazonBestsellers]: AmazonBestsellersParams;
|
|
716
566
|
[Target.Amazon]: AmazonParams;
|
|
717
|
-
[Target.Ecommerce]: EcommerceParams;
|
|
718
567
|
[Target.WalmartProduct]: WalmartProductParams;
|
|
719
568
|
[Target.WalmartSearch]: WalmartSearchParams;
|
|
720
569
|
[Target.Walmart]: WalmartParams;
|
|
721
570
|
[Target.TargetProduct]: TargetProductParams;
|
|
722
571
|
[Target.TargetSearch]: TargetSearchParams;
|
|
723
572
|
[Target.Target]: TargetParams;
|
|
724
|
-
[Target.LowesSearch]: LowesSearchParams;
|
|
725
573
|
[Target.Universal]: UniversalParams;
|
|
726
574
|
[Target.Chatgpt]: ChatgptParams;
|
|
727
575
|
[Target.Perplexity]: PerplexityParams;
|
|
@@ -731,7 +579,6 @@ export type TargetParamsMap = {
|
|
|
731
579
|
[Target.Mobile]: MobileParams;
|
|
732
580
|
[Target.Airbnb]: AirbnbParams;
|
|
733
581
|
[Target.AppleAppStore]: AppleAppStoreParams;
|
|
734
|
-
[Target.InstagramGraphqlProfile]: InstagramGraphqlProfileParams;
|
|
735
582
|
[Target.TiktokPost]: TiktokPostParams;
|
|
736
583
|
[Target.TiktokShopSearch]: TiktokShopSearchParams;
|
|
737
584
|
[Target.TiktokShopProduct]: TiktokShopProductParams;
|
|
@@ -739,10 +586,8 @@ export type TargetParamsMap = {
|
|
|
739
586
|
[Target.RedditPost]: RedditPostParams;
|
|
740
587
|
[Target.RedditSubreddit]: RedditSubredditParams;
|
|
741
588
|
[Target.RedditUser]: RedditUserParams;
|
|
742
|
-
[Target.YoutubeVideo]: YoutubeVideoParams;
|
|
743
589
|
[Target.YoutubeMetadata]: YoutubeMetadataParams;
|
|
744
590
|
[Target.YoutubeSearch]: YoutubeSearchParams;
|
|
745
|
-
[Target.YoutubeSearchMax]: YoutubeSearchMaxParams;
|
|
746
591
|
[Target.YoutubeSubtitles]: YoutubeSubtitlesParams;
|
|
747
592
|
[Target.YoutubeChannel]: YoutubeChannelParams;
|
|
748
593
|
};
|
|
@@ -777,6 +622,9 @@ export type DecodoSchema = {
|
|
|
777
622
|
getSharedParameters: () => Record<string, unknown>;
|
|
778
623
|
readonly version?: string;
|
|
779
624
|
};
|
|
625
|
+
/**
|
|
626
|
+
* Fields other than these are dropped before the upstream call.
|
|
627
|
+
*/
|
|
780
628
|
export interface RunSearchRequest {
|
|
781
629
|
query: string;
|
|
782
630
|
url?: string;
|
|
@@ -785,11 +633,20 @@ export interface RunSearchRequest {
|
|
|
785
633
|
geo?: string;
|
|
786
634
|
locale?: string;
|
|
787
635
|
input_encoding?: string;
|
|
636
|
+
/**
|
|
637
|
+
* Not checked to be an integer; forwarded as given.
|
|
638
|
+
*/
|
|
788
639
|
page?: number;
|
|
789
640
|
[k: string]: unknown;
|
|
790
641
|
}
|
|
791
642
|
export type RunSearchResponse = {
|
|
643
|
+
/**
|
|
644
|
+
* Set by the vendor, not by scraper-api. Failures arrive as ScrapeFailed or a 500 UpstreamError instead.
|
|
645
|
+
*/
|
|
792
646
|
status?: "done";
|
|
647
|
+
/**
|
|
648
|
+
* Observed as an empty string.
|
|
649
|
+
*/
|
|
793
650
|
url?: string;
|
|
794
651
|
organic?: {
|
|
795
652
|
link?: string;
|
|
@@ -800,10 +657,16 @@ export type RunSearchResponse = {
|
|
|
800
657
|
rank?: number;
|
|
801
658
|
[k: string]: unknown;
|
|
802
659
|
}[];
|
|
660
|
+
/**
|
|
661
|
+
* An array on the wire, empty when the query has no news; scraper-api's own type calls it an object.
|
|
662
|
+
*/
|
|
803
663
|
top_stories?: {
|
|
804
664
|
title?: string;
|
|
805
665
|
link?: string;
|
|
806
666
|
site?: string;
|
|
667
|
+
/**
|
|
668
|
+
* Relative age as the search engine shows it, for example 3 hours ago.
|
|
669
|
+
*/
|
|
807
670
|
ago?: string;
|
|
808
671
|
rank?: number;
|
|
809
672
|
[k: string]: unknown;
|
|
@@ -818,6 +681,9 @@ export type RunSearchResponse = {
|
|
|
818
681
|
link?: string;
|
|
819
682
|
[k: string]: unknown;
|
|
820
683
|
}[];
|
|
684
|
+
/**
|
|
685
|
+
* Observed empty; populated shape not seen.
|
|
686
|
+
*/
|
|
821
687
|
answer_box?: {
|
|
822
688
|
[k: string]: unknown;
|
|
823
689
|
};
|
|
@@ -837,7 +703,13 @@ export type RunSearchResponse = {
|
|
|
837
703
|
[k: string]: unknown;
|
|
838
704
|
};
|
|
839
705
|
export interface MapSiteRequest {
|
|
706
|
+
/**
|
|
707
|
+
* Absolute http or https URL to map.
|
|
708
|
+
*/
|
|
840
709
|
url: string;
|
|
710
|
+
/**
|
|
711
|
+
* Maximum links to return. Zero, negative or above 147700 all become 147700; nothing is rejected.
|
|
712
|
+
*/
|
|
841
713
|
limit?: number;
|
|
842
714
|
sitemap?: "include" | "only" | "skip";
|
|
843
715
|
domain_filter?: "domain" | "subdomain" | "all";
|
|
@@ -845,97 +717,208 @@ export interface MapSiteRequest {
|
|
|
845
717
|
locale?: string;
|
|
846
718
|
JS_rendering?: boolean;
|
|
847
719
|
follow_redirects?: boolean;
|
|
720
|
+
/**
|
|
721
|
+
* Either one pattern or a list of them. Each must compile as a Go regular expression.
|
|
722
|
+
*/
|
|
848
723
|
select_paths?: string | string[];
|
|
724
|
+
/**
|
|
725
|
+
* Either one pattern or a list of them. Each must compile as a Go regular expression.
|
|
726
|
+
*/
|
|
849
727
|
exclude_paths?: string | string[];
|
|
850
728
|
[k: string]: unknown;
|
|
851
729
|
}
|
|
852
730
|
export interface MapSiteResponse {
|
|
731
|
+
/**
|
|
732
|
+
* Always exactly one element.
|
|
733
|
+
*/
|
|
853
734
|
results: {
|
|
854
735
|
content: {
|
|
855
736
|
links: {
|
|
856
737
|
url: string;
|
|
857
738
|
}[];
|
|
858
739
|
};
|
|
740
|
+
/**
|
|
741
|
+
* Always 200. Not the status of the mapped site.
|
|
742
|
+
*/
|
|
859
743
|
status_code: number;
|
|
860
744
|
url: string;
|
|
861
745
|
sitemap_status: "include" | "only" | "skip";
|
|
862
746
|
map_id: string;
|
|
747
|
+
/**
|
|
748
|
+
* UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
|
|
749
|
+
*/
|
|
863
750
|
created_at: string;
|
|
751
|
+
/**
|
|
752
|
+
* UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
|
|
753
|
+
*/
|
|
864
754
|
updated_at: string;
|
|
865
755
|
}[];
|
|
866
756
|
}
|
|
867
757
|
export interface StartCrawlRequest {
|
|
758
|
+
/**
|
|
759
|
+
* An http or https URL with a host. URLs carrying credentials (user:pass@) are refused.
|
|
760
|
+
*/
|
|
868
761
|
url: string;
|
|
869
762
|
limit?: number;
|
|
870
763
|
max_depth?: number;
|
|
871
764
|
sitemap?: "include" | "only" | "skip";
|
|
872
765
|
domain_filter?: "domain" | "subdomain" | "all";
|
|
873
766
|
output?: "markdown" | "html";
|
|
767
|
+
/**
|
|
768
|
+
* Letters, spaces, dots, apostrophes and hyphens, 2 to 60 characters.
|
|
769
|
+
*/
|
|
874
770
|
geo?: string;
|
|
771
|
+
/**
|
|
772
|
+
* BCP 47 style, for example en or de-DE.
|
|
773
|
+
*/
|
|
875
774
|
locale?: string;
|
|
876
775
|
follow_redirects?: boolean;
|
|
877
776
|
JS_retry?: boolean;
|
|
777
|
+
/**
|
|
778
|
+
* Seconds. 0 means the server default. Rejected above the server's ceiling, 4 hours by default; the ceiling is configurable per environment.
|
|
779
|
+
*/
|
|
878
780
|
max_duration?: number;
|
|
781
|
+
/**
|
|
782
|
+
* http or https URL called when the crawl settles. Internal addresses are refused.
|
|
783
|
+
*/
|
|
879
784
|
callback_url?: string;
|
|
785
|
+
/**
|
|
786
|
+
* Opaque value echoed back on the callback, at most 8192 bytes. Redacted in logs.
|
|
787
|
+
*/
|
|
880
788
|
passthrough?: string;
|
|
789
|
+
/**
|
|
790
|
+
* Either one pattern or a list of them. Each must compile as a Go regular expression.
|
|
791
|
+
*/
|
|
881
792
|
select_paths?: string | string[];
|
|
793
|
+
/**
|
|
794
|
+
* Either one pattern or a list of them. Each must compile as a Go regular expression.
|
|
795
|
+
*/
|
|
882
796
|
exclude_paths?: string | string[];
|
|
883
797
|
[k: string]: unknown;
|
|
884
798
|
}
|
|
885
799
|
export interface StartCrawlResponse {
|
|
886
800
|
target: "crawl";
|
|
887
801
|
url: string;
|
|
802
|
+
/**
|
|
803
|
+
* UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
|
|
804
|
+
*/
|
|
888
805
|
created_at: string;
|
|
889
806
|
crawl_id: string;
|
|
890
807
|
status: "pending" | "done" | "faulted" | "cancelled" | "truncated";
|
|
808
|
+
/**
|
|
809
|
+
* Absolute URL of this crawl's status endpoint.
|
|
810
|
+
*/
|
|
891
811
|
crawl_status: string;
|
|
812
|
+
/**
|
|
813
|
+
* Absolute URL of the per-page metadata listing.
|
|
814
|
+
*/
|
|
892
815
|
results_tasks: string;
|
|
816
|
+
/**
|
|
817
|
+
* Absolute URL of the same listing with page content included.
|
|
818
|
+
*/
|
|
893
819
|
results_content: string;
|
|
894
820
|
}
|
|
895
821
|
export interface ListCrawlPagesResponse {
|
|
896
822
|
crawl_id: string;
|
|
823
|
+
/**
|
|
824
|
+
* The crawled pages. Named url, not results.
|
|
825
|
+
*/
|
|
897
826
|
url: {
|
|
898
827
|
task_id?: string;
|
|
899
828
|
status: "pending" | "done" | "faulted";
|
|
829
|
+
/**
|
|
830
|
+
* UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
|
|
831
|
+
*/
|
|
900
832
|
created_at: string;
|
|
833
|
+
/**
|
|
834
|
+
* UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
|
|
835
|
+
*/
|
|
901
836
|
updated_at: string;
|
|
902
837
|
url: string;
|
|
903
838
|
depth: number;
|
|
904
839
|
parent_url?: string;
|
|
905
840
|
result_key?: string;
|
|
841
|
+
/**
|
|
842
|
+
* Present only when type=content was requested.
|
|
843
|
+
*/
|
|
906
844
|
content?: string;
|
|
845
|
+
/**
|
|
846
|
+
* Why this page has no content, when fetching it failed.
|
|
847
|
+
*/
|
|
907
848
|
content_error?: string;
|
|
849
|
+
/**
|
|
850
|
+
* Absolute URL of this crawl's status endpoint.
|
|
851
|
+
*/
|
|
908
852
|
crawl_status: string;
|
|
853
|
+
/**
|
|
854
|
+
* Absolute URL of the per-page metadata listing.
|
|
855
|
+
*/
|
|
909
856
|
results_tasks: string;
|
|
857
|
+
/**
|
|
858
|
+
* Absolute URL of the same listing with page content included.
|
|
859
|
+
*/
|
|
910
860
|
results_content: string;
|
|
911
861
|
}[];
|
|
862
|
+
/**
|
|
863
|
+
* Absolute URL of the next page. Absent on the last page.
|
|
864
|
+
*/
|
|
912
865
|
next?: string;
|
|
866
|
+
/**
|
|
867
|
+
* Present only on the first page in content mode.
|
|
868
|
+
*/
|
|
913
869
|
total?: number;
|
|
914
870
|
}
|
|
915
871
|
export interface GetCrawlStatusResponse {
|
|
916
872
|
target: "crawl";
|
|
917
873
|
url: string;
|
|
874
|
+
/**
|
|
875
|
+
* UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
|
|
876
|
+
*/
|
|
918
877
|
created_at: string;
|
|
919
878
|
crawl_id: string;
|
|
920
879
|
status: "pending" | "done" | "faulted" | "cancelled" | "truncated";
|
|
880
|
+
/**
|
|
881
|
+
* Why the crawl stopped early. On truncated, max_duration is the deadline and vendor_limit means the vendor kept refusing the account's submissions, quota or request rate. On faulted, no_pages_found means the crawl found nothing to crawl, for example sitemap only on a site without a sitemap.
|
|
882
|
+
*/
|
|
921
883
|
reason?: "max_duration" | "vendor_limit" | "no_pages_found";
|
|
922
884
|
sitemap_status: "include" | "only" | "skip";
|
|
885
|
+
/**
|
|
886
|
+
* The format the crawl's pages are saved in.
|
|
887
|
+
*/
|
|
923
888
|
output: "markdown" | "html";
|
|
924
889
|
discovered: number;
|
|
925
890
|
completed: number;
|
|
926
891
|
failed: number;
|
|
927
892
|
in_flight: number;
|
|
893
|
+
/**
|
|
894
|
+
* Sitemap files fetched for this crawl, sitemap indexes included. 0 when sitemap is skip.
|
|
895
|
+
*/
|
|
928
896
|
sitemaps: number;
|
|
897
|
+
/**
|
|
898
|
+
* Scrape requests the vendor accepted for this crawl, the billed work. Counts pages, JavaScript retries and sitemap fetches; not results reads.
|
|
899
|
+
*/
|
|
929
900
|
requests: number;
|
|
930
901
|
}
|
|
931
902
|
export interface CancelCrawlResponse {
|
|
932
903
|
target: "crawl";
|
|
933
904
|
url: string;
|
|
905
|
+
/**
|
|
906
|
+
* UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
|
|
907
|
+
*/
|
|
934
908
|
created_at: string;
|
|
935
909
|
crawl_id: string;
|
|
936
910
|
status: "pending" | "done" | "faulted" | "cancelled" | "truncated";
|
|
911
|
+
/**
|
|
912
|
+
* Absolute URL of this crawl's status endpoint.
|
|
913
|
+
*/
|
|
937
914
|
crawl_status: string;
|
|
915
|
+
/**
|
|
916
|
+
* Absolute URL of the per-page metadata listing.
|
|
917
|
+
*/
|
|
938
918
|
results_tasks: string;
|
|
919
|
+
/**
|
|
920
|
+
* Absolute URL of the same listing with page content included.
|
|
921
|
+
*/
|
|
939
922
|
results_content: string;
|
|
940
923
|
}
|
|
941
924
|
declare const dataApiEndpoints: {
|
|
@@ -975,6 +958,9 @@ export type CrawlOptions = {
|
|
|
975
958
|
export type CrawlResultsOptions = {
|
|
976
959
|
content?: boolean;
|
|
977
960
|
};
|
|
961
|
+
export type CrawlPagesOptions = CrawlResultsOptions & {
|
|
962
|
+
cursor?: string;
|
|
963
|
+
};
|
|
978
964
|
export type ResultEntry = {
|
|
979
965
|
content: unknown;
|
|
980
966
|
status_code: number;
|
|
@@ -1033,6 +1019,11 @@ export type TaskResultsResponse = {
|
|
|
1033
1019
|
results: ResultEntry[];
|
|
1034
1020
|
};
|
|
1035
1021
|
export type CrawlPage = ListCrawlPagesResponse["url"][number];
|
|
1022
|
+
export type CrawlPageList = {
|
|
1023
|
+
pages: CrawlPage[];
|
|
1024
|
+
next?: string;
|
|
1025
|
+
total?: number;
|
|
1026
|
+
};
|
|
1036
1027
|
export type CrawlResult = {
|
|
1037
1028
|
status: GetCrawlStatusResponse;
|
|
1038
1029
|
pages: CrawlPage[];
|
|
@@ -1059,6 +1050,7 @@ export declare class WebScrapingApi {
|
|
|
1059
1050
|
map(params: MapSiteRequest): Promise<MapSiteResponse>;
|
|
1060
1051
|
startCrawl(params: StartCrawlRequest): Promise<StartCrawlResponse>;
|
|
1061
1052
|
getCrawlStatus(crawlId: string): Promise<GetCrawlStatusResponse>;
|
|
1053
|
+
listCrawlPages(crawlId: string, { cursor, content }?: CrawlPagesOptions): Promise<CrawlPageList>;
|
|
1062
1054
|
getCrawlResults(crawlId: string, { content }?: CrawlResultsOptions): Promise<CrawlPage[]>;
|
|
1063
1055
|
cancelCrawl(crawlId: string): Promise<CancelCrawlResponse>;
|
|
1064
1056
|
crawl(params: StartCrawlRequest, { pollInterval, timeout, }?: CrawlOptions): Promise<CrawlResult>;
|
|
@@ -3,8 +3,8 @@ import type { DecodoSchema } from '../schema/types.js';
|
|
|
3
3
|
import { dataApiEndpoints } from '../generated/data-api.js';
|
|
4
4
|
import type { CancelCrawlResponse, GetCrawlStatusResponse, MapSiteRequest, MapSiteResponse, RunSearchRequest, RunSearchResponse, StartCrawlRequest, StartCrawlResponse } from '../generated/data-api.js';
|
|
5
5
|
import type { ScrapeRequest, BatchRequest } from '../generated/targets.js';
|
|
6
|
-
import type { CrawlOptions, CrawlResultsOptions } from '../types/requests.js';
|
|
7
|
-
import type { CrawlPage, CrawlResult, SyncResponse, AsyncTaskResponse, BatchResponse, TaskMetadata, TaskResultsResponse } from '../types/responses.js';
|
|
6
|
+
import type { CrawlOptions, CrawlPagesOptions, CrawlResultsOptions } from '../types/requests.js';
|
|
7
|
+
import type { CrawlPage, CrawlPageList, CrawlResult, SyncResponse, AsyncTaskResponse, BatchResponse, TaskMetadata, TaskResultsResponse } from '../types/responses.js';
|
|
8
8
|
export type WebScrapingApiRoutes = {
|
|
9
9
|
scrape: string;
|
|
10
10
|
task: string;
|
|
@@ -29,6 +29,7 @@ export declare class WebScrapingApi {
|
|
|
29
29
|
map(params: MapSiteRequest): Promise<MapSiteResponse>;
|
|
30
30
|
startCrawl(params: StartCrawlRequest): Promise<StartCrawlResponse>;
|
|
31
31
|
getCrawlStatus(crawlId: string): Promise<GetCrawlStatusResponse>;
|
|
32
|
+
listCrawlPages(crawlId: string, { cursor, content }?: CrawlPagesOptions): Promise<CrawlPageList>;
|
|
32
33
|
getCrawlResults(crawlId: string, { content }?: CrawlResultsOptions): Promise<CrawlPage[]>;
|
|
33
34
|
cancelCrawl(crawlId: string): Promise<CancelCrawlResponse>;
|
|
34
35
|
crawl(params: StartCrawlRequest, { pollInterval, timeout, }?: CrawlOptions): Promise<CrawlResult>;
|
|
@@ -14,6 +14,16 @@ export const DATA_API_ROUTES = {
|
|
|
14
14
|
const DEFAULT_CRAWL_POLL_INTERVAL_MS = 5_000;
|
|
15
15
|
const DEFAULT_CRAWL_TIMEOUT_MS = 3_600_000;
|
|
16
16
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
17
|
+
const nextCursor = (next) => {
|
|
18
|
+
if (!next) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const cursor = new URL(next).searchParams.get('cursor');
|
|
22
|
+
if (!cursor) {
|
|
23
|
+
throw new Error(`Crawl results next link has no cursor: ${next}. Use getCrawlResults() to fetch every page.`);
|
|
24
|
+
}
|
|
25
|
+
return cursor;
|
|
26
|
+
};
|
|
17
27
|
export class WebScrapingApi {
|
|
18
28
|
http;
|
|
19
29
|
schemas;
|
|
@@ -72,6 +82,17 @@ export class WebScrapingApi {
|
|
|
72
82
|
async getCrawlStatus(crawlId) {
|
|
73
83
|
return this.http.get(this.crawlPath('getCrawlStatus', crawlId, 'getCrawlStatus'));
|
|
74
84
|
}
|
|
85
|
+
async listCrawlPages(crawlId, { cursor, content = true } = {}) {
|
|
86
|
+
const query = {};
|
|
87
|
+
if (content) {
|
|
88
|
+
query.type = 'content';
|
|
89
|
+
}
|
|
90
|
+
if (cursor) {
|
|
91
|
+
query.cursor = cursor;
|
|
92
|
+
}
|
|
93
|
+
const res = await this.http.get(this.crawlPath('listCrawlPages', crawlId, 'listCrawlPages'), query);
|
|
94
|
+
return { pages: res.url, next: nextCursor(res.next), total: res.total };
|
|
95
|
+
}
|
|
75
96
|
async getCrawlResults(crawlId, { content = true } = {}) {
|
|
76
97
|
const path = this.crawlPath('listCrawlPages', crawlId, 'getCrawlResults');
|
|
77
98
|
const pages = [];
|