# Google 地圖商戶搜尋 API

> 在 Google 地圖上搜商戶：名稱、類別、地址、電話、網站、評分和評價數、營業時間和座標。只有商戶公開資訊。每頁 20 個。

網頁版：https://okdata.online/zh/apis/google/maps/places/search/

- **介面**：`GET /v1/google/maps/places/search`
- **ID**：`google.maps.places.search`
- **價格**：$0.005/次 · 每頁約 20 條結果
- **返回**：一頁約 20 條結果（`data.items`，Place 物件）
- **狀態**：預覽
- **適合**：競品監控、選品定價

## 價格

每次呼叫 $0.005，返回一頁，約 20 條結果。抓 1,000 條結果大約要 50 次呼叫，合計 $0.25。每翻一頁是一次單獨的呼叫。請求到了平台的呼叫，返回為空、查不到或出錯也照常計費；還沒請求到平台就被攔下的不扣費。

## 引數

| 引數名 | 型別 | 必填 | 預設值 | 說明 |
|---|---|---|---|---|
| `query` | string | 是 |  | 關鍵詞，和在平台搜尋框裡輸入的一樣。（例：`coffee shops in Austin`） |
| `country` | string | 否 |  | 從哪個國家搜，兩位國家程式碼（us、gb、de、jp……），結果按這個國家本地化；不填用 Google 預設。（例：`us`） |
| `language` | string | 否 |  | 介面語言，兩位語言程式碼（en、fr、zh-cn……）。（例：`en`） |
| `coordinates` | string | 否 |  | 在哪裡附近搜，格式 @緯度,經度,縮放（和 Google 地圖連結裡一樣）；不填按搜尋詞裡的地點。（例：`@30.2672,-97.7431,14z`） |
| `cursor` | string | 否 |  | 上一次返回的 page.next_cursor，原樣傳回。每翻一頁都是一次單獨的呼叫。 |
| `view` | string: brief / compact / standard / full | 否 | `standard` | 返回多少欄位。brief：只給 ID、標題、正文前 100 字、連結、時間和主要數字，適合先掃一遍列表，再按 ID 取詳情；compact 去掉空欄位、長正文截到 500 字；full 會在 ext 裡帶上平台特有欄位。 |
| `fields` | string[] | 否 |  | 只保留這些欄位，按路徑寫（如 author.name），用來省 token。放在查詢引數裡時用逗號分隔。 |

cursor、view、fields 的用法見 [請求說明](https://okdata.online/zh/docs/requests/)。

## 返回欄位

每一條都是一個 [Place](https://okdata.online/zh/docs/objects/place/)。

| 欄位 | 型別 | 說明 |
|---|---|---|
| `id` | string | Google 的地點 ID。 |
| `name` | string | 商戶名稱。 |
| `url` | string \| null | Google 地圖上的地點頁。 |
| `category` | string \| null | 主類別，Google 原文。 |
| `categories` | string[] \| null | 所有類別。 |
| `address` | string \| null | 地址。 |
| `phone` | string \| null | 商戶電話。 |
| `website` | string \| null | 商戶官網。 |
| `rating` | number \| null | 平均星級，1 到 5。 |
| `reviews` | integer \| null | 評價數。 |
| `price_level` | string \| null | 價位（如「$$」），Google 顯示的話。 |
| `latitude` | number \| null | 緯度。 |
| `longitude` | number \| null | 經度。 |
| `hours` | object \| null | 按星期的營業時間，Google 原文。 |
| `open_state` | string \| null | 抓取時是否營業，Google 原文。 |
| `description` | string \| null | Google 對這家店的簡介。 |
| `thumbnail_url` | string \| null | 照片。 |
| `rank` | integer \| null | 在結果裡的位置，從 1 開始。 |
| `ext` | object | 平台特有欄位，只在 view=full 時返回。 |

## 請求示例

### cURL

```bash
curl -G "https://api.okdata.online/v1/google/maps/places/search" \
  -H "Authorization: Bearer $OKDATA_API_KEY" \
  --data-urlencode 'query=coffee shops in Austin'
```

### Python

```python
import os
import requests

resp = requests.get(
    "https://api.okdata.online/v1/google/maps/places/search",
    headers={"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
    params={"query": "coffee shops in Austin"},
    timeout=60,
)
body = resp.json()
if body["code"] != "ok":
    raise RuntimeError(f"{body['code']}: {body['message']} (charged: {body['charged']})")

for row in body["data"]["items"]:
    print(row)
print("cost: $" + body["meta"]["billing"]["amount"])
```

### TypeScript

```ts
const url = new URL('https://api.okdata.online/v1/google/maps/places/search');
url.searchParams.set('query', "coffee shops in Austin");

const res = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.OKDATA_API_KEY}`,
  },
});
const body = await res.json();
if (body.code !== 'ok') throw new Error(`${body.code}: ${body.message}`);

