scrapebadger 0.59.0 → 0.60.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/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.1";
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,94 @@ 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 from the end of the listing URL
6595
+ * (uk/au: ~10 digits; za: the listing ref, e.g. `"ls26bvmcpnsqmz7l9jz"`).
6596
+ * @param options - Optional parameters (market).
6590
6597
  * @throws NotFoundError - If the listing does not exist or has expired.
6591
6598
  */
6592
- async getListing(listingId) {
6593
- return this.client.request(`/v1/gumtree/listings/${listingId}`);
6599
+ async getListing(listingId, options = {}) {
6600
+ return this.client.request(`/v1/gumtree/listings/${listingId}`, {
6601
+ params: { market: options.market }
6602
+ });
6594
6603
  }
6595
6604
  /**
6596
6605
  * Every live listing by the seller of `listingId`. Gumtree keys a seller's
6597
6606
  * ad list by one of their ads, so any listing id of theirs works.
6598
6607
  *
6599
- * @param listingId - Any Gumtree listing id belonging to the seller.
6600
- * @param page - Page number, 1-50.
6608
+ * @param listingId - Any Gumtree listing id belonging to the seller (za: a
6609
+ * listing ref, e.g. `"ls26bvmcpnsqmz7l9jz"`).
6610
+ * @param options - Page number (1-50), or `{ page, market }`.
6601
6611
  */
6602
- async getSellerListings(listingId, page) {
6612
+ async getSellerListings(listingId, options = {}) {
6613
+ const { page, market } = typeof options === "number" ? { page: options } : options;
6603
6614
  return this.client.request(
6604
6615
  `/v1/gumtree/listings/${listingId}/seller-listings`,
6605
- { params: { page } }
6616
+ { params: { page, market } }
6606
6617
  );
6607
6618
  }
6608
6619
  /**
6609
6620
  * Gumtree search-box keyword suggestions, each with the category it maps to.
6610
6621
  *
6611
6622
  * @param query - Partial search term, e.g. `"iph"`.
6623
+ * @param options - Optional parameters (market).
6612
6624
  */
6613
- async autocomplete(query) {
6625
+ async autocomplete(query, options = {}) {
6614
6626
  return this.client.request("/v1/gumtree/autocomplete", {
6615
- params: { query }
6627
+ params: { query, market: options.market }
6616
6628
  });
6617
6629
  }
6618
6630
  /**
6619
- * Resolve a place name or postcode prefix to Gumtree locations with coordinates.
6631
+ * Resolve a place name or postcode prefix to Gumtree locations. The `id`
6632
+ * (au: a number; za: a ref such as `"pfw8k"`) or `name` (uk) is what
6633
+ * {@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 and suburbs.
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 (uk/au: a number; za: a ref such as
6649
+ * `"dkp8y"` for Gauteng) to list the children of, or
6650
+ * `{ parent_id, market }`. Unset = the market's root (the whole country).
6634
6651
  */
6635
- async listLocations(parentId) {
6652
+ async listLocations(options = {}) {
6636
6653
  return this.client.request("/v1/gumtree/locations", {
6637
- params: { parent_id: parentId }
6654
+ params: treeParams(options)
6638
6655
  });
6639
6656
  }
6640
6657
  /**
6641
- * Browse Gumtree's category tree. A node's `slug` is the {@link search} category.
6658
+ * Browse Gumtree's category tree. A node's `slug` (uk) or `id` (au: a
6659
+ * number; za: a ref such as `"p6dnh"`) is the {@link search} category.
6642
6660
  *
6643
- * @param parentId - Category id to list the children of. Defaults to all
6644
- * categories (`1`) server-side.
6661
+ * @param options - Category id (uk/au: a number; za: a ref such as
6662
+ * `"l4dq6"` for Vehicles) to list the children of, or
6663
+ * `{ parent_id, market }`. Unset = the market's root (all categories).
6645
6664
  */
6646
- async listCategories(parentId) {
6665
+ async listCategories(options = {}) {
6647
6666
  return this.client.request("/v1/gumtree/categories", {
6648
- params: { parent_id: parentId }
6667
+ params: treeParams(options)
6649
6668
  });
6650
6669
  }
6670
+ /**
6671
+ * The Gumtree sites this API covers (`uk`, `au`, `za`), with their domain,
6672
+ * currency, distance unit, page size and id format.
6673
+ */
6674
+ async listMarkets() {
6675
+ return this.client.request("/v1/gumtree/markets");
6676
+ }
6651
6677
  };
6678
+ function treeParams(options) {
6679
+ const { parent_id, market } = typeof options === "object" ? options : { parent_id: options };
6680
+ return { parent_id, market };
6681
+ }
6652
6682
 
6653
6683
  // src/duckduckgo/search.ts
6654
6684
  var SearchClient10 = class {
@@ -10150,7 +10180,7 @@ var ScrapeBadger = class {
10150
10180
  facebook;
10151
10181
  /** Walmart scraper API client — 11 endpoints (walmart.com, US-only) */
10152
10182
  walmart;
10153
- /** Gumtree scraper API client — 8 endpoints (gumtree.com, UK-only) */
10183
+ /** Gumtree scraper API client — 9 endpoints (gumtree.com, gumtree.com.au, gumtree.co.za) */
10154
10184
  gumtree;
10155
10185
  /** DuckDuckGo scraper API client — search, images, news, videos, autocomplete, instant, regions */
10156
10186
  duckduckgo;