scrapebadger 0.64.1 → 0.66.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.js CHANGED
@@ -9,7 +9,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
  var WebSocket__default = /*#__PURE__*/_interopDefault(WebSocket);
10
10
 
11
11
  // src/internal/version.ts
12
- var SDK_VERSION = "0.64.1";
12
+ var SDK_VERSION = "0.65.0";
13
13
 
14
14
  // src/internal/exceptions.ts
15
15
  var ScrapeBadgerError = class _ScrapeBadgerError extends Error {
@@ -213,7 +213,7 @@ var BaseClient = class _BaseClient {
213
213
  };
214
214
  }
215
215
  /**
216
- * Make an HTTP request and return both data and rate limit headers.
216
+ * Make an HTTP request and return the data with its rate limit, status and headers.
217
217
  */
218
218
  async requestWithHeaders(path, options = {}) {
219
219
  return this.requestRaw(path, options);
@@ -276,7 +276,7 @@ var BaseClient = class _BaseClient {
276
276
  }
277
277
  const data = await this.handleResponse(httpResponse);
278
278
  const rateLimit = this.parseRateLimitHeaders(httpResponse.headers);
279
- return { data, rateLimit };
279
+ return { data, rateLimit, status: httpResponse.status, headers: httpResponse.headers };
280
280
  } catch (error) {
281
281
  lastError = error;
282
282
  if (!_BaseClient.isRetryable(error)) {
@@ -3884,10 +3884,10 @@ var SearchClient3 = class {
3884
3884
  async posts(options) {
3885
3885
  return this.client.request("/v1/reddit/search/posts", {
3886
3886
  params: {
3887
- query: options.query,
3887
+ q: options.query,
3888
3888
  subreddit: options.subreddit,
3889
3889
  sort: options.sort,
3890
- time: options.time,
3890
+ t: options.time,
3891
3891
  after: options.after,
3892
3892
  limit: options.limit
3893
3893
  }
@@ -3918,7 +3918,7 @@ var SearchClient3 = class {
3918
3918
  async subreddits(options) {
3919
3919
  return this.client.request("/v1/reddit/search/subreddits", {
3920
3920
  params: {
3921
- query: options.query,
3921
+ q: options.query,
3922
3922
  after: options.after,
3923
3923
  limit: options.limit
3924
3924
  }
@@ -3949,7 +3949,7 @@ var SearchClient3 = class {
3949
3949
  async users(options) {
3950
3950
  return this.client.request("/v1/reddit/search/users", {
3951
3951
  params: {
3952
- query: options.query,
3952
+ q: options.query,
3953
3953
  after: options.after,
3954
3954
  limit: options.limit
3955
3955
  }
@@ -3986,7 +3986,7 @@ var SearchClient3 = class {
3986
3986
  params: {
3987
3987
  domain: options.domain,
3988
3988
  sort: options.sort,
3989
- time: options.time,
3989
+ t: options.time,
3990
3990
  after: options.after,
3991
3991
  limit: options.limit
3992
3992
  }
@@ -4985,6 +4985,112 @@ var AccountClient = class {
4985
4985
  }
4986
4986
  };
4987
4987
 
4988
+ // src/agent/client.ts
4989
+ var AgentClient = class {
4990
+ constructor(client) {
4991
+ this.client = client;
4992
+ }
4993
+ /**
4994
+ * Quote a call: its cost, whether its parameters are valid, and its latency.
4995
+ * Free: nothing runs and nothing is charged.
4996
+ *
4997
+ * @param method - HTTP method of the call to quote.
4998
+ * @param path - Path of the call, e.g. "/v1/google/search" (the "/v1" prefix is optional).
4999
+ * @param options - The call's query `params` and JSON `body`.
5000
+ * @throws NotFoundError - No such endpoint.
5001
+ */
5002
+ async quote(method, path, options = {}) {
5003
+ return this.client.request("/v1/quote", {
5004
+ method: "POST",
5005
+ body: { method, path, params: options.params, body: options.body }
5006
+ });
5007
+ }
5008
+ /**
5009
+ * Send feedback (an API or field you needed and couldn't find) or a bug
5010
+ * report. Free, never billed; rate limited per key (429 when over the limit).
5011
+ *
5012
+ * @param summary - One-line summary, 3-200 characters.
5013
+ * @param options - `type` ("feedback" default, or "bug"), `details`, `requestId`, `endpoint`, `contact`.
5014
+ */
5015
+ async feedback(summary, options = {}) {
5016
+ return this.client.request("/v1/feedback", {
5017
+ method: "POST",
5018
+ body: {
5019
+ type: options.type ?? "feedback",
5020
+ summary,
5021
+ details: options.details,
5022
+ request_id: options.requestId,
5023
+ endpoint: options.endpoint,
5024
+ contact: options.contact
5025
+ }
5026
+ });
5027
+ }
5028
+ /**
5029
+ * Report a bug: a wrong or empty result for valid input, a misleading error,
5030
+ * or a price mismatch. Same as `feedback(summary, { ...options, type: "bug" })`.
5031
+ *
5032
+ * @param summary - One-line summary, 3-200 characters.
5033
+ * @param options - `details`, `requestId` (the failing call's X-Request-ID), `endpoint`, `contact`.
5034
+ */
5035
+ async reportBug(summary, options = {}) {
5036
+ return this.feedback(summary, { ...options, type: "bug" });
5037
+ }
5038
+ };
5039
+ var ResultsClient = class {
5040
+ constructor(client) {
5041
+ this.client = client;
5042
+ }
5043
+ /**
5044
+ * Replay a recent result, optionally trimmed. Free.
5045
+ *
5046
+ * @param resultId - `X-Result-ID` of the original call.
5047
+ * @param options - `jq`, `fields`, `maxItems`, `summary` view params.
5048
+ * @returns The original response body, reshaped — any JSON value.
5049
+ * @throws NotFoundError - Unknown result, or it expired (~15 minutes).
5050
+ */
5051
+ async get(resultId, options = {}) {
5052
+ const { jq, fields, maxItems, summary } = options;
5053
+ return this.client.request(`/v1/results/${encodeURIComponent(resultId)}`, {
5054
+ params: {
5055
+ jq,
5056
+ fields: Array.isArray(fields) ? fields.join(",") : fields,
5057
+ max_items: maxItems,
5058
+ summary: summary ? true : void 0
5059
+ }
5060
+ });
5061
+ }
5062
+ };
5063
+ var RequestsClient = class {
5064
+ constructor(client) {
5065
+ this.client = client;
5066
+ }
5067
+ /**
5068
+ * Poll an async request. Free.
5069
+ *
5070
+ * @param requestId - `request_id` from the 202 response.
5071
+ * @returns `running: true` while in progress; once done, `data` is the original body.
5072
+ * @throws NotFoundError - Unknown or expired request (one that never completed was not billed).
5073
+ * @throws ScrapeBadgerError - The original call finished with an error status (as the matching subclass).
5074
+ */
5075
+ async get(requestId) {
5076
+ const { data, status, headers } = await this.client.requestWithHeaders(
5077
+ `/v1/requests/${encodeURIComponent(requestId)}`
5078
+ );
5079
+ const running = status === 202;
5080
+ const retryAfter = running ? data?.retry_after_seconds : void 0;
5081
+ const credits = headers?.get("X-Credits-Used");
5082
+ return {
5083
+ requestId,
5084
+ running,
5085
+ status: status ?? 200,
5086
+ retryAfterSeconds: retryAfter ?? null,
5087
+ resultId: headers?.get("X-Result-ID") ?? null,
5088
+ creditsUsed: credits && /^\d+$/.test(credits) ? Number(credits) : null,
5089
+ data
5090
+ };
5091
+ }
5092
+ };
5093
+
4988
5094
  // src/airbnb/client.ts
4989
5095
  var AirbnbClient = class {
4990
5096
  client;
@@ -9305,7 +9411,7 @@ var PropertiesClient2 = class {
9305
9411
  };
9306
9412
 
9307
9413
  // src/zillow/agent.ts
9308
- var AgentClient = class {
9414
+ var AgentClient2 = class {
9309
9415
  client;
9310
9416
  constructor(client) {
9311
9417
  this.client = client;
@@ -9363,7 +9469,7 @@ var ZillowClient = class {
9363
9469
  this._gen = client;
9364
9470
  this.search = new SearchClient18(client);
9365
9471
  this.properties = new PropertiesClient2(client);
9366
- this.agent = new AgentClient(client);
9472
+ this.agent = new AgentClient2(client);
9367
9473
  this.reference = new ReferenceClient14(client);
9368
9474
  }
9369
9475
  // --- BEGIN generated by sdk/codegen/facade — do not edit ---
@@ -10412,6 +10518,12 @@ var ScrapeBadger = class {
10412
10518
  /** Amazon scraper API client — 14 endpoints */
10413
10519
  /** Account API client. (Generated from the OpenAPI spec.) */
10414
10520
  account;
10521
+ /** Quote a call before making it, and report bugs or send feedback. Free. */
10522
+ agent;
10523
+ /** Re-read a recent result (`X-Result-ID`) for free, optionally trimmed. */
10524
+ results;
10525
+ /** Poll a call made with `Prefer: respond-async`. Free. */
10526
+ requests;
10415
10527
  /** Airbnb API client. (Generated from the OpenAPI spec.) */
10416
10528
  airbnb;
10417
10529
  /** Aliexpress API client. (Generated from the OpenAPI spec.) */
@@ -10520,6 +10632,9 @@ var ScrapeBadger = class {
10520
10632
  this.instagram = new InstagramClient(this.baseClient);
10521
10633
  this.redfin = new RedfinClient(this.baseClient);
10522
10634
  this.account = new AccountClient(this.baseClient);
10635
+ this.agent = new AgentClient(this.baseClient);
10636
+ this.results = new ResultsClient(this.baseClient);
10637
+ this.requests = new RequestsClient(this.baseClient);
10523
10638
  this.airbnb = new AirbnbClient(this.baseClient);
10524
10639
  this.aliexpress = new AliexpressClient(this.baseClient);
10525
10640
  this.amazon = new AmazonClient(this.baseClient);
@@ -10555,6 +10670,7 @@ var ScrapeBadger = class {
10555
10670
  };
10556
10671
 
10557
10672
  exports.AccountRestrictedError = AccountRestrictedError;
10673
+ exports.AgentClient = AgentClient;
10558
10674
  exports.AmazonClient = AmazonClient;
10559
10675
  exports.AmazonListingsClient = ListingsClient;
10560
10676
  exports.AmazonProductsClient = ProductsClient2;
@@ -10656,6 +10772,8 @@ exports.RedditSearchClient = SearchClient3;
10656
10772
  exports.RedditSubredditsClient = SubredditsClient;
10657
10773
  exports.RedditUsersClient = UsersClient3;
10658
10774
  exports.RedfinClient = RedfinClient;
10775
+ exports.RequestsClient = RequestsClient;
10776
+ exports.ResultsClient = ResultsClient;
10659
10777
  exports.ScrapeBadger = ScrapeBadger;
10660
10778
  exports.ScrapeBadgerError = ScrapeBadgerError;
10661
10779
  exports.ServerError = ServerError;
@@ -10714,7 +10832,7 @@ exports.YoutubeSearchClient = SearchClient15;
10714
10832
  exports.YoutubeShortsClient = ShortsClient2;
10715
10833
  exports.YoutubeTrendingClient = TrendingClient2;
10716
10834
  exports.YoutubeVideosClient = VideosClient3;
10717
- exports.ZillowAgentClient = AgentClient;
10835
+ exports.ZillowAgentClient = AgentClient2;
10718
10836
  exports.ZillowClient = ZillowClient;
10719
10837
  exports.ZillowPropertiesClient = PropertiesClient2;
10720
10838
  exports.ZillowReferenceClient = ReferenceClient14;