scrapebadger 0.59.0 → 0.60.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.59.0";
12
+ var SDK_VERSION = "0.60.0";
13
13
 
14
14
  // src/internal/exceptions.ts
15
15
  var ScrapeBadgerError = class _ScrapeBadgerError extends Error {
@@ -6535,15 +6535,17 @@ var GumtreeClient = class {
6535
6535
  this.client = client;
6536
6536
  }
6537
6537
  /**
6538
- * Search gumtree.com listings.
6538
+ * Search Gumtree listings in the UK, Australia or South Africa.
6539
6539
  *
6540
6540
  * @param params - Optional query, category, location (+ distance radius),
6541
- * price, sort, seller type, urgent/photo flags, category-specific filters
6542
- * and page (1-50).
6543
- * @returns ~25-30 listings per page. Gumtree pins up to 5 paid featured ads
6544
- * (`is_featured`) above the chosen sort order.
6541
+ * price, sort, seller type, urgent/photo flags (uk only),
6542
+ * category-specific filters, page (1-50) and market.
6543
+ * @returns uk ~25-30 listings per page (Gumtree pins up to 5 paid featured
6544
+ * ads, `is_featured`, above the chosen sort order), au 24, za 20. Prices
6545
+ * are in `currency`.
6545
6546
  * @throws AuthenticationError - If the API key is invalid.
6546
- * @throws ValidationError - If the parameters are invalid.
6547
+ * @throws ValidationError - If the parameters are invalid, or not supported
6548
+ * by the market.
6547
6549
  */
6548
6550
  async search(params = {}) {
6549
6551
  return this.client.request("/v1/gumtree/search", {
@@ -6559,7 +6561,8 @@ var GumtreeClient = class {
6559
6561
  urgent_only: params.urgent_only,
6560
6562
  with_photos: params.with_photos,
6561
6563
  filters: params.filters,
6562
- page: params.page
6564
+ page: params.page,
6565
+ market: params.market
6563
6566
  }
6564
6567
  });
6565
6568
  }
@@ -6569,15 +6572,18 @@ var GumtreeClient = class {
6569
6572
  * Each filter lists its values with live result counts. Feed a `key` and a
6570
6573
  * `value` back into {@link search} as `filters: "key:value"`.
6571
6574
  *
6572
- * @param params - Optional category (default `"all"`), location (default
6573
- * `"uk"`) and query to scope the counts.
6575
+ * @param params - Optional category (default `"all"`), location (default:
6576
+ * the whole country), query to scope the counts, already-applied
6577
+ * `filters` (za only) and market.
6574
6578
  */
6575
6579
  async searchFilters(params = {}) {
6576
6580
  return this.client.request("/v1/gumtree/search/filters", {
6577
6581
  params: {
6578
6582
  category: params.category,
6579
6583
  location: params.location,
6580
- query: params.query
6584
+ query: params.query,
6585
+ filters: params.filters,
6586
+ market: params.market
6581
6587
  }
6582
6588
  });
6583
6589
  }
@@ -6585,70 +6591,92 @@ var GumtreeClient = class {
6585
6591
  * Full listing: description, every attribute, images, location, seller and
6586
6592
  * similar ads. Motors listings carry the full vehicle spec.
6587
6593
  *
6588
- * @param listingId - Gumtree listing id — the number at the end of a
6589
- * `gumtree.com/p/...` URL.
6594
+ * @param listingId - Gumtree listing id — the number at the end of the
6595
+ * listing URL (uk/au: ~10 digits; za: the full 26-digit ad id, not the
6596
+ * short one).
6597
+ * @param options - Optional parameters (market).
6590
6598
  * @throws NotFoundError - If the listing does not exist or has expired.
6591
6599
  */
6592
- async getListing(listingId) {
6593
- return this.client.request(`/v1/gumtree/listings/${listingId}`);
6600
+ async getListing(listingId, options = {}) {
6601
+ return this.client.request(`/v1/gumtree/listings/${listingId}`, {
6602
+ params: { market: options.market }
6603
+ });
6594
6604
  }
6595
6605
  /**
6596
6606
  * Every live listing by the seller of `listingId`. Gumtree keys a seller's
6597
6607
  * ad list by one of their ads, so any listing id of theirs works.
6598
6608
  *
6599
- * @param listingId - Any Gumtree listing id belonging to the seller.
6600
- * @param page - Page number, 1-50.
6609
+ * @param listingId - Any Gumtree listing id belonging to the seller (za: the
6610
+ * 26-digit id).
6611
+ * @param options - Page number (1-50), or `{ page, market }`.
6601
6612
  */
6602
- async getSellerListings(listingId, page) {
6613
+ async getSellerListings(listingId, options = {}) {
6614
+ const { page, market } = typeof options === "number" ? { page: options } : options;
6603
6615
  return this.client.request(
6604
6616
  `/v1/gumtree/listings/${listingId}/seller-listings`,
6605
- { params: { page } }
6617
+ { params: { page, market } }
6606
6618
  );
6607
6619
  }
6608
6620
  /**
6609
6621
  * Gumtree search-box keyword suggestions, each with the category it maps to.
6610
6622
  *
6611
6623
  * @param query - Partial search term, e.g. `"iph"`.
6624
+ * @param options - Optional parameters (market).
6612
6625
  */
6613
- async autocomplete(query) {
6626
+ async autocomplete(query, options = {}) {
6614
6627
  return this.client.request("/v1/gumtree/autocomplete", {
6615
- params: { query }
6628
+ params: { query, market: options.market }
6616
6629
  });
6617
6630
  }
6618
6631
  /**
6619
- * Resolve a place name or postcode prefix to Gumtree locations with coordinates.
6632
+ * Resolve a place name or postcode prefix to Gumtree locations. The `id`
6633
+ * (au/za) or `name` (uk) is what {@link search} takes as `location`.
6620
6634
  *
6621
6635
  * @param query - Town, area or postcode prefix (min 2 chars), e.g. `"manch"` or `"SW1A"`.
6636
+ * @param options - Optional parameters (market).
6622
6637
  */
6623
- async locationAutocomplete(query) {
6638
+ async locationAutocomplete(query, options = {}) {
6624
6639
  return this.client.request(
6625
6640
  "/v1/gumtree/locations/autocomplete",
6626
- { params: { query } }
6641
+ { params: { query, market: options.market } }
6627
6642
  );
6628
6643
  }
6629
6644
  /**
6630
- * Browse Gumtree's location tree: UK -> nations -> counties -> towns.
6645
+ * Browse Gumtree's location tree. uk: UK -> nations -> counties -> towns;
6646
+ * au: states -> regions -> areas; za: provinces -> towns.
6631
6647
  *
6632
- * @param parentId - Location id to list the children of. Defaults to the
6633
- * United Kingdom (`10000392`) server-side.
6648
+ * @param options - Location id to list the children of, or
6649
+ * `{ parent_id, market }`. Unset = the market's root (the whole country).
6634
6650
  */
6635
- async listLocations(parentId) {
6651
+ async listLocations(options = {}) {
6636
6652
  return this.client.request("/v1/gumtree/locations", {
6637
- params: { parent_id: parentId }
6653
+ params: treeParams(options)
6638
6654
  });
6639
6655
  }
6640
6656
  /**
6641
- * Browse Gumtree's category tree. A node's `slug` is the {@link search} category.
6657
+ * Browse Gumtree's category tree. A node's `slug` (uk) or `id` (au/za) is
6658
+ * the {@link search} category.
6642
6659
  *
6643
- * @param parentId - Category id to list the children of. Defaults to all
6644
- * categories (`1`) server-side.
6660
+ * @param options - Category id to list the children of, or
6661
+ * `{ parent_id, market }`. Unset = the market's root (all categories).
6645
6662
  */
6646
- async listCategories(parentId) {
6663
+ async listCategories(options = {}) {
6647
6664
  return this.client.request("/v1/gumtree/categories", {
6648
- params: { parent_id: parentId }
6665
+ params: treeParams(options)
6649
6666
  });
6650
6667
  }
6668
+ /**
6669
+ * The Gumtree sites this API covers (`uk`, `au`, `za`), with their domain,
6670
+ * currency, distance unit, page size and id format.
6671
+ */
6672
+ async listMarkets() {
6673
+ return this.client.request("/v1/gumtree/markets");
6674
+ }
6651
6675
  };
6676
+ function treeParams(options) {
6677
+ const { parent_id, market } = typeof options === "number" ? { parent_id: options } : options;
6678
+ return { parent_id, market };
6679
+ }
6652
6680
 
6653
6681
  // src/duckduckgo/search.ts
6654
6682
  var SearchClient10 = class {
@@ -10150,7 +10178,7 @@ var ScrapeBadger = class {
10150
10178
  facebook;
10151
10179
  /** Walmart scraper API client — 11 endpoints (walmart.com, US-only) */
10152
10180
  walmart;
10153
- /** Gumtree scraper API client — 8 endpoints (gumtree.com, UK-only) */
10181
+ /** Gumtree scraper API client — 9 endpoints (gumtree.com, gumtree.com.au, gumtree.co.za) */
10154
10182
  gumtree;
10155
10183
  /** DuckDuckGo scraper API client — search, images, news, videos, autocomplete, instant, regions */
10156
10184
  duckduckgo;