Walmart API
Walmart API 允许您搜索商品并通过商品 ID 获取详细的商品信息。两个端点均支持设备模拟、配送地区定位和履约方式筛选。
端点
| 端点 | 描述 |
|---|---|
POST /api/v1/walmart/search | 搜索 Walmart 商品,支持排序、分页、价格和履约方式筛选 |
POST /api/v1/walmart/product | 通过 Walmart 商品 ID 获取详细商品信息 |
身份验证
| 请求头 | 值 | 必填 |
|---|---|---|
Authorization | Bearer YOUR_API_KEY | 是 |
Content-Type | application/json | 是 |
商品搜索
Bash
POST https://api.scavio.dev/api/v1/walmart/search搜索 Walmart 商品并获取结构化结果,包括价格、评分和库存状态。
请求体
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
query | string | -- | 必填。 搜索关键词(1-500 个字符)。 |
domain | string | "" | Walmart 域名。 |
device | string | desktop | 设备类型。可选值:desktop, mobile, tablet |
sort_by | string | best_match | 排序方式。可选值:best_match, price_low, price_high, best_seller |
start_page | integer | 1 | 起始页码(从 1 开始)。 |
min_price | integer | -- | 最低价格筛选(单位:美元)。 |
max_price | integer | -- | 最高价格筛选(单位:美元)。 |
fulfillment_speed | string | -- | 配送速度筛选。可选值:today, tomorrow, 2_days, anytime |
fulfillment_type | string | -- | 履约类型筛选。目前支持:in_store |
delivery_zip | string | -- | 配送邮编,用于获取本地化结果和库存信息。 |
store_id | string | -- | Walmart 门店 ID,用于查询店内库存。 |
示例
curl -X POST 'https://api.scavio.dev/api/v1/walmart/search' \
-H 'Authorization: Bearer sk_live_your_key' \
-H 'Content-Type: application/json' \
-d '{
"query": "wireless headphones",
"sort_by": "best_seller",
"min_price": 20,
"max_price": 100
}'响应示例
JSON
{
"data": {
"page": 1,
"products_count": 40,
"location": {
"city": "Jacksonville",
"state": "FL",
"store_id": "5054",
"zipcode": "32246"
},
"products": [
{
"id": "123456789",
"title": "Sony WH-1000XM5 Wireless Noise Canceling Headphones",
"url": "/ip/Sony-WH-1000XM5/123456789",
"image": "https://i5.walmartimages.com/...",
"price": 248.0,
"price_strikethrough": null,
"currency": "USD",
"rating": 4.7,
"rating_count": 8230,
"sponsored": false,
"out_of_stock": false,
"seller_name": "Walmart.com",
"seller_id": "F55CDC31AB754BB68FE0B39041159D63",
"fulfillment": {
"delivery": true,
"free_shipping": true,
"pickup": true,
"shipping": true
},
"pos": 1,
"variants": []
}
],
"url": "https://www.walmart.com/search?q=...",
"html": "",
"screenshot": ""
},
"response_time": 1920,
"credits_used": 1,
"credits_remaining": 999
}商品详情
Bash
POST https://api.scavio.dev/api/v1/walmart/product通过 Walmart 商品 ID 获取特定商品的详细信息。返回内容包括价格、描述、规格参数、图片、评分和卖家信息。
请求体
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
product_id | string | -- | 必填。 Walmart 商品 ID(例如 123456789)。 |
domain | string | -- | Walmart 域名。 |
device | string | desktop | 设备类型。可选值:desktop, mobile, tablet |
delivery_zip | string | -- | 配送邮编,用于获取本地化价格。 |
store_id | string | -- | Walmart 门店 ID,用于查询店内库存。 |
示例
curl -X POST 'https://api.scavio.dev/api/v1/walmart/product' \
-H 'Authorization: Bearer sk_live_your_key' \
-H 'Content-Type: application/json' \
-d '{"product_id": "123456789"}'响应示例
JSON
{
"data": {
"id": "123456789",
"sku": "123456789",
"gtin": "012345678901",
"price": 248.0,
"price_strikethrough": 349.99,
"currency": "USD",
"rating": 4.7,
"rating_count": 8230,
"out_of_stock": false,
"seller_name": "Walmart.com",
"seller_id": "F55CDC31AB754BB68FE0B39041159D63",
"seller_url": null,
"image": "https://i5.walmartimages.com/...",
"images": [
"https://i5.walmartimages.com/..."
],
"fulfillment": {
"delivery": true,
"delivery_information": "Arrives today",
"free_shipping": true,
"fulfilled_by": "",
"out_of_stock": false,
"pickup": true,
"pickup_information": "Pickup today",
"shipping": true,
"shipping_information": "Free shipping"
},
"specifications": [
{ "key": "Brand", "value": "Sony" },
{ "key": "Wireless technology", "value": "Bluetooth" }
],
"html": "",
"screenshot": ""
},
"response_time": 2310,
"credits_used": 1,
"credits_remaining": 998
}响应格式
两个端点均返回统一的响应包装结构:
| 字段 | 类型 | 描述 |
|---|---|---|
data | object | null | 响应数据。如果上游请求失败则为 null。搜索接口返回 {page, products, location, ...};商品详情接口直接返回商品对象。 |
response_time | number | 服务端响应时间(毫秒) |
credits_used | number | 消耗的积分数量 |
credits_remaining | number | 当前计费周期内剩余积分 |
错误响应
| 状态码 | 描述 |
|---|---|
401 | 未授权 -- API 密钥缺失或无效 |
429 | 超出当前套餐的速率或用量限制 |
502 | 上游错误 -- 请稍后重试 |
503 | 上游不可用 -- 请稍后重试 |
请参阅错误参考获取完整的错误代码列表和重试最佳实践。
相关文档
- 快速开始 -- 获取 API 密钥并发送第一个请求
- Google Search API -- 搜索 Google 并获取结构化 SERP 数据
- YouTube API -- 搜索视频并提取元数据
- Amazon API -- 搜索 Amazon 商品,覆盖 12 个站点
- 速率限制 -- 各套餐等级的限额