> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zenrows.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using the Amazon Discovery API

> Use the ZenRows Amazon Discovery API to search products and extract structured listings with prices, ratings, and discount details.

The Amazon Discovery API enables you to extract search results from Amazon based on specific queries. It provides a structured list of products and their details, empowering you to analyze trends and monitor market activity effectively.

* Product Name, Price, and Discount Details
* Ratings and Review Counts
* Product URLs and Images
* Related Searches and Sponsored Products

Example Use Cases:

* **Market Research:** Identify trending products and evaluate their popularity.
* **Demand Analysis:** Understand product search trends in specific regions or categories.

## Supported Query Parameters

| PARAMETER            | TYPE           | DEFAULT | DESCRIPTION                                                                                     |
| -------------------- | -------------- | ------- | ----------------------------------------------------------------------------------------------- |
| **query** `required` | `string`       |         | The search term you want to query on Amazon. Must be URL-encoded. Example: `Echo+Dot`.          |
| **url**              | `string <uri>` |         | The URL of the search results page to retrieve. Example: `https://www.amazon.com/s?k=Echo+Dot`. |
| **tld**              | `string`       | `.com`  | The top-level domain of the Amazon website. Supported values: `.com`, `.it`, `.de`, etc.        |
| **country**          | `string`       | `us`    | The originating country for the product retrieval. Example: `country=es`.                       |

## How to Setup

Request the search endpoint with the desired query:

```bash theme={null}
https://ecommerce.api.zenrows.com/v1/targets/amazon/discovery/{query}?apikey=YOUR_ZENROWS_API_KEY
```

### Example

```bash cURL theme={null}
curl "https://ecommerce.api.zenrows.com/v1/targets/amazon/discovery/{query}?apikey=YOUR_ZENROWS_API_KEY&country=gb" #Optional: Target specific country
```

<Note>`{query}` must be encoded.</Note>

