Google Maps Nearby Search API
Search Google Maps around an exact latitude and longitude and get up to 20 normalized places per call, each with the address broken into street, city, state, postal code and country. Use this when you have coordinates and want the map viewport centred on them; use maps.search when you only have a place name. Pass the returned nextCursor back as cursor for the next 20 places.
USD 0.001300 / 次成功调用
公开 ID: places.search.nearby · 版本 1
定价
USD 0.001300 / 次成功调用
快速开始
使用 API 密钥发现此工具,再通过返回的 provider 和 endpoint 检查接口后执行。
将 GLOOP_API_BASE 设为 API 地址,GLOOP_API_KEY 设为服务端密钥。
curl
curl --fail-with-body "${GLOOP_API_BASE%/}/v1/discover" \
-H "Authorization: Bearer $GLOOP_API_KEY" \
-H 'Content-Type: application/json' \
--data-raw '{
"limit": 5,
"query": "Google Maps Nearby Search"
}'Python
import os, json, urllib.request
url = os.environ['GLOOP_API_BASE'].rstrip('/') + "/v1/discover"
headers = {'Authorization': 'Bearer ' + os.environ['GLOOP_API_KEY']}
headers['Content-Type'] = 'application/json'
data = "{\n \"limit\": 5,\n \"query\": \"Google Maps Nearby Search\"\n}".encode('utf-8')
request = urllib.request.Request(url, data=data, headers=headers)
with urllib.request.urlopen(request) as response:
print(json.load(response))Node.js
const url = process.env.GLOOP_API_BASE.replace(/\/$/, '') + "/v1/discover";
const headers = { Authorization: `Bearer ${process.env.GLOOP_API_KEY}` };
headers['Content-Type'] = 'application/json';
const response = await fetch(url, { method: 'POST', headers, body: JSON.stringify({
"limit": 5,
"query": "Google Maps Nearby Search"
}) });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());工具 API 文档 · POST /v1/inspect输入结构
{
"additionalProperties": false,
"properties": {
"coordinates": {
"additionalProperties": false,
"description": "The exact map centre to search around. Use maps.search instead if you only have a place name.",
"properties": {
"latitude": {
"description": "Latitude of the map centre in decimal degrees.",
"maximum": 90,
"minimum": -90,
"type": "number"
},
"longitude": {
"description": "Longitude of the map centre in decimal degrees.",
"maximum": 180,
"minimum": -180,
"type": "number"
}
},
"required": [
"latitude",
"longitude"
],
"type": "object"
},
"cursor": {
"description": "Opaque cursor from a previous response's nextCursor. Pass it back to get the next page of places.",
"type": "string"
},
"language": {
"description": "Two-letter language code for the results (e.g. en).",
"type": "string"
},
"limit": {
"description": "Accepted but does not change the page: every call returns one full Google Maps viewport of about 20 places, never trimmed, so nextCursor continues exactly where this response ended. Price is flat per request.",
"maximum": 20,
"minimum": 1,
"type": "integer"
},
"query": {
"description": "What you would type in the Google Maps search bar (e.g. coffee shop).",
"minLength": 1,
"type": "string"
},
"zoom": {
"description": "Google Maps viewport zoom. Lower covers a wider area, higher focuses more tightly around the coordinates.",
"maximum": 21,
"minimum": 3,
"type": "number"
}
},
"required": [
"query",
"coordinates"
],
"type": "object"
}输出结构
{
"type": "object"
}