Places & time zones
Nearest place
GET/v1/places/nearest
The closest known place to a latitude and longitude, with its time zone.
- Useful for "use my location".
Request
Send these in the query string.
| Field | Type | Description |
|---|---|---|
| lat | numberrequired | Latitude, -90 to 90 (north positive) |
| lon | numberrequired | Longitude, -180 to 180 (east positive) |
Example
curl -X GET "https://api.bestastroapi.in/v1/places/nearest?lat=28.6139&lon=77.209" \
-H "x-api-key: $BESTASTRO_KEY"Response
[]is a list.{key}is a key that varies.
| Field | Type | Meaning |
|---|---|---|
| lat | numberdegrees | Latitude you sent |
| lon | numberdegrees | Longitude you sent |
| distance_km | numberkm | Distance to the place |
| place | Place | The closest place |
Objects used above
Place A city, town or village.
| Field | Type | Meaning |
|---|---|---|
| id | integer | Stable id. Send it as place_id to any calculation |
| name | string | Name |
| district | string or null | District or county |
| state | string or null | State or province |
| country | string | Country |
| country_code | string | Two-letter country code |
| label | string | Ready to show: name, district for smaller places, state, country |
| lat | numberdegrees | Latitude |
| lon | numberdegrees | Longitude |
| tz | string | IANA time zone |
| population | integer or null | Population. Null when not known, which is usual for villages |
| match | string | Why it is listed. Only in place search optionalexact | starts_with | contains | other_name | similar |
| utc_offset | string | UTC offset at datetime. Only in place search with datetime optional |
Raw sample
200 application/json
{
"distance_km": 1.01,
"lat": 28.6139,
"lon": 77.209,
"place": {
"country": "India",
"country_code": "IN",
"district": "New Delhi",
"id": 1261481,
"label": "New Delhi, Delhi, India",
"lat": 28.62137,
"lon": 77.2148,
"name": "New Delhi",
"population": 317797,
"state": "Delhi",
"tz": "Asia/Kolkata"
}
}Real output for the example request above.
Errors use one format. See error codes. Also in openapi.json.