> ## 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 Walmart Product Reviews API

> Scrape Walmart product reviews and star ratings for sentiment analysis and market research using the ZenRows Product Reviews API endpoint.

The Walmart Product Reviews API allows you to retrieve detailed product reviews from Walmart, providing valuable insights into customer feedback. You can obtain key information such as ratings, review content, helpful votes, and product details. The tool is ideal for sentiment analysis, product feedback, and market research, helping businesses make informed decisions based on customer opinions.

* Ratings: Aggregate rating scores and distribution by stars.
* Review Details: Content, Titles, Dates, and Verified Purchase Status.
* Navigation: Links for paginated review data.
* Helpful Votes: Count of votes indicating helpfulness.
* Product Information: Name, URL, and SKU of the product.

Example Use Cases:

* **Sentiment Analysis:** Analyze customer feedback for better decision-making.
* **Product Feedback:** Identify common customer concerns and praises.

## Supported Query Parameters

| PARAMETER          | TYPE     | DEFAULT | DESCRIPTION                                                                                                                 |
| ------------------ | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
| **sku** `required` | `string` |         | The Walmart item ID (numeric, 8 to 20 characters). Example: `5074872077`.                                                   |
| **url**            | `string` |         | The URL of the Walmart product page from which reviews are to be fetched. Example: `https://www.walmart.com/ip/5074872077`. |
| **tld**            | `string` | `.com`  | Top-level domain (TLD) for the Walmart website. Default is `.com`. Supported examples: `.com`, `.ca`.                       |
| **sort**           | `string` |         | The sorting method for reviews. Options: `submission-desc`, `relevancy`, `helpful`, `rating-desc`, `rating-asc`.            |

## How to Setup

Request the reviews endpoint for the product:

```bash theme={null}
https://ecommerce.api.zenrows.com/v1/targets/walmart/reviews/{sku}?apikey=YOUR_ZENROWS_API_KEY
```

### Example

```bash cURL theme={null}
curl "https://ecommerce.api.zenrows.com/v1/targets/walmart/reviews/{sku}?apikey=YOUR_ZENROWS_API_KEY"
```

<Note>Replace `{sku}` with the actual product ID.</Note>

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

  sku = "123456789"  # Example SKU
  api_endpoint = f"https://ecommerce.api.zenrows.com/v1/targets/walmart/reviews/{sku}"
  params = {
      "apikey": "YOUR_ZENROWS_API_KEY",
  }
  response = requests.get(api_endpoint, params=params)
  print(response.text)
  ```

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

  const apikey = 'YOUR_ZENROWS_API_KEY';
  const sku = encodeURIComponent('123456789'); // Example SKU
  const api_endpoint = `https://ecommerce.api.zenrows.com/v1/targets/walmart/reviews/${sku}`;

  axios
      .get(api_endpoint, {
          params: {
              apikey,
          },
      })
      .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 apikey = "YOUR_ZENROWS_API_KEY";
          String sku = URLEncoder.encode("123456789", StandardCharsets.UTF_8.toString()); // Example SKU
          String api_endpoint = "https://ecommerce.api.zenrows.com/v1/targets/walmart/reviews/" + sku;

          URI uri = new URIBuilder(api_endpoint)
              .addParameter("apikey", apikey)
              .build();

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

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

  ```php PHP theme={null}
  <?php
  $apikey = 'YOUR_ZENROWS_API_KEY';
  $sku = urlencode('123456789'); // Example SKU
  $api_endpoint = "https://ecommerce.api.zenrows.com/v1/targets/walmart/reviews/$sku";
  $params = [
      'apikey' => $apikey,
  ];

  $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() {
      apikey := "YOUR_ZENROWS_API_KEY"
      sku := url.QueryEscape("123456789") // Example SKU
      api_endpoint := "https://ecommerce.api.zenrows.com/v1/targets/walmart/reviews/" + sku
      params := url.Values{}
      params.Add("apikey", apikey)

      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 'cgi'

  apikey = 'YOUR_ZENROWS_API_KEY'
  sku = CGI.escape('123456789') # Example SKU
  api_endpoint = "https://ecommerce.api.zenrows.com/v1/targets/walmart/reviews/#{sku}"

  conn = Faraday.new(url: api_endpoint) do |f|
  f.params = {
      apikey: apikey,
  }
  end

  response = conn.get

  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json Response Example theme={null}
  {
      "average_score": 4.5,
      "five_star_count": 123,
      "five_star_ratio": 0.73,
      "four_star_count": 123,
      "four_star_ratio": 0.15,
      "one_star_count": 123,
      "one_star_ratio": 0.04,
      "page_navigation": "https:\/\/www.walmart.com\/reviews\/product\/5074872077?page=2",
      "product_details": {
          "product_name": "iPhone 13",
          "product_url": "https:\/\/www.walmart.com\/ip\/Apple-iPhone-13\/123456789"
      },
      "reviews_list": [
          {
              "helpful_votes": 2,
              "is_verified_purchase": true,
              "rating_score": 5,
              "review_content": "It\u2019s great. Works for what we need it to do.",
              "review_date": "Reviewed in the United States on September 4, 2022",
              "review_source": "influenster.com",
              "review_title": "works good",
              "reviewer_name": "Brittany"
          }
      ],
      "three_star_count": 123,
      "three_star_ratio": 0.06,
      "total_ratings_count": 12494,
      "total_reviews_count": 123,
      "two_star_count": 123,
      "two_star_ratio": 0.02
  }
  ```
</ResponseExample>

## Troubleshooting and FAQs

<Accordion title="How do I find the Walmart Item ID (sku) for a product?">
  The Walmart SKU is typically part of the product URL. For example, in the URL `https://www.walmart.com/ip/123456789`, the SKU is `123456789`. You can use this ID directly in the API request.
</Accordion>

<Accordion title="Which fields can I expect to receive in the response?">
  The response includes detailed information about the product, its reviews, and overall ratings. Here is what you can expect:

  * **average\_score:** The average rating score of the product.
  * **total\_ratings\_count:** The total number of ratings received.
  * **total\_reviews\_count:** The total number of written reviews.
  * **star counts and ratios:** Number and percentage of reviews for each rating (five-star, four-star, three-star, two-star, and one-star).
  * **page\_navigation:** A URL to the next page of reviews, if available.
  * **product\_details:** Basic information about the product, including its name and URL.
  * **reviews\_list:** An array containing individual review details such as:
    * **review\_title:** Title of the review.
    * **review\_content:** Text of the review.
    * **rating\_score:** Rating given in the review.
    * **review\_date:** Date when the review was posted.
    * **reviewer\_name:** Name of the reviewer.
    * **is\_verified\_purchase:** Whether the review is from a verified purchase.
    * **helpful\_votes:** Number of helpful votes the review received.
    * **review\_source:** Source of the review if applicable.

  This structure gives you both a high-level overview of the product's reputation and access to each individual review for deeper analysis.
</Accordion>

<Accordion title="Can I use the Walmart Product Scraper API for commercial purposes?">
  Yes, the Walmart Product Scraper API can be used for both personal and commercial projects. Be sure to adhere to Walmart's terms of service and any applicable legal requirements when using the data.
</Accordion>
