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

# Google Shopping API

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

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

## 搜索

```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": "google_shopping", "query": "wireless earbuds", "limit": 3 } }'
```

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

### 参数

* `site`：必填。值为 `google_shopping`。
* `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": "google_shopping",
  "query": "wireless earbuds",
  "country": "US",
  "returnedCount": 3,
  "products": [
    {
      "rank": 1,
      "productId": "1067219252613399794",
      "title": "JLab Go Air Sport True Wireless Earbuds",
      "url": "https://www.google.com/search?q=wireless+earbuds&udm=28&gl=us&hl=en#product=1067219252613399794&title=JLab+Go+Air+Sport+True+Wireless+Earbuds",
      "price": 9.88,
      "currency": "USD",
      "rating": 4.1,
      "seller": "Walmart"
    },
    {
      "rank": 2,
      "productId": "5295866786049939613",
      "title": "JBL Vibe Beam 2 Noise Cancelling True Wireless Earbuds",
      "url": "https://www.google.com/search?q=wireless+earbuds&udm=28&gl=us&hl=en#product=5295866786049939613&title=JBL+Vibe+Beam+2+Noise+Cancelling+True+Wireless+Earbuds",
      "price": 39.95,
      "currency": "USD",
      "rating": 4.2,
      "seller": "Best Buy",
      "imageUrl": "https://encrypted-tbn0.gstatic.com/shopping?q=tbn:ANd9GcTxk4D_LlWLl4n-ponPRc2ihvXVxc8LIg5CGbLCdzmKDbN8zVii50zLQ0tUpH6TwjuCdY2RS3wRw93no9--JdlU6yG_udswoQ"
    },
    {
      "rank": 3,
      "productId": "549048356659243400",
      "title": "Beats Solo Buds True Wireless Earbuds",
      "url": "https://www.google.com/search?q=wireless+earbuds&udm=28&gl=us&hl=en#product=549048356659243400&title=Beats+Solo+Buds+True+Wireless+Earbuds",
      "price": 69.99,
      "currency": "USD",
      "rating": 3.8,
      "seller": "Target",
      "imageUrl": "https://encrypted-tbn2.gstatic.com/shopping?q=tbn:ANd9GcSQnGg6ee9gh0KOOWZFMqbmbUGjWa3kZ5V5EBOzJjb6JRM9z6TdPAoGlSi5_f6cPsEXle-oiBJ8EJ-FaREc98Wqt8jC8WzmfQ"
    }
  ]
}
```

### 结果字段

* `site`、`query` 和 `country` 回显请求。`returnedCount` 是 `products` 中的商品数。
* 每个商品包含 `rank`、`productId`、`title` 和 `url`。`productId` 是 Google 商品 ID；Google 未归并为商品的出售条目则是报价（offer）ID。`rank` 遵循商城的默认排序，商城标为广告的商品会被跳过。
* 搜索结果页显示时返回 `price`、`rating`、`reviewCount`、`imageUrl` 和 `seller`。`price` 是以商品的 `currency`（ISO 4217）计的数字；不同规格分别定价时，取最低价。
* `rating` 为五分制。像 999+ 这样的缩写评价数不会返回。只有 Google 显示确切数量（1,000 以下）时才返回 `reviewCount`。
* 每次搜索从商城搜索结果的第一页获取商品。
* Google 的页面不链接商品或商家页面，因此 `url` 是商品所在的 Google Shopping 结果页，末尾带有 `#product={productId}&title={title}`。把这个 `url` 传给 `COMMERCE_PRODUCT`，即可读取商品的卖家、规格和描述。`seller` 是 Google 列出的第一家卖家。

## 商品页面

```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.google.com/search?q=wireless+earbuds&udm=28&gl=us&hl=en#product=5295866786049939613&title=JBL+Vibe+Beam+2+Noise+Cancelling+True+Wireless+Earbuds" } }'
```

### 参数

