namestring必填
Location name or postal code. Append `, ` or `, ` to narrow results.
https://api.sandbase.ai/v1/api/open-meteo/geocodingLook up places by name and get coordinates, country, timezone, population and elevation for use with the weather APIs.
您的輸出會顯示在這裡
完成輸入後,點擊執行。
Returns a list of places that match a name or postal code, with coordinates, country, timezone, population and elevation for each match. The only required input is name, for example Berlin.
latitude and longitude for a weather request.timezone of a place before you format forecast times.curl -X POST "https://api.sandbase.ai/v1/api/open-meteo/geocoding" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Berlin"}'
The result is returned in outputs[0].data.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Location name or postal code. Append , or , to narrow results. |
count | integer | No | Maximum number of results (1-100). Default 10. |
countryCode | string | No | ISO-3166-1 alpha-2 country code to filter results. |
format | string | No | Response format. Default json. |
language | string | No | Two-letter language code for translated names. Default en. |
Real response for the request above, trimmed: lists keep their first item and long strings are cut.
{
"generationtime_ms": 0.23376942,
"results": [
{
"admin1": "State of Berlin",
"admin1_id": 2950157,
"admin3": "Berlin, Stadt",
"admin3_id": 6547383,
"admin4": "Berlin",
"admin4_id": 6547539,
"country": "Germany",
"country_code": "DE",
"country_id": 2921044,
"elevation": 74.0,
"feature_code": "PPLC",
"id": 2950159
}
]
}
| Field | Meaning |
|---|---|
results[] | List of matching places. The first entries are the best matches for name. |
results[].name | Name of the place, translated to the language you request. |
results[].latitude / results[].longitude | Coordinates of the place in decimal degrees. Pass these to the weather APIs. |
results[].timezone | IANA timezone name of the place, such as Europe/Berlin. |
results[].elevation | Elevation of the place. Open-Meteo Elevation can return the same kind of value for any coordinate. |
results[].population | Number of inhabitants listed for the place. Use it to rank places that share a name. |
results[].country / results[].country_code | Country name and its two-letter ISO country code. |
results[].admin1 / results[].admin2 / results[].admin3 / results[].admin4 | Names of the administrative areas that contain the place, from the largest (such as state) to smaller ones. Not every level appears for every place. |
results[].id | Numeric ID of the place. The admin1_id, admin2_id, admin3_id, admin4_id and country_id fields hold the IDs of the matching areas. |
results[].postcodes[] | Postal codes that belong to the place. |
countryCode, for example DE, to keep only results from one country.count (1-100) to change how many results come back. The default is 10.latitude and longitude from a result to Open-Meteo Weather Forecast, and add timezone to get local times.feature_code describes the type of place. For example, PPLC marks the capital in the Berlin, Germany result.$0.0001 per successful call. Failed calls are not charged. It is included in the daily free quota of each organization.
開始建置
具備統一驗證與用量追蹤的平台 API 端點。
curl -X POST "https://api.sandbase.ai/v1/api/open-meteo/geocoding" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Berlin",
"count": 5,
"format": "json",
"language": "en",
"countryCode": "DE"
}'請將您的 SandBase API 金鑰設定在伺服器環境中。請求使用 Bearer 驗證。
export SANDBASE_API_KEY="YOUR_API_KEY"請將金鑰保留在伺服器端,不要在瀏覽器程式碼中公開。
namestring必填Location name or postal code. Append `, ` or `, ` to narrow results.
countintegerMaximum number of results (1-100). Default 10.
預設:10
countryCodestringISO-3166-1 alpha-2 country code to filter results.
formatstringResponse format. Default `json`.
預設:"json"
可能值:json, protobuf
languagestringTwo-letter language code for translated names. Default `en`.
預設:"en"
這是此 API 的已儲存範例回應;檢視時不會發出即時請求。
尚未發布已儲存回應。請在 Playground 中執行 API 以檢視其回應。
探索更多
| API | 價格 | 回應 |
|---|---|---|
Open-Meteo Geocoding此 API Open-Meteo | 每次呼叫 $0.0001 | JSON |
Open-Meteo | 每次呼叫 $0.0001 | JSON |
Open-Meteo | 每次呼叫 $0.0001 | JSON |
Open-Meteo | 每次呼叫 $0.0001 | JSON |
Open-Meteo | 每次呼叫 $0.0001 | JSON |
Open-Meteo | 每次呼叫 $0.0001 | JSON |
問題
使用 POST 請求將您的 SandBase API 金鑰放在 Authorization 標頭(Bearer)中,並以 JSON 主體傳入參數,即可呼叫 https://api.sandbase.ai/v1/api/open-meteo/geocoding。您也可以直接在本頁的 Playground 試用,不必撰寫程式碼。
每次 $0.0001,並從您的 SandBase 餘額中扣款。您只會為實際發出的呼叫付費;沒有訂閱方案。
必要:name (string)。 選填:count (integer), countryCode (string), format(json, protobuf 之一) 和 language (string)。 本頁的 Parameters 表格與 Playground 會列出每個欄位。
在同一個 HTTP 請求中回傳的 JSON 回應(同步)。 本頁的 README 包含範例回應。
不需要。Open-Meteo Geocoding 是透過 SandBase 運作,因此一組 SandBase API 金鑰即可使用此端點以及目錄中的其他所有 API 和模型。您不需要另外申請 Open-Meteo API 存取權。