scrapebadger 0.64.1 → 0.65.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.mjs CHANGED
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import WebSocket from 'ws';
4
4
 
5
5
  // src/internal/version.ts
6
- var SDK_VERSION = "0.64.1";
6
+ var SDK_VERSION = "0.65.0";
7
7
 
8
8
  // src/internal/exceptions.ts
9
9
  var ScrapeBadgerError = class _ScrapeBadgerError extends Error {
@@ -207,7 +207,7 @@ var BaseClient = class _BaseClient {
207
207
  };
208
208
  }
209
209
  /**
210
- * Make an HTTP request and return both data and rate limit headers.
210
+ * Make an HTTP request and return the data with its rate limit, status and headers.
211
211
  */
212
212
  async requestWithHeaders(path, options = {}) {
213
213
  return this.requestRaw(path, options);
@@ -270,7 +270,7 @@ var BaseClient = class _BaseClient {
270
270
  }
271
271
  const data = await this.handleResponse(httpResponse);
272
272
  const rateLimit = this.parseRateLimitHeaders(httpResponse.headers);
273
- return { data, rateLimit };
273
+ return { data, rateLimit, status: httpResponse.status, headers: httpResponse.headers };
274
274
  } catch (error) {
275
275
  lastError = error;
276
276
  if (!_BaseClient.isRetryable(error)) {
@@ -4979,6 +4979,112 @@ var AccountClient = class {
4979
4979
  }
4980
4980
  };
4981
4981
 
4982
+ // src/agent/client.ts
4983
+ var AgentClient = class {
4984
+ constructor(client) {
4985
+ this.client = client;
4986
+ }
4987
+ /**
4988
+ * Quote a call: its cost, whether its parameters are valid, and its latency.
4989
+ * Free: nothing runs and nothing is charged.
4990
+ *
4991
+ * @param method - HTTP method of the call to quote.
4992
+ * @param path - Path of the call, e.g. "/v1/google/search" (the "/v1" prefix is optional).
4993
+ * @param options - The call's query `params` and JSON `body`.
4994
+ * @throws NotFoundError - No such endpoint.
4995
+ */
4996
+ async quote(method, path, options = {}) {
4997
+ return this.client.request("/v1/quote", {
4998
+ method: "POST",
4999
+ body: { method, path, params: options.params, body: options.body }
5000
+ });
5001
+ }
5002
+ /**
5003
+ * Send feedback (an API or field you needed and couldn't find) or a bug
5004
+ * report. Free, never billed; rate limited per key (429 when over the limit).
5005
+ *
5006
+ * @param summary - One-line summary, 3-200 characters.
5007
+ * @param options - `type` ("feedback" default, or "bug"), `details`, `requestId`, `endpoint`, `contact`.
5008
+ */
5009
+ async feedback(summary, options = {}) {
5010
+ return this.client.request("/v1/feedback", {
5011
+ method: "POST",
5012
+ body: {
5013
+ type: options.type ?? "feedback",
5014
+ summary,
5015
+ details: options.details,
5016
+ request_id: options.requestId,
5017
+ endpoint: options.endpoint,
5018
+ contact: options.contact
5019
+ }
5020
+ });
5021
+ }
5022
+ /**
5023
+ * Report a bug: a wrong or empty result for valid input, a misleading error,
5024
+ * or a price mismatch. Same as `feedback(summary, { ...options, type: "bug" })`.
5025
+ *
5026
+ * @param summary - One-line summary, 3-200 characters.
5027
+ * @param options - `details`, `requestId` (the failing call's X-Request-ID), `endpoint`, `contact`.
5028
+ */
5029
+ async reportBug(summary, options = {}) {
5030
+ return this.feedback(summary, { ...options, type: "bug" });
5031
+ }
5032
+ };
5033
+ var ResultsClient = class {
5034
+ constructor(client) {
5035
+ this.client = client;
5036
+ }
5037
+ /**
5038
+ * Replay a recent result, optionally trimmed. Free.
5039
+ *
5040
+ * @param resultId - `X-Result-ID` of the original call.
5041
+ * @param options - `jq`, `fields`, `maxItems`, `summary` view params.
5042
+ * @returns The original response body, reshaped — any JSON value.
5043
+ * @throws NotFoundError - Unknown result, or it expired (~15 minutes).
5044
+ */
5045
+ async get(resultId, options = {}) {
5046
+ const { jq, fields, maxItems, summary } = options;
5047
+ return this.client.request(`/v1/results/${encodeURIComponent(resultId)}`, {
5048
+ params: {
5049
+ jq,
5050
+ fields: Array.isArray(fields) ? fields.join(",") : fields,
5051
+ max_items: maxItems,
5052
+ summary: summary ? true : void 0
5053
+ }
5054
+ });
5055
+ }
5056
+ };
5057
+ var RequestsClient = class {
5058
+ constructor(client) {
5059
+ this.client = client;
5060
+ }
5061
+ /**
5062
+ * Poll an async request. Free.
5063
+ *
5064
+ * @param requestId - `request_id` from the 202 response.
5065
+ * @returns `running: true` while in progress; once done, `data` is the original body.
5066
+ * @throws NotFoundError - Unknown or expired request (one that never completed was not billed).
5067
+ * @throws ScrapeBadgerError - The original call finished with an error status (as the matching subclass).
5068
+ */
5069
+ async get(requestId) {
5070
+ const { data, status, headers } = await this.client.requestWithHeaders(
5071
+ `/v1/requests/${encodeURIComponent(requestId)}`
5072
+ );
5073
+ const running = status === 202;
5074
+ const retryAfter = running ? data?.retry_after_seconds : void 0;
5075
+ const credits = headers?.get("X-Credits-Used");
5076
+ return {
5077
+ requestId,
5078
+ running,
5079
+ status: status ?? 200,
5080
+ retryAfterSeconds: retryAfter ?? null,
5081
+ resultId: headers?.get("X-Result-ID") ?? null,
5082
+ creditsUsed: credits && /^\d+$/.test(credits) ? Number(credits) : null,
5083
+ data
5084
+ };
5085
+ }
5086
+ };
5087
+
4982
5088
  // src/airbnb/client.ts
4983
5089
  var AirbnbClient = class {
4984
5090
  client;
@@ -9299,7 +9405,7 @@ var PropertiesClient2 = class {
9299
9405
  };
9300
9406
 
9301
9407
  // src/zillow/agent.ts
9302
- var AgentClient = class {
9408
+ var AgentClient2 = class {
9303
9409
  client;
9304
9410
  constructor(client) {
9305
9411
  this.client = client;
@@ -9357,7 +9463,7 @@ var ZillowClient = class {
9357
9463
  this._gen = client;
9358
9464
  this.search = new SearchClient18(client);
9359
9465
  this.properties = new PropertiesClient2(client);
9360
- this.agent = new AgentClient(client);
9466
+ this.agent = new AgentClient2(client);
9361
9467
  this.reference = new ReferenceClient14(client);
9362
9468
  }
9363
9469
  // --- BEGIN generated by sdk/codegen/facade — do not edit ---
@@ -10406,6 +10512,12 @@ var ScrapeBadger = class {
10406
10512
  /** Amazon scraper API client — 14 endpoints */
10407
10513
  /** Account API client. (Generated from the OpenAPI spec.) */
10408
10514
  account;
10515
+ /** Quote a call before making it, and report bugs or send feedback. Free. */
10516
+ agent;
10517
+ /** Re-read a recent result (`X-Result-ID`) for free, optionally trimmed. */
10518
+ results;
10519
+ /** Poll a call made with `Prefer: respond-async`. Free. */
10520
+ requests;
10409
10521
  /** Airbnb API client. (Generated from the OpenAPI spec.) */
10410
10522
  airbnb;
10411
10523
  /** Aliexpress API client. (Generated from the OpenAPI spec.) */
@@ -10514,6 +10626,9 @@ var ScrapeBadger = class {
10514
10626
  this.instagram = new InstagramClient(this.baseClient);
10515
10627
  this.redfin = new RedfinClient(this.baseClient);
10516
10628
  this.account = new AccountClient(this.baseClient);
10629
+ this.agent = new AgentClient(this.baseClient);
10630
+ this.results = new ResultsClient(this.baseClient);
10631
+ this.requests = new RequestsClient(this.baseClient);
10517
10632
  this.airbnb = new AirbnbClient(this.baseClient);
10518
10633
  this.aliexpress = new AliexpressClient(this.baseClient);
10519
10634
  this.amazon = new AmazonClient(this.baseClient);
@@ -10548,6 +10663,6 @@ var ScrapeBadger = class {
10548
10663
  }
10549
10664
  };
10550
10665
 
10551
- export { AccountRestrictedError, AmazonClient, ListingsClient as AmazonListingsClient, ProductsClient2 as AmazonProductsClient, ReferenceClient2 as AmazonReferenceClient, SearchClient5 as AmazonSearchClient, SellersClient as AmazonSellersClient, ApartmentsClient, AuthenticationError, BaiduClient, BingClient, MediaClient3 as BingMediaClient, NewsClient2 as BingNewsClient, ReferenceClient8 as BingReferenceClient, SearchClient11 as BingSearchClient, BlockedError, AskClient as ChatGPTAskClient, BrandClient as ChatGPTBrandClient, ChatGPTClient, ReferenceClient16 as ChatGPTReferenceClient, CommunitiesClient, ConflictError, DepopClient, DuckDuckGoClient, MediaClient2 as DuckDuckGoMediaClient, ReferenceClient7 as DuckDuckGoReferenceClient, SearchClient10 as DuckDuckGoSearchClient, CategoriesClient as EbayCategoriesClient, EbayClient, ItemsClient2 as EbayItemsClient, ReferenceClient5 as EbayReferenceClient, SearchClient8 as EbaySearchClient, SellersClient2 as EbaySellersClient, AskClient2 as GeminiAskClient, BrandClient2 as GeminiBrandClient, GeminiClient, GeoClient, AdsClient as GoogleAdsClient, AiModeClient as GoogleAiModeClient, AutocompleteClient as GoogleAutocompleteClient, GoogleClient, FinanceClient as GoogleFinanceClient, FlightsClient as GoogleFlightsClient, HotelsClient as GoogleHotelsClient, ImagesClient as GoogleImagesClient, JobsClient as GoogleJobsClient, LensClient as GoogleLensClient, MapsClient as GoogleMapsClient, NewsClient as GoogleNewsClient, PatentsClient as GooglePatentsClient, ProductsClient as GoogleProductsClient, ScholarClient as GoogleScholarClient, SearchClient2 as GoogleSearchClient, ShoppingClient as GoogleShoppingClient, ShortsClient as GoogleShortsClient, TrendsClient2 as GoogleTrendsClient, VideosClient as GoogleVideosClient, GumtreeClient, IPNotAllowedError, ImmobiliareClient, AudioClient as InstagramAudioClient, InstagramClient, HashtagsClient as InstagramHashtagsClient, LocationsClient as InstagramLocationsClient, MediaClient as InstagramMediaClient, SearchClient4 as InstagramSearchClient, UsersClient4 as InstagramUsersClient, InsufficientCreditsError, AdsClient3 as LeboncoinAdsClient, LeboncoinClient, ReferenceClient13 as LeboncoinReferenceClient, SearchClient17 as LeboncoinSearchClient, SellersClient4 as LeboncoinSellersClient, LinkedInClient, ListsClient, BrokersClient as LoopNetBrokersClient, LoopNetClient, ListingsClient2 as LoopNetListingsClient, ReferenceClient15 as LoopNetReferenceClient, SearchClient19 as LoopNetSearchClient, NaverClient, ContentClient as NaverContentClient, PlacesClient as NaverPlacesClient, ProductsClient5 as NaverProductsClient, ReviewsClient2 as NaverReviewsClient, SearchClient12 as NaverSearchClient, ShoppingClient2 as NaverShoppingClient, ShoppingLiveClient as NaverShoppingLiveClient, StoresClient2 as NaverStoresClient, NotFoundError, PermissionDeniedError, RateLimitError, RealtorClient, PropertiesClient as RealtorPropertiesClient, ReferenceClient12 as RealtorReferenceClient, SearchClient16 as RealtorSearchClient, RedditClient, PostsClient as RedditPostsClient, SearchClient3 as RedditSearchClient, SubredditsClient as RedditSubredditsClient, UsersClient3 as RedditUsersClient, RedfinClient, ScrapeBadger, ScrapeBadgerError, ServerError, ShopeeClient, ProductsClient3 as ShopeeProductsClient, ReferenceClient3 as ShopeeReferenceClient, ReviewsClient as ShopeeReviewsClient, SearchClient6 as ShopeeSearchClient, SpacesClient, StreamClient, AdsClient2 as TikTokAdsClient, TikTokClient, HashtagsClient2 as TikTokHashtagsClient, MusicClient as TikTokMusicClient, ReferenceClient4 as TikTokReferenceClient, SearchClient7 as TikTokSearchClient, TrendingClient as TikTokTrendingClient, UsersClient5 as TikTokUsersClient, VideosClient2 as TikTokVideosClient, TimeoutError, TrendsClient, TweetsClient, TwitterClient, UsersClient, ValidationError, VintedClient, ItemsClient as VintedItemsClient, ReferenceClient as VintedReferenceClient, SearchClient as VintedSearchClient, UsersClient2 as VintedUsersClient, WallapopClient, WalmartClient, ProductsClient4 as WalmartProductsClient, ReferenceClient6 as WalmartReferenceClient, SearchClient9 as WalmartSearchClient, SellersClient3 as WalmartSellersClient, StoresClient as WalmartStoresClient, WebClient, WebSocketStreamError, YahooClient, MediaClient4 as YahooMediaClient, NewsClient3 as YahooNewsClient, ReferenceClient9 as YahooReferenceClient, SearchClient13 as YahooSearchClient, YandexClient, ImagesClient2 as YandexImagesClient, ReferenceClient10 as YandexReferenceClient, SearchClient14 as YandexSearchClient, ChannelsClient as YoutubeChannelsClient, YoutubeClient, CommunityClient as YoutubeCommunityClient, MusicClient2 as YoutubeMusicClient, PlaylistsClient as YoutubePlaylistsClient, ReferenceClient11 as YoutubeReferenceClient, SearchClient15 as YoutubeSearchClient, ShortsClient2 as YoutubeShortsClient, TrendingClient2 as YoutubeTrendingClient, VideosClient3 as YoutubeVideosClient, AgentClient as ZillowAgentClient, ZillowClient, PropertiesClient2 as ZillowPropertiesClient, ReferenceClient14 as ZillowReferenceClient, SearchClient18 as ZillowSearchClient, collectAll, verifyWebhookSignature };
10666
+ export { AccountRestrictedError, AgentClient, AmazonClient, ListingsClient as AmazonListingsClient, ProductsClient2 as AmazonProductsClient, ReferenceClient2 as AmazonReferenceClient, SearchClient5 as AmazonSearchClient, SellersClient as AmazonSellersClient, ApartmentsClient, AuthenticationError, BaiduClient, BingClient, MediaClient3 as BingMediaClient, NewsClient2 as BingNewsClient, ReferenceClient8 as BingReferenceClient, SearchClient11 as BingSearchClient, BlockedError, AskClient as ChatGPTAskClient, BrandClient as ChatGPTBrandClient, ChatGPTClient, ReferenceClient16 as ChatGPTReferenceClient, CommunitiesClient, ConflictError, DepopClient, DuckDuckGoClient, MediaClient2 as DuckDuckGoMediaClient, ReferenceClient7 as DuckDuckGoReferenceClient, SearchClient10 as DuckDuckGoSearchClient, CategoriesClient as EbayCategoriesClient, EbayClient, ItemsClient2 as EbayItemsClient, ReferenceClient5 as EbayReferenceClient, SearchClient8 as EbaySearchClient, SellersClient2 as EbaySellersClient, AskClient2 as GeminiAskClient, BrandClient2 as GeminiBrandClient, GeminiClient, GeoClient, AdsClient as GoogleAdsClient, AiModeClient as GoogleAiModeClient, AutocompleteClient as GoogleAutocompleteClient, GoogleClient, FinanceClient as GoogleFinanceClient, FlightsClient as GoogleFlightsClient, HotelsClient as GoogleHotelsClient, ImagesClient as GoogleImagesClient, JobsClient as GoogleJobsClient, LensClient as GoogleLensClient, MapsClient as GoogleMapsClient, NewsClient as GoogleNewsClient, PatentsClient as GooglePatentsClient, ProductsClient as GoogleProductsClient, ScholarClient as GoogleScholarClient, SearchClient2 as GoogleSearchClient, ShoppingClient as GoogleShoppingClient, ShortsClient as GoogleShortsClient, TrendsClient2 as GoogleTrendsClient, VideosClient as GoogleVideosClient, GumtreeClient, IPNotAllowedError, ImmobiliareClient, AudioClient as InstagramAudioClient, InstagramClient, HashtagsClient as InstagramHashtagsClient, LocationsClient as InstagramLocationsClient, MediaClient as InstagramMediaClient, SearchClient4 as InstagramSearchClient, UsersClient4 as InstagramUsersClient, InsufficientCreditsError, AdsClient3 as LeboncoinAdsClient, LeboncoinClient, ReferenceClient13 as LeboncoinReferenceClient, SearchClient17 as LeboncoinSearchClient, SellersClient4 as LeboncoinSellersClient, LinkedInClient, ListsClient, BrokersClient as LoopNetBrokersClient, LoopNetClient, ListingsClient2 as LoopNetListingsClient, ReferenceClient15 as LoopNetReferenceClient, SearchClient19 as LoopNetSearchClient, NaverClient, ContentClient as NaverContentClient, PlacesClient as NaverPlacesClient, ProductsClient5 as NaverProductsClient, ReviewsClient2 as NaverReviewsClient, SearchClient12 as NaverSearchClient, ShoppingClient2 as NaverShoppingClient, ShoppingLiveClient as NaverShoppingLiveClient, StoresClient2 as NaverStoresClient, NotFoundError, PermissionDeniedError, RateLimitError, RealtorClient, PropertiesClient as RealtorPropertiesClient, ReferenceClient12 as RealtorReferenceClient, SearchClient16 as RealtorSearchClient, RedditClient, PostsClient as RedditPostsClient, SearchClient3 as RedditSearchClient, SubredditsClient as RedditSubredditsClient, UsersClient3 as RedditUsersClient, RedfinClient, RequestsClient, ResultsClient, ScrapeBadger, ScrapeBadgerError, ServerError, ShopeeClient, ProductsClient3 as ShopeeProductsClient, ReferenceClient3 as ShopeeReferenceClient, ReviewsClient as ShopeeReviewsClient, SearchClient6 as ShopeeSearchClient, SpacesClient, StreamClient, AdsClient2 as TikTokAdsClient, TikTokClient, HashtagsClient2 as TikTokHashtagsClient, MusicClient as TikTokMusicClient, ReferenceClient4 as TikTokReferenceClient, SearchClient7 as TikTokSearchClient, TrendingClient as TikTokTrendingClient, UsersClient5 as TikTokUsersClient, VideosClient2 as TikTokVideosClient, TimeoutError, TrendsClient, TweetsClient, TwitterClient, UsersClient, ValidationError, VintedClient, ItemsClient as VintedItemsClient, ReferenceClient as VintedReferenceClient, SearchClient as VintedSearchClient, UsersClient2 as VintedUsersClient, WallapopClient, WalmartClient, ProductsClient4 as WalmartProductsClient, ReferenceClient6 as WalmartReferenceClient, SearchClient9 as WalmartSearchClient, SellersClient3 as WalmartSellersClient, StoresClient as WalmartStoresClient, WebClient, WebSocketStreamError, YahooClient, MediaClient4 as YahooMediaClient, NewsClient3 as YahooNewsClient, ReferenceClient9 as YahooReferenceClient, SearchClient13 as YahooSearchClient, YandexClient, ImagesClient2 as YandexImagesClient, ReferenceClient10 as YandexReferenceClient, SearchClient14 as YandexSearchClient, ChannelsClient as YoutubeChannelsClient, YoutubeClient, CommunityClient as YoutubeCommunityClient, MusicClient2 as YoutubeMusicClient, PlaylistsClient as YoutubePlaylistsClient, ReferenceClient11 as YoutubeReferenceClient, SearchClient15 as YoutubeSearchClient, ShortsClient2 as YoutubeShortsClient, TrendingClient2 as YoutubeTrendingClient, VideosClient3 as YoutubeVideosClient, AgentClient2 as ZillowAgentClient, ZillowClient, PropertiesClient2 as ZillowPropertiesClient, ReferenceClient14 as ZillowReferenceClient, SearchClient18 as ZillowSearchClient, collectAll, verifyWebhookSignature };
10552
10667
  //# sourceMappingURL=index.mjs.map
10553
10668
  //# sourceMappingURL=index.mjs.map