* `url`：必填。Google Shopping 搜索返回的商品 `url`，最多 2,048 个字符，格式为 `google.com/search?q={query}&udm=28&gl={market}#product={productId}&title={title}`。[Google 搜索](https://docs.querying.ai/zh/engines/google-serp.md)、[Google AI 概览](https://docs.querying.ai/zh/engines/google-ai-overviews.md) 和 [Google AI 模式](https://docs.querying.ai/zh/engines/google-ai-mode.md) 结果中商品的 `productDetailUrl` 也可直接使用。
* `country`：可选。默认为 `url` 中的 `gl`，取值为 `US`、`GB`、`AU`、`CA`、`KR`、`JP`、`TW`、`HK`、`DE`、`FR`、`ES`、`IT`、`PL`、`PT`、`BR`、`IN`、`ID`、`TH` 和 `VN` 之一。其他国家会以 `422 REGION_UNSUPPORTED` 拒绝。

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

### 响应示例

```json theme={"theme":"css-variables"}
{
  "site": "google_shopping",
  "country": "US",
  "url": "https://www.google.com/search?q=wireless+earbuds&udm=28&gl=us&hl=en#product=5295866786049939613&title=JBL+Vibe+Beam+2+Noise+Cancelling+True+Wireless+Earbuds",
  "productId": "5295866786049939613",
  "title": "JBL Vibe Beam 2 Noise Cancelling True Wireless Earbuds",
  "brand": "JBL",
  "price": 39.95,
  "listPrice": 65,
  "currency": "USD",
  "inStock": true,
  "seller": "Scheels",
  "rating": 4.2,
  "images": [
    "https://encrypted-tbn0.gstatic.com/shopping?q=tbn:ANd9GcTxk4D_LlWLl4n-ponPRc2ihvXVxc8LIg5CGbLCdzmKDbN8zVii50zLQ0tUpH6TwjuCdY2RS3wRw93no9--JdlU6yG_udswoQ",
    "https://encrypted-tbn2.gstatic.com/shopping?q=tbn:ANd9GcQ64EZlooEjcI4GdHBULPySzyZvLSCxjsMi8raMFjbWdZv_KK0cL6P2pIc7nts3uk7G0_XBWBBhVjcuz92sCo2lcDw4hW2H"
  ],
  "description": "The JBL Vibe Beam 2 is a true wireless in-ear earbud system designed to deliver strong audio performance, effective noise control, and seamless everyday usability. Equipped with Bluetooth 5.3, it…",
  "specs": [
    { "name": "Brand", "value": "JBL" },
    { "name": "Noise Canceling", "value": "Yes" },
    { "name": "With Microphone", "value": "Yes" }
  ],
  "offers": [
    {
      "price": 39.95,
      "title": "JBL Vibe Beam 2 headphones",
      "seller": "Scheels",
      "inStock": true,
      "currency": "USD",
      "listPrice": 65
    },
    {
      "url": "https://www.walmart.com/ip/JBL-Vibe-Beam-2-True-Wireless-Noise-Cancelling-In-Ear-Earbuds-Black/21106652379?wmlspartner=wlpa&selectedSellerId=609&veh=seo_fpl&cn=google",
      "price": 39.77,
      "title": "Jbl Vibe Beam 2 True Wireless Noise Cancelling In-Ear Earbuds, Black",
      "seller": "Walmart - Electronics Expo (Authorized Dealer)",
      "inStock": true,
      "currency": "USD"
    }
  ]
}
```

### 结果字段

* `site`、`country`、`url` 和 `productId` 标识页面。`url` 是读取的页面，`productId` 与搜索返回的 ID 一致。
* `title` 始终返回。页面显示时返回 `brand`、`price`、`listPrice`、`currency`、`inStock`、`seller`、`rating`、`reviewCount`、`images`、`description`、`specs` 和 `offers`。
* `price` 是页面最初显示、未计优惠券和运费的购买价格，以 `currency`（ISO 4217）计。 `listPrice` 是页面划线显示的原价，高于 `price` 时才返回。 `inStock` 是商品的库存状态。 `seller` 是销售该商品的商家。
* `rating` 为五分制，保留两位小数。 `reviewCount` 是评价数。只有 Google 显示确切数量（1,000 以下）时才返回 `reviewCount`。
* `images` 按页面顺序列出商品图库中最多 30 张图片。
* `description` 是每段一行的纯文本，最多 10,000 个字符；只出现在图片中的文字不包含在内。
* `specs` 列出商品详情中最多 100 组 `{ name, value }`。
* 读取时会在该市场的 Google Shopping 上重新搜索 `url` 中的搜索词；如果 Google 不再为这个搜索词列出该商品，则改用商品名称搜索，然后打开商品面板，因此比商城页面耗时更长。两次搜索都找不到该商品时，任务以 `PAGE_UNAVAILABLE` 结束。
* `offers` 列出 Google 为该商品显示的商家，从 Google 标为最低价的商家开始，每家包含 `seller`、`title`（商家的商品名称）、`url`（Google 提供链接时为商家的商品页面）、`price`、`listPrice`、`currency` 和 `inStock`。商品的 `price`、`listPrice`、`seller` 和 `inStock` 取自第一家商家。价格使用该市场 Shopping 标签页的货币（ISO 4217），与标签语言无关。
* 来自 Google AI 概览或 AI 模式商品的 `productDetailUrl` 会用商品名称搜索，结果中返回该商品的 `productDocid`。

## 错误与计费

* 没有返回任何商品的搜索以失败任务结束。
* 只对完成的任务计费：每次搜索或每个商品页面 2 积分。

## 相关

* [Google 搜索](https://docs.querying.ai/zh/engines/google-serp.md)
* [Google AI 概览](https://docs.querying.ai/zh/engines/google-ai-overviews.md)
* [Google AI 模式](https://docs.querying.ai/zh/engines/google-ai-mode.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.