# Walmart Search API

The `Walmart Search API` endpoint returns a list of Walmart products based on a search query.

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

```bash
curl --request GET \
--url "https://api.scraperapi.com/structured/walmart/search?api_key=API_KEY&\
query=QUERY&country_code=COUNTRY_CODE&tld=TLD&page=PAGE"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

payload = {
    "api_key": "APIKEY",
    "query": "QUERY",
    "country_code": "COUNTRY_CODE",
    "tld": "TLD",
    "page": "PAGE"
}

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

print(r.text)
```

{% endtab %}

{% tab title="NodeJS" %}

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

fetch(`https://api.scraperapi.com/structured/walmart/search?api_key=API_KEY&query=QUERY&country_code=COUNTRY_CODE&tld=TLD`)
  .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/search?api_key=API_KEY&query=QUERY&country_code=COUNTRY_CODE&tld=TLD";

$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",
  :query => "QUERY",
  :country_code => "COUNTRY_CODE",
  :tld => "TLD"
}

uri = URI('https://api.scraperapi.com/structured/walmart/search')
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 query   = "QUERY";
            String country_code = "COUNTRY_CODE";
            String tld = "TLD";

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

            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**

<table><thead><tr><th width="397">Parameters</th><th>Details</th></tr></thead><tbody><tr><td><code>API_KEY</code> (required)</td><td>Your API Key.</td></tr><tr><td> <code>QUERY</code> (required)</td><td>Example: Skateboard</td></tr><tr><td><code>TLD</code></td><td>Top-level Walmart domain to scrape:<br><strong>com</strong> (walmart.com)<br><strong>ca</strong> (walmart.ca)</td></tr><tr><td><code>COUNTRY_CODE</code></td><td>Valid values are two letter country codes for which we offer Geo Targeting (e.g. “<strong>au</strong>”, “<strong>es</strong>”, “<strong>it</strong>”, etc.). You can find the full list here.</td></tr><tr><td><code>PAGE</code></td><td>Page number.</td></tr><tr><td><code>OUTPUT_FORMAT</code></td><td><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></td></tr></tbody></table>

### Sample Response