<RequestExample>
  ```python Python theme={null}
  # pip install requests
  import requests
  import urllib.parse

  query = "laptop stand"
  encoded_query = urllib.parse.quote(query)
  api_endpoint = f"https://ecommerce.api.zenrows.com/v1/targets/amazon/discovery/{encoded_query}"

  params = {
      "apikey": "YOUR_ZENROWS_API_KEY",
      "country": "us"  # Optional: Target specific country
  }

  response = requests.get(api_endpoint, params=params)
  print(response.text)
  ```

  ```javascript NodeJS theme={null}
  // npm install axios
  const axios = require('axios');

  const query = "laptop stand";
  const encodedQuery = encodeURIComponent(query);
  const api_endpoint = `https://ecommerce.api.zenrows.com/v1/targets/amazon/discovery/${encodedQuery}`;

  const apikey = "YOUR_ZENROWS_API_KEY";

  axios
      .get(api_endpoint, {
          params: { apikey, country: "us" }, // Optional: Target specific country
      })
      .then((response) => console.log(response.data))
      .catch((error) => console.log(error));
  ```

  ```java Java theme={null}
  import org.apache.hc.client5.http.fluent.Request;
  import org.apache.hc.core5.net.URIBuilder;
  import java.net.URI;
  import java.net.URLEncoder;
  import java.nio.charset.StandardCharsets;

  public class ZRRequest {
      public static void main(final String... args) throws Exception {
          String query = "laptop stand";
          String encodedQuery = URLEncoder.encode(query, StandardCharsets.UTF_8);
          String api_endpoint = "https://ecommerce.api.zenrows.com/v1/targets/amazon/discovery/" + encodedQuery;

          String apikey = "YOUR_ZENROWS_API_KEY";

          URI uri = new URIBuilder(api_endpoint)
              .addParameter("apikey", apikey)
              .addParameter("country", "us") // Optional: Target specific country
              .build();

          String response = Request.get(uri)
              .execute().returnContent().asString();

          System.out.println(response);
      }
  }
  ```

  ```php PHP theme={null}
  <?php
  $query = "laptop stand";
  $encoded_query = urlencode($query);
  $api_endpoint = "https://ecommerce.api.zenrows.com/v1/targets/amazon/discovery/$encoded_query";

  $apikey = "YOUR_ZENROWS_API_KEY";
  $params = [
      'apikey' => $apikey,
      'country' => 'us'  // Optional: Target specific country
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $api_endpoint . '?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

  $response = curl_exec($ch);
  echo $response . PHP_EOL;
  curl_close($ch);
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
      "fmt"
      "io/ioutil"
      "log"
      "net/http"
      "net/url"
  )

  func main() {
      query := "laptop stand"
      encodedQuery := url.QueryEscape(query)
      api_endpoint := "https://ecommerce.api.zenrows.com/v1/targets/amazon/discovery/" + encodedQuery

      apikey := "YOUR_ZENROWS_API_KEY"
      params := url.Values{}
      params.Add("apikey", apikey)
      params.Add("country", "us") // Optional: Target specific country

      resp, err := http.Get(api_endpoint + "?" + params.Encode())
      if err != nil {
          log.Fatalln(err)
      }
      defer resp.Body.Close()

      body, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          log.Fatalln(err)
      }

      fmt.Println(string(body))
  }
  ```

  ```ruby Ruby theme={null}
  # gem install faraday
  require 'faraday'
  require 'uri'

  query = "laptop stand"
  encoded_query = URI.encode_www_form_component(query)
  api_endpoint = "https://ecommerce.api.zenrows.com/v1/targets/amazon/discovery/#{encoded_query}"

  apikey = "YOUR_ZENROWS_API_KEY"

  conn = Faraday.new(url: api_endpoint) do |f|
    f.params = { apikey: apikey, country: "us" } # Optional: Target specific country
  end

  response = conn.get

  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json Response Example theme={null}
  {
    "search_query": "laptop stand",
    "pagination": {
      "current_page": 1,
      "total_pages": 20,
      "next_page_url": "https://www.amazon.com/s?k=laptop+stand&page=2&xpid=9u8lcOrIDaHFG&qid=1739387945&ref=sr_pg_1"
    },
    "products": [
      {
        "title": "Adjustable Laptop Stand for Desk",
        "asin": "B08XYZ1234",
        "price": 16.99,
        "original_price": 19.99,
        "discounted": true,
        "rating": 4.5,
        "reviews_count": 1250,
        "availability": "In Stock",
        "seller": "Amazon",
        "fulfilled_by_amazon": true,
        "url": "https://www.amazon.com/dp/B08XYZ1234",
        "image_url": "https://m.media-amazon.com/images/I/71d5FyZOpXL._AC_SL1500_.jpg"
      },
      {
        "title": "Laptop Stand, Ergonomic Aluminum Riser",
        "asin": "B09ABC5678",
        "price": 29.99,
        "original_price": null,
        "discounted": false,
        "rating": 4.8,
        "reviews_count": 3400,
        "availability": "In Stock",
        "seller": "Best Deals Inc.",
        "fulfilled_by_amazon": false,
        "url": "https://www.amazon.com/dp/B09ABC5678",
        "image_url": "https://m.media-amazon.com/images/I/81QpJ5BXLbL._AC_SL1500_.jpg"
      }
    ],
    "sponsored_products": [
      {
        "title": "Portable Laptop Stand, Foldable & Lightweight",
        "asin": "B07LMN4567",
        "price": 22.49,
        "original_price": 24.99,
        "discounted": true,
        "rating": 4.6,
        "reviews_count": 980,
        "availability": "In Stock",
        "seller": "Gadgets Hub",
        "fulfilled_by_amazon": true,
        "url": "https://www.amazon.com/dp/B07LMN4567",
        "image_url": "https://m.media-amazon.com/images/I/61zKpLgJtJL._AC_SL1500_.jpg"
      }
    ],
    "related_searches": [
      "adjustable laptop stand",
      "foldable laptop stand",
      "laptop stand for desk",
      "portable laptop riser"
    ]
  }
  ```
</ResponseExample>

## Troubleshooting and FAQs

<Accordion title="How do I handle pagination?">
  The `pagination.current_page` field in the response helps you track pages. Use the `url` parameter with the next page link provided by Amazon to scrape additional pages.
</Accordion>

<Accordion title="Can I target a specific currency for pricing?">
  The `country` parameter determines the currency used in pricing. For example, `country=de` will return prices in Euros (EUR), while `country=us` will return prices in USD.
</Accordion>

<Accordion title="How do I monitor sponsored products?">
  Sponsored products are included in the `sponsored_product_list` field of the response. Use this field to analyze ad placements.
</Accordion>
