Search cities by name
companyenrich.geo.cities.searchSearches cities by name or country codes — returns up to 100 cities per page
- 价格
- free按目录价
- 成功率
- —暂无成功率数据暂无成功率数据
- 延迟 p50
- ——
- 最后验证
- 2026年8月20日实测可用
POSThttps://toolswitch.dev/v1/tools/companyenrich.geo.cities.searchBeta- 可用平台额度调用
- 同步返回
- 读取公开数据
参数
FREE. Returns numeric city `id`s for the `cities` filter. Expect near-duplicates for one metro ('San Francisco', 'City and County of San Francisco', 'South San Francisco') — pass all the ids you mean, or you will silently narrow the audience.
| 参数 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| 请求体(JSON) | ||||
page | 整数 | 可选 | 1-based page number | |
query | 字符串 | 可选 | city name; prefixes work ('san fran' matched three San Francisco entries) | san fran |
countryCodes | array[string] | 可选 | ISO alpha-2 codes to scope the search | ["US"] |
- 请求体(JSON)
page整数可选1-based page number
query字符串可选city name; prefixes work ('san fran' matched three San Francisco entries)
示例:
san francountryCodesarray[string]可选ISO alpha-2 codes to scope the search
示例:
["US"]
示例响应
JSON
{
"page": 1,
"items": [
{
"id": 130518,
"name": "City and County of San Francisco",
"latitude": 37.77823,
"longitude": -122.4425
},
{
"id": 131186,
"name": "San Francisco",
"latitude": 37.77493,
"longitude": -122.41942
},
"... 1 more items truncated"
],
"totalItems": 3,
"totalPages": 1
}代码示例
将 $TOOLSWITCH_KEY 替换为你在控制台创建的密钥。
Beta
curl -X POST 'https://toolswitch.dev/v1/tools/companyenrich.geo.cities.search' \
-H "X-Toolswitch-Key: $TOOLSWITCH_KEY" \
-H "Content-Type: application/json" \
--data-raw '{"query":"san fran","countryCodes":["US"]}'import os
import json
import requests
response = requests.request(
"POST",
"https://toolswitch.dev/v1/tools/companyenrich.geo.cities.search",
headers={"X-Toolswitch-Key": os.environ["TOOLSWITCH_KEY"]},
json=json.loads("{\"query\":\"san fran\",\"countryCodes\":[\"US\"]}"),
)
response.raise_for_status()
print(response.text)const response = await fetch("https://toolswitch.dev/v1/tools/companyenrich.geo.cities.search", {
method: "POST",
headers: {
"X-Toolswitch-Key": process.env.TOOLSWITCH_KEY ?? "",
"Content-Type": "application/json",
},
body: JSON.stringify(JSON.parse("{\"query\":\"san fran\",\"countryCodes\":[\"US\"]}")),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
console.log(await response.text());网关接口为 Beta,地址与鉴权方式可能变更。 示例参数仅为样例数据。 调用按 free 计费,已含服务费。