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

# Walmart API

> 搜索 Walmart 的商品并读取商品页面，以 JSON 获取结果：搜索结果的排名、价格、评分和评价数，以及商品页面的价格、库存、卖家、图片、规格和选项。

通过异步任务 API 搜索 Walmart（walmart.com）的商品并读取商品页面。发送 `COMMERCE_SERP` 并设置 `site` `walmart`，按商城的顺序获取搜索结果中的商品；向 `COMMERCE_PRODUCT` 传入商品的 `url`，读取该商品。每次完成的搜索或商品页面消耗 **0.5 积分**。

## 搜索

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/async/task \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "taskType": "COMMERCE_SERP", "payload": { "site": "walmart", "query": "wireless earbuds", "limit": 3 } }'
```

提交任务后，轮询 `GET /v1/async/task/{id}` 或通过 webhook 接收。参见[异步任务](https://docs.querying.ai/zh/concepts/async-tasks.md)。

### 参数

* `site`：必填。值为 `walmart`。
* `query`：必填。搜索词，1-500 个字符。
* `limit`：可选整数，范围 1-40，默认 20。
* `country`：可选。默认是商城所在国家 `US`。其他国家会以 `422 REGION_UNSUPPORTED` 拒绝。

仅接受上方列出的载荷字段。请省略 `include`：即使是 `include: {}`，也会在冻结积分前返回针对 `payload.include` 的 `422 VALIDATION_ERROR`。

### 响应示例

```json theme={"theme":"css-variables"}
{
  "site": "walmart",
  "query": "wireless earbuds",
  "country": "US",
  "returnedCount": 3,
  "products": [
    {
      "rank": 1,
      "productId": "19988265343",
      "title": "Wireless Earbuds, 40Hour Battery Life, IPX6 Water Resistance, Touch Controls, for Cycling, Running and Working Out",
      "url": "https://www.walmart.com/ip/Wireless-Earbuds-40-Hour-Battery-Life-IPX6-Water-Resistance-Touch-Controls-for-Cycling-Running-and-Working-Out/19988265343",
      "price": 23.28,
      "currency": "USD",
      "rating": 4.6,
      "reviewCount": 60,
      "imageUrl": "https://i5.walmartimages.com/seo/Wireless-Earbuds-40-Hour-Battery-Life-IPX6-Water-Resistance-Touch-Controls-for-Cycling-Running-and-Working-Out_9d00bfbd-1199-482e-8683-26c939d8a25e.a140f5c2f33ebe4c9d64552b6d7c8f7b.jpeg"
    },
    {
      "rank": 2,
      "productId": "20857668382",
      "title": "Bloydek Wireless Earbuds In-Ear Earbuds,Bluetooth 5.4,Strong Noise Cancellation,IPX5 Waterproof,Touch Control,Type-C Fast Charge,Gaming Low Latency",
      "url": "https://www.walmart.com/ip/Bloydek-Wireless-Bluetooth-In-Ear-Earbuds-Bluetooth-5-4-Strong-Noise-Cancellation-IPX5-Waterproof-Touch-Control-Type-C-Fast-Charge-Gaming-Low-Latency/20857668382",
      "price": 16.99,
      "currency": "USD",
      "rating": 5,
      "reviewCount": 81,
      "imageUrl": "https://i5.walmartimages.com/seo/Bloydek-Wireless-Bluetooth-In-Ear-Earbuds-Bluetooth-5-4-Strong-Noise-Cancellation-IPX5-Waterproof-Touch-Control-Type-C-Fast-Charge-Gaming-Low-Latency_30bb2f49-e592-45bf-ba5e-df79256d9612.d5a461ed3464c2970b69385668a19f3a.jpeg?odnHeight=180&odnWidth=180&odnBg=FFFFFF"
    },
    {
      "rank": 3,
      "productId": "7678011381",
      "title": "Clip on Earbuds Open Ear Wireless Bluetooth 5.4 Headphones with Mic,50H Play,Noise Cancelling,Waterproof,Sports Ear Buds,Lightweight Open Ear Headphones with C-Shaped Bridge,Workouts (Black)",
      "url": "https://www.walmart.com/ip/Clip-Earbuds-Open-Ear-Wireless-Bluetooth-5-4-Headphones-Mic-50H-Play-Noise-Cancelling-Waterproof-Sports-Ear-Buds-Lightweight-Open-Ear-Headphones-C-Sh/7678011381",
      "price": 13.99,
      "currency": "USD",
      "rating": 4.2,
      "reviewCount": 238,
      "imageUrl": "https://i5.walmartimages.com/seo/Clip-Earbuds-Open-Ear-Wireless-Bluetooth-5-4-Headphones-Mic-50H-Play-Noise-Cancelling-Waterproof-Sports-Ear-Buds-Lightweight-Open-Ear-Headphones-C-Sh_3f7e97de-8440-4292-b33e-1aa08be84400.a047bf99a987ed55f7c32d597934768d.jpeg?odnHeight=180&odnWidth=180&odnBg=FFFFFF"
    }
  ]
}
```

### 结果字段

* `site`、`query` 和 `country` 回显请求。`returnedCount` 是 `products` 中的商品数。
* 每个商品包含 `rank`、`productId`、`title` 和 `url`。`productId` 是商城自己的商品 ID。`rank` 遵循商城的默认排序，商城标为广告的商品会被跳过。
* 搜索结果页显示时返回 `price`、`rating`、`reviewCount` 和 `imageUrl`。`price` 是以商品的 `currency`（ISO 4217）计的数字；不同规格分别定价时，取最低价。
* `rating` 为五分制。像 999+ 这样的缩写评价数不会返回。
* 每次搜索从商城搜索结果的第一页获取商品。

## 商品页面

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/async/task \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "taskType": "COMMERCE_PRODUCT", "payload": { "url": "https://www.walmart.com/ip/Wireless-Earbuds-40-Hour-Battery-Life-IPX6-Water-Resistance-Touch-Controls-for-Cycling-Running-and-Working-Out/19988265343" } }'
```