```json
{
  "items": [
    {
      "availability": "In stock",
      "id": "5Q2MFCGA4YFB",
      "image": "https://i5.walmartimages.com/asr/0119bcd3-0ea5-45f5-92b8-451c7db9dae9.740de01aff4ffa73cd8579e3335e187a.jpeg?odnHeight=180&odnWidth=180&odnBg=ffffff",
      "name": "Matchbox Hitch N' Haul: 1:64 Scale Toy Vehicle & Trailer, 4 Accessories (Styles May Vary)",
      "price": 9.76,
      "rating": {
        "average_rating": 4,
        "number_of_reviews": 31
      },
      "seller": "Lord of Retail",
      "url": "https://www.walmart.com/ip/Matchbox-Hitch-N-Haul-1-64-Scale-Toy-Vehicle-Trailer-4-Accessories-Styles-May-Vary/33707529"
    },
    {
      "availability": "In stock",
      "id": "6CC9SDVNKUOY",
      "image": "https://i5.walmartimages.com/asr/9bb1f17e-40b6-4e91-81e4-b271d5614382.639d7c60eb338e74f24d2993c8ad5e47.jpeg?odnHeight=180&odnWidth=180&odnBg=ffffff",
      "name": "Matchbox MBX Electric Drivers, 12 1:64 Scale Toy Cars, Collectibl Set (Styles May Vary)",
      "price": 16.99,
      "rating": {
        "average_rating": 4.5,
        "number_of_reviews": 24
      },
      "seller": "Walmart.com",
      "url": "https://www.walmart.com/ip/Matchbox-MBX-Electric-Drivers-12-1-64-Scale-Toy-Cars-Collectibl-Set-Styles-May-Vary/332457175"
    },
    {
      "availability": "In stock",
      "id": "4MZMRIPU6IXM",
      "image": "https://i5.walmartimages.com/asr/6373c341-7f91-4882-a71e-57f5fe6f80d1.27c3483efa32e44b4834657efdfaed33.jpeg?odnHeight=180&odnWidth=180&odnBg=ffffff",
      "name": "Hot Wheels Matchbox Tomica Toy Car Model 1:64 Car Dustproof Storage Box Children's Toys Transparent three-layer 30-cell storage box",
      "price": 35.36,
      "rating": {
        "average_rating": 4,
        "number_of_reviews": 3
      },
      "seller": "Joybuy Marketplace(Express)",
      "url": "https://www.walmart.com/ip/Hot-Wheels-Matchbox-Tomica-Toy-Car-Model-1-64-Car-Dustproof-Storage-Box-Children-s-Toys-Transparent-three-layer-30-cell-storage-box/1132555385"
    },
    {
      "availability": "In stock",
      "id": "5CV5G5DOQTLU",
      "image": "https://i5.walmartimages.com/asr/ce0f6a6f-6cf5-49f2-9007-113baeafb787.ec1e0da7556aabf433381b97be6bd997.jpeg?odnHeight=180&odnWidth=180&odnBg=ffffff",
      "name": "Matchbox Themed 1:64 Scale Vehicle for Toy Car Collectors & Kids Ages 3 Years Old & Up",
      "price": 14.99,
      "rating": {
        "average_rating": 5,
        "number_of_reviews": 2
      },
      "seller": "JMRE Group Holdings",
      "url": "https://www.walmart.com/ip/Matchbox-Themed-1-64-Scale-Vehicle-for-Toy-Car-Collectors-Kids-Ages-3-Years-Old-Up/1804156209"
    },
    {
      "availability": "In stock",
      "id": "5173Y2CKWSR4",
      "image": "https://i5.walmartimages.com/asr/aa6e5dcf-3936-4d10-91dd-534ca2c0ebe4.c63146f8b92d79ca5c3aed6506156329.jpeg?odnHeight=180&odnWidth=180&odnBg=ffffff",
      "name": "Matchbox 2019 Ram Ambulance, Moving Parts 26/54",
      "price": 19.99,
      "rating": {
        "average_rating": 0,
        "number_of_reviews": 0
      },
      "seller": "KandR toys",
      "url": "https://www.walmart.com/ip/Matchbox-2019-Ram-Ambulance-Moving-Parts-26-54/1702189364"
    },
    {
      "availability": "In stock",
      "id": "7CA7DZCNLDPL",
      "image": "https://i5.walmartimages.com/asr/06d0c0b1-b379-48f4-88a3-1e6413fd847d.5e06151d57b7820c34016dc50332341b.jpeg?odnHeight=180&odnWidth=180&odnBg=ffffff",
      "name": "Matchbox Action Drivers Pizza Hut Pizza Run Playset",
      "price": 25.47,
      "rating": {
        "average_rating": 4.8,
        "number_of_reviews": 13
      },
      "seller": "Pordobel (SIGNATURE REQUIRED)",
      "url": "https://www.walmart.com/ip/Matchbox-Action-Drivers-Pizza-Hut-Pizza-Run-Playset/965388844"
    },
    {
      "availability": "In stock",
      "id": "1HZOPZCOIW0W",
      "image": "https://i5.walmartimages.com/asr/4bfb396f-06b7-44ec-9196-82b9632ebaf4.93c4f1120653ed4da560be9dc444936c.jpeg?odnHeight=180&odnWidth=180&odnBg=ffffff",
      "name": "Matchbox Action Drivers Matchbox Transforming Excavator, Toy Construction Truck with 1:64 Scale Vehicle",
      "price": 22.48,
      "rating": {
        "average_rating": 4.9,
        "number_of_reviews": 34
      },
      "seller": "Walmart.com",
      "url": "https://www.walmart.com/ip/Matchbox-Action-Drivers-Matchbox-Transforming-Excavator-Toy-Construction-Truck-with-1-64-Scale-Vehicle/2047218741"
    }
  ],
  "meta": {
    "page": 2,
    "pages": 25
  }
}
```


---

# 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-search-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.
