# Walmart Reviews API

This endpoint will retrieve reviews for a specified product from a Walmart reviews page and transform it into usable JSON.

{% tabs %}
{% tab title="cURL" %}

```bash
curl --request GET \
--url "https://api.scraperapi.com/structured/walmart/review?\
api_key=API_KEY&product_id=PRODUCT_ID&country_code=COUNTRY_CODE&tld=TLD&sort=SORT"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

payload = {
    "api_key": "API_KEY",
    "product_id": "PRODUCT_ID",
    "country_code": "COUNTRY_CODE",
    "tld": "TLD",
    "sort" "SORT"
}

r = requests.get('https://api.scraperapi.com/structured/walmart/review', params=payload)

print(r.text)

```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import fetch from 'node-fetch';

fetch(
  'https://api.scraperapi.com/structured/walmart/review?api_key=API_KEY&product_id=PRODUCT_ID&country_code=COUNTRY_CODE&tld=TLD&sort=SORT'
)
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://api.scraperapi.com/structured/walmart/review?api_key=API_KEY&product_id=PRODUCT_ID&country_code=COUNTRY_CODE&tld=TLD&sort=SORT";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

$response = curl_exec($ch);
curl_close($ch);

print_r($response);
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'

params = {
  :api_key => "API_KEY",
  :product_id => "PRODUCT_ID",
  :country_code => "COUNTRY_CODE",
  :tld => "TLD",
  :sort => "SORT",
}

uri = URI('https://api.scraperapi.com/structured/walmart/review')
uri.query = URI.encode_www_form(params)

website_content = Net::HTTP.get(uri)
print(website_content)
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "API_KEY";
            String product_id   = "PRODUCT_ID";
            String country_code = "COUNTRY_CODE";
            String tld = "TLD";
            String sort = "SORT";

            String urlStr = "https://api.scraperapi.com/structured/walmart/review?api_key=" 
                            + apiKey + "&product_id=" + product_id + "&country_code=" + country_code + "&tld=" + tld + "&sort=" + sort;

            URL url = new URL(urlStr);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");

            int responseCode = conn.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                StringBuilder response = new StringBuilder();
                String line;
                while ((line = in.readLine()) != null) {
                    response.append(line);
                }
                in.close();
                System.out.println(response.toString());
            } else {
                System.out.println("Error in API Call. Response code: " + responseCode);
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Supported Parameters**

| Parameter           | Details                                                                                                                                                                                                                    |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `api_key`           | Your API Key.                                                                                                                                                                                                              |
| `product_id`        | Walmart Product id. Example: `5253396052`                                                                                                                                                                                  |
| `TLD`               | <p>Top-level Walmart domain to scrape:<br><strong>com</strong> (walmart.com)<br><strong>ca</strong> (walmart.ca)</p>                                                                                                       |
| `COUNTRY_CODE`      | Valid values are two letter country codes for which we offer Geo Targeting (e.g. “**au**”, “**es**”, “**it**”, etc.). You can find the full list here.                                                                     |
| `sort`              | <p>Sort by option. Valid values are:</p><p></p><p><code>relevancy</code><br><code>helpful</code><br><code>submission-desc</code><br><code>submission-asc</code><br><code>rating-desc</code><br><code>rating-asc</code></p> |
| `ratings`           | Comma-separated number list of review ratings. Supported values: `1,2,3,4,5` - used in any combination.                                                                                                                    |
| `verified_purchase` | Boolean - `true` or `false`. Filters reviews only from verified purchases when set to `true`.                                                                                                                              |
| `page`              | Page number.                                                                                                                                                                                                               |
| `OUTPUT_FORMAT`     | <p>For structured data methods we offer CSV and JSON output. JSON is default if parameter is not added. Options:</p><ul><li>csv</li><li>json (default)</li></ul>                                                           |

### Sample Response

```json
{
  "product_name": "HOBIBEAR Boys Sneakers Kids Running Lightweight Breathable Sport Tennis Shoes（Toddles/Little Kids/Big Kids）",
  "product_url": "https://www.walmart.com/ip/HOBIBEAR-Boys-Sneakers-Kids-Running-Lightweight-Breathable-Sport-Tennis-Shoes-Toddles-Little-Kids-Big-Kids/1347882796",
  "rating": 4.0556,
  "review_count": 18,
  "reviews": [
    {
      "title": "good",
      "text": "design,price and true size overall like.",
      "author": "vi",
      "date_published": "3/10/2024",
      "rating": 4,
      "positive_feedback": 0,
      "negative_feedback": 0
    },
    {
      "title": "Didn't last long",
      "text": "Did not hold up very long to little boy running/ playing/ activities.",
      "author": "firefli529",
      "date_published": "5/11/2024",
      "rating": 3,
      "positive_feedback": 0,
      "negative_feedback": 0,
      "badges": [
        "Verified Purchase",
        "Incentivized Review"
      ]
    },
...
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.scraperapi.com/structured-data-endpoints/e-commerce/walmart/walmart-reviews-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