### 参数

* `url`：必填。Walmart 的商品页面，最多 2,048 个字符，格式为 `walmart.com/ip/{name}/{id}`。搜索返回的商品 `url` 可直接使用。跟踪代码等不影响结果的参数会在读取前去掉。
* `country`：可选。默认是页面所在国家 `US`。其他国家会以 `422 REGION_UNSUPPORTED` 拒绝。

仅接受上方列出的载荷字段。请省略 `include`：即使是 `include: {}`，也会在冻结积分前返回针对 `payload.include` 的 `422 VALIDATION_ERROR`。

### 响应示例

```json theme={"theme":"css-variables"}
{
  "site": "walmart",
  "country": "US",
  "url": "https://www.walmart.com/ip/Wireless-Earbuds-40-Hour-Battery-Life-IPX6-Water-Resistance-Touch-Controls-for-Cycling-Running-and-Working-Out/19988265343",
  "productId": "19988265343",
  "title": "Wireless Earbuds, 40‑Hour Battery Life, IPX6 Water Resistance, Touch Controls, for Cycling, Running and Working Out",
  "brand": "Rovisigns",
  "price": 23.28,
  "listPrice": 39.99,
  "currency": "USD",
  "inStock": true,
  "seller": "DEYU",
  "rating": 4.6,
  "reviewCount": 60,
  "images": [
    "https://i5.walmartimages.com/seo/Wireless-Earbuds-40-Hour-Battery-Life-IPX6-Water-Resistance-Touch-Controls-for-Cycling-Running-and-Working-Out_9d00bfbd-1199-482e-8683-26c939d8a25e.a140f5c2f33ebe4c9d64552b6d7c8f7b.jpeg",
    "https://i5.walmartimages.com/asr/13c98513-e5c4-4247-9a11-5cdef37188ce.afb045dc15d75519e29ab72440ca2968.jpeg"
  ],
  "description": "Immersive Rich Audio & Clear Calls：Our open-ear earbuds Adopts innovative quad-speaker structure with dual drivers per earbud, equipped with 15mm large-diaphragm dynamic drivers and dedicated…",
  "specs": [
    { "name": "Battery life", "value": "60 h" },
    { "name": "Headphone style", "value": "In-Ear" },
    { "name": "Noise control technology", "value": "Passive Noise Cancellation" }
  ],
  "categories": [
    "Electronics",
    "Audio",
    "Headphones",
    "Shop Headphones by Type",
    "Earbuds and In-Ear Headphones"
  ],
  "gtin": "607616049364"
}
```

### 结果字段

* `site`、`country`、`url` 和 `productId` 标识页面。`url` 是读取的页面，`productId` 与搜索返回的 ID 一致。
* `title` 始终返回。页面显示时返回 `brand`、`price`、`listPrice`、`currency`、`inStock`、`seller`、`rating`、`reviewCount`、`images`、`description`、`specs`、`options`、`categories` 和 `gtin`。
* `price` 是页面最初显示、未计优惠券和运费的购买价格，以 `currency`（ISO 4217）计。 `listPrice` 是页面划线显示的原价，高于 `price` 时才返回。 `inStock` 是商品的库存状态。 `seller` 是销售该商品的商家。
* `rating` 为五分制，保留两位小数。 `reviewCount` 是评价数。
* `images` 按页面顺序列出商品图库中最多 30 张图片。
* `description` 是每段一行的纯文本，最多 10,000 个字符；只出现在图片中的文字不包含在内。
* `specs` 列出商品详情中最多 100 组 `{ name, value }`。 `options` 列出尺寸或颜色等最多 20 个选项，每个选项最多 100 个 `values`；其他字段描述页面默认打开的选项。 `categories` 从最宽的类目排到最窄的类目，最多 10 级。 `gtin` 是页面列出的 UPC、EAN 或 JAN。

## 错误与计费

* 没有返回任何商品的搜索以失败任务结束。
* 商城以 404 或 410 响应的商品页面（例如已下架的商品）会以 `PAGE_UNAVAILABLE` 结束任务，消息中带有商城的响应。如果商城以 403、412、429 或 435 拒绝读取，任务会等待并在最多 6 分钟内重新请求。其他读取失败，以及持续更久的拒绝，以 `ENGINE_NO_RESULT` 结束。
* 只对完成的任务计费：每次搜索或每个商品页面 0.5 积分。

## 相关

* [Amazon](https://docs.querying.ai/zh/engines/amazon.md)
* [Target](https://docs.querying.ai/zh/engines/target.md)
* [eBay](https://docs.querying.ai/zh/engines/ebay.md)
* [全部 Commerce 商城](https://docs.querying.ai/zh/engines/overview.md#commerce)
* [积分与限制](https://docs.querying.ai/zh/concepts/credits-and-limits.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.