scrapebadger 0.58.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.58.0";
12
+ var SDK_VERSION = "0.60.0";
13
13
 
14
14
  // src/internal/exceptions.ts
15
15
  var ScrapeBadgerError = class _ScrapeBadgerError extends Error {
@@ -6529,6 +6529,155 @@ var WalmartClient = class {
6529
6529
  }
6530
6530
  };
6531
6531
 
6532
+ // src/gumtree/client.ts
6533
+ var GumtreeClient = class {
6534
+ constructor(client) {
6535
+ this.client = client;
6536
+ }
6537
+ /**
6538
+ * Search Gumtree listings in the UK, Australia or South Africa.
6539
+ *
6540
+ * @param params - Optional query, category, location (+ distance radius),
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`.
6546
+ * @throws AuthenticationError - If the API key is invalid.
6547
+ * @throws ValidationError - If the parameters are invalid, or not supported
6548
+ * by the market.
6549
+ */
6550
+ async search(params = {}) {
6551
+ return this.client.request("/v1/gumtree/search", {
6552
+ params: {
6553
+ query: params.query,
6554
+ category: params.category,
6555
+ location: params.location,
6556
+ distance: params.distance,
6557
+ min_price: params.min_price,
6558
+ max_price: params.max_price,
6559
+ sort: params.sort,
6560
+ seller_type: params.seller_type,
6561
+ urgent_only: params.urgent_only,
6562
+ with_photos: params.with_photos,
6563
+ filters: params.filters,
6564
+ page: params.page,
6565
+ market: params.market
6566
+ }
6567
+ });
6568
+ }
6569
+ /**
6570
+ * The filters, sort orders and radius options Gumtree offers for a category.
6571
+ *
6572
+ * Each filter lists its values with live result counts. Feed a `key` and a
6573
+ * `value` back into {@link search} as `filters: "key:value"`.
6574
+ *
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.
6578
+ */
6579
+ async searchFilters(params = {}) {
6580
+ return this.client.request("/v1/gumtree/search/filters", {
6581
+ params: {
6582
+ category: params.category,
6583
+ location: params.location,
6584
+ query: params.query,
6585
+ filters: params.filters,
6586
+ market: params.market
6587
+ }
6588
+ });
6589
+ }
6590
+ /**
6591
+ * Full listing: description, every attribute, images, location, seller and
6592
+ * similar ads. Motors listings carry the full vehicle spec.
6593
+ *
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).
6598
+ * @throws NotFoundError - If the listing does not exist or has expired.
6599
+ */
6600
+ async getListing(listingId, options = {}) {
6601
+ return this.client.request(`/v1/gumtree/listings/${listingId}`, {
6602
+ params: { market: options.market }
6603
+ });
6604
+ }
6605
+ /**
6606
+ * Every live listing by the seller of `listingId`. Gumtree keys a seller's
6607
+ * ad list by one of their ads, so any listing id of theirs works.
6608
+ *
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 }`.
6612
+ */
6613
+ async getSellerListings(listingId, options = {}) {
6614
+ const { page, market } = typeof options === "number" ? { page: options } : options;
6615
+ return this.client.request(
6616
+ `/v1/gumtree/listings/${listingId}/seller-listings`,
6617
+ { params: { page, market } }
6618
+ );
6619
+ }
6620
+ /**
6621
+ * Gumtree search-box keyword suggestions, each with the category it maps to.
6622
+ *
6623
+ * @param query - Partial search term, e.g. `"iph"`.
6624
+ * @param options - Optional parameters (market).
6625
+ */
6626
+ async autocomplete(query, options = {}) {
6627
+ return this.client.request("/v1/gumtree/autocomplete", {
6628
+ params: { query, market: options.market }
6629
+ });
6630
+ }
6631
+ /**
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`.
6634
+ *
6635
+ * @param query - Town, area or postcode prefix (min 2 chars), e.g. `"manch"` or `"SW1A"`.
6636
+ * @param options - Optional parameters (market).
6637
+ */
6638
+ async locationAutocomplete(query, options = {}) {
6639
+ return this.client.request(
6640
+ "/v1/gumtree/locations/autocomplete",
6641
+ { params: { query, market: options.market } }
6642
+ );
6643
+ }
6644
+ /**
6645
+ * Browse Gumtree's location tree. uk: UK -> nations -> counties -> towns;
6646
+ * au: states -> regions -> areas; za: provinces -> towns.
6647
+ *
6648
+ * @param options - Location id to list the children of, or
6649
+ * `{ parent_id, market }`. Unset = the market's root (the whole country).
6650
+ */
6651
+ async listLocations(options = {}) {
6652
+ return this.client.request("/v1/gumtree/locations", {
6653
+ params: treeParams(options)
6654
+ });
6655
+ }
6656
+ /**
6657
+ * Browse Gumtree's category tree. A node's `slug` (uk) or `id` (au/za) is
6658
+ * the {@link search} category.
6659
+ *
6660
+ * @param options - Category id to list the children of, or
6661
+ * `{ parent_id, market }`. Unset = the market's root (all categories).
6662
+ */
6663
+ async listCategories(options = {}) {
6664
+ return this.client.request("/v1/gumtree/categories", {
6665
+ params: treeParams(options)
6666
+ });
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
+ }
6675
+ };
6676
+ function treeParams(options) {
6677
+ const { parent_id, market } = typeof options === "number" ? { parent_id: options } : options;
6678
+ return { parent_id, market };
6679
+ }
6680
+
6532
6681
  // src/duckduckgo/search.ts
6533
6682
  var SearchClient10 = class {
6534
6683
  constructor(client) {
@@ -10029,6 +10178,8 @@ var ScrapeBadger = class {
10029
10178
  facebook;
10030
10179
  /** Walmart scraper API client — 11 endpoints (walmart.com, US-only) */
10031
10180
  walmart;
10181
+ /** Gumtree scraper API client — 9 endpoints (gumtree.com, gumtree.com.au, gumtree.co.za) */
10182
+ gumtree;
10032
10183
  /** DuckDuckGo scraper API client — search, images, news, videos, autocomplete, instant, regions */
10033
10184
  duckduckgo;
10034
10185
  /** Bing scraper API client — 6 endpoints (search, images, videos, news, autocomplete, markets) */
@@ -10120,6 +10271,7 @@ var ScrapeBadger = class {
10120
10271
  this.ebay = new EbayClient(this.baseClient);
10121
10272
  this.facebook = new FacebookClient(this.baseClient);
10122
10273
  this.walmart = new WalmartClient(this.baseClient);
10274
+ this.gumtree = new GumtreeClient(this.baseClient);
10123
10275
  this.duckduckgo = new DuckDuckGoClient(this.baseClient);
10124
10276
  this.bing = new BingClient(this.baseClient);
10125
10277
  this.booking = new BookingClient(this.baseClient);
@@ -10198,6 +10350,7 @@ exports.GoogleShoppingClient = ShoppingClient;
10198
10350
  exports.GoogleShortsClient = ShortsClient;
10199
10351
  exports.GoogleTrendsClient = TrendsClient2;
10200
10352
  exports.GoogleVideosClient = VideosClient;
10353
+ exports.GumtreeClient = GumtreeClient;
10201
10354
  exports.IPNotAllowedError = IPNotAllowedError;
10202
10355
  exports.ImmobiliareClient = ImmobiliareClient;
10203
10356
  exports.InstagramAudioClient = AudioClient;