for (const row of body.data.items) {
  console.log(row);
}
console.log('cost: $' + body.meta.billing.amount);
```

### MCP

```json
{
  "name": "call",
  "arguments": {
    "capability": "google.maps.places.search",
    "query": "coffee shops in Austin"
  }
}
```

或者對接好 MCP 的智慧體直接說：

> 用「Google 地圖商戶搜尋」查一下，總結返回的結果。

## 返回示例

```json
{
  "code": "ok",
  "request_id": "0f6c2a8e-4b1d-4e0a-9a51-3c7d2b9e1f20",
  "data": {
    "items": [
      {
        "id": "ChIJTWZhRFW1RIYRrdGa7DPzT7w",
        "name": "Mozart's Coffee Roasters",
        "url": "https://www.google.com/maps/place/?q=place_id:ChIJTWZhRFW1RIYRrdGa7DPzT7w",
        "category": "Coffee shop",
        "categories": [
          "Coffee shop",
          "Espresso bar"
        ],
        "address": "3825 Lake Austin Blvd, Austin, TX 78703",
        "phone": "+15124772900",
        "website": "https://mozartscoffee.com/",
        "rating": 4.5,
        "reviews": 11042,
        "price_level": null,
        "latitude": 30.2954696,
        "longitude": -97.7839512,
        "hours": {
          "monday": "7 AM–12 AM"
        },
        "open_state": "Open · Closes 12 AM",
        "description": "Lakeside coffee and desserts, beans roasted on site.",
        "thumbnail_url": null,
        "rank": 1
      }
    ]
  },
  "page": {
    "next_cursor": "c1.k3Vq9TzR0bYw2LmXe8NdPa",
    "cursor_expires_at": "2026-11-12T08:00:00Z",
    "has_more": true,
    "returned": 1
  },
  "warnings": [],
  "meta": {
    "capability": "google.maps.places.search",
    "result_status": "complete",
    "billing": {
      "amount": "0.005",
      "currency": "USD",
      "balance_after": "9.995"
    },
    "unavailable": {},
    "cached": false,
    "replayed": false,
    "fetched_at": "2026-11-11T08:00:00Z"
  }
}
```

## 錯誤

所有錯誤同一種結構：code、request_id、message 和 message_zh（每個 code 一句固定的話）、charged、retry、retry_after_seconds、param 和 docs_url，具體問題寫在 problems 裡。請求到了平台的調用出錯（查不到、平台失敗或超時）時，按這個介面的價格計一次費，charged 為 true，並給出 amount；引數錯誤這類還沒請求到平台的錯誤不扣費。只有 settlement_unknown 的扣費結果要查詢後才知道。完整列表：https://okdata.online/zh/docs/errors/

## 常見問題

### Google 地圖商戶搜尋介面多少錢？

每次呼叫 $0.005，返回一頁，約 20 條結果。抓 1,000 條結果大約要 50 次呼叫，合計 $0.25。每翻一頁是一次單獨的呼叫。請求到了平台的呼叫，返回為空、查不到或出錯也照常計費；還沒請求到平台就被攔下的不扣費。

### 怎麼翻頁？

把返回裡的 page.next_cursor 原樣作為 cursor 引數傳回去。page.has_more 為 false 時就沒有下一頁了。每一頁都是一次 $0.005 的呼叫。

### 需要Google帳號、Cookie 或掃碼登入嗎？

不需要。只要帶上 okdata 的 API key。返回的是Google上的公開資料，不會用到你自己的Google帳號。

### 呼叫失敗會扣費嗎？

請求到了平台就會扣一次：返回為空、查不到、平台出錯或超時，都按一次呼叫計費（按條計價的按 1 條），錯誤裡 charged 為 true，並給出 amount。引數錯誤、餘額不足這類還沒請求到平台就被攔下的不扣費。

### Google不展示某個欄位怎麼辦？

這個欄位會是 null，meta.unavailable 裡會列出它和原因：platform（平台本來就不展示）或 capability（我們暫時取不到）。

## Google的其他介面

- [Google 廣告透明中心廣告主搜尋](https://okdata.online/zh/apis/google/advertisers/search/)：$0.004/次 · 每頁約 10 個廣告主
- [Google 廣告主的廣告](https://okdata.online/zh/apis/google/advertisers/ads/list/)：$0.004/次 · 每頁約 40 條廣告
- [Google 網頁搜尋](https://okdata.online/zh/apis/google/search/)：$0.01/次
- [Google 新聞搜尋](https://okdata.online/zh/apis/google/news/search/)：$0.005/次 · 每頁約 100 條結果
- [Google 圖片搜尋](https://okdata.online/zh/apis/google/images/search/)：$0.01/次 · 每頁約 20 條結果
- [Google 購物搜尋](https://okdata.online/zh/apis/google/shopping/search/)：$0.01/次 · 每頁約 40 個商品
- [Google 趨勢：當下熱搜](https://okdata.online/zh/apis/google/trends/trending/list/)：$0.008/次 · 每頁約 100 條榜單
- [Google 搜尋聯想詞](https://okdata.online/zh/apis/google/suggestions/list/)：$0.008/次 · 每頁約 15 條榜單
- [Google 影片搜尋](https://okdata.online/zh/apis/google/videos/search/)：$0.008/次
- [Google 學術搜尋](https://okdata.online/zh/apis/google/scholar/search/)：$0.008/次
- [Google 專利搜尋](https://okdata.online/zh/apis/google/patents/search/)：$0.008/次
- [Google 招聘搜尋](https://okdata.online/zh/apis/google/jobs/search/)：$0.008/次 · 每頁約 10 條結果

## 概要

- **簡稱**：地圖商戶
- **英文名**：Google Maps place search API
- **也叫**：谷歌地圖、地圖商戶、本地商家、海外客戶開發
- **分類**：[電商](https://okdata.online/zh/categories/commerce/)
- **狀態**：預覽。還可能調整，改動會提前公告。
- **價格**：$0.005（約 ¥0.035） / 次 · 引數錯誤不扣費
- **返回**：每頁約 20 條結果，帶翻下一頁的游標
- **調用出錯時**：照常計一次費。出錯時我們這邊先自動重試。請求到了平台的呼叫，出錯也按一次計費；引數錯誤不扣費。

## 什麼時候收費

- 返回了資料：$0.005，每次呼叫收一次
- 引數不合法、餘額不足、介面暫停：不收費

| 情況 | 收費 |
|---|---|
| 每翻一頁 | 另算一次呼叫：$0.005 |
| 單次最高扣費 | $0.005 |
| 空結果 | $0.005 |
| 平台出錯或超時 | $0.005 |
| 引數不合法、餘額不足、介面暫停 | 不收費 |
| 24 小時內帶同一個 Idempotency-Key 重發 | 直接返回儲存的結果，不扣費 |

請求到了平台的呼叫，返回為空、查不到或出錯也照常計費，收 $0.005；引數錯誤這類還沒請求平台就被攔下的不扣費。

價格取自價目表版本 fb99dc8a88674793。 [這個平台的全部價格](https://okdata.online/zh/pricing/google/)

- 新帳號送 $0.20 試用額度，不用綁卡：夠調這個介面 40 次。
- 抓 1,000 條結果約要 50 次呼叫，合計 $0.25。

## 已知限制

- 每頁約 20 條結果，條數由平台決定，沒有每頁條數引數。
- 翻下一頁時把 `page.next_cursor` 作為 `cursor` 傳回。游標 24 小時內有效。`page.has_more` 為 false 時就沒有下一頁了。

## 各檢視返回的欄位

“檢視”一列是欄位最早出現的 `view`：`compact` 只返回 compact 欄位，`standard` 再加上 standard 欄位，`full` 返回全部。預設是 `standard`。

- `compact`：`id`, `name`, `url`, `category`, `address`, `phone`, `website`, `rating`, `reviews`, `rank`
- `standard`：`categories`, `price_level`, `latitude`, `longitude`, `hours`, `open_state`, `description`, `thumbnail_url`
- `full`：`ext`

## 這個介面的常見報錯

| 狀態碼 | 程式碼 | 含義 | 是否扣費 | 能否重試 |
|---|---|---|---|---|
| 400 | `invalid_params` | 引數缺失、型別或取值不對，或者請求方法不對。problems 列出每一處問題，param 是第一個出錯的引數。 | 否 | 修正後重試 |
| 400 | `cursor_mismatch` | cursor 發到了別的介面，或者引數和它所在那一頁不一樣（view 和 fields 可以變）。 | 否 | 修正後重試 |
| 401 | `unauthorized` | Key 缺失、格式不對、已撤銷、已停用或已過期（知道原因時 reason 會寫明）。 | 否 | 不要重試 |
| 402 | `insufficient_balance` | 餘額（available）不夠這次呼叫的最高費用（required）。 | 否 | 修正後重試 |
| 410 | `cursor_expired` | cursor 超過了這個介面的有效期（page.cursor_expires_at 寫了到期時間）。 | 否 | 不要重試 |
| 429 | `rate_limited` | 帳號這一分鐘請求太多（reason: rate），或同時進行的呼叫太多（reason: concurrency）。 | 否 | 可以重試 |
| 500 | `settlement_unknown` | 資料已返回，但沒能確認是否扣費。 | 查詢後才知道 | 用同一個 Idempotency-Key 重試 |
| 502 | `fetch_failed` | 我們這邊自動重試後，這次請求仍然失敗了。如果請求到了平台、且這次請求產生了費用，就按介面價格計一次費（charged 為 true，並給出 amount）；否則不計費。 | 請求到了平台就扣一次 | 可以重試 |
| 503 | `capability_paused` | 這個介面暫時停用了，這次沒有執行。 | 否 | 可以重試 |
| 504 | `timeout` | 資料沒有及時返回。如果請求到了平台、且這次請求產生了費用，就按介面價格計一次費（charged 為 true，並給出 amount）；否則預扣退回。 | 請求到了平台就扣一次 | 可以重試 |

[全部錯誤碼](https://okdata.online/zh/docs/errors/)

## 在你的 AI 裡用

> 先讀 https://okdata.online/zh/apis/google/maps/places/search.md，再用 okdata 幫我調這個介面，key 在環境變數 OKDATA_API_KEY 裡。用「Google 地圖商戶搜尋」查一下，總結返回的結果。
