Skip to content
BestAstroAPI

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.

FieldTypeDescription
latnumberrequiredLatitude, -90 to 90 (north positive)
lonnumberrequiredLongitude, -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"

Try it live

Sends a real request from your browser.

Response

  • [] is a list. {key} is a key that varies.
FieldTypeMeaning
latnumberdegreesLatitude you sent
lonnumberdegreesLongitude you sent
distance_kmnumberkmDistance to the place
placePlaceThe closest place

Objects used above

Place A city, town or village.

FieldTypeMeaning
idintegerStable id. Send it as place_id to any calculation
namestringName
districtstring or nullDistrict or county
statestring or nullState or province
countrystringCountry
country_codestringTwo-letter country code
labelstringReady to show: name, district for smaller places, state, country
latnumberdegreesLatitude
lonnumberdegreesLongitude
tzstringIANA time zone
populationinteger or nullPopulation. Null when not known, which is usual for villages
matchstringWhy it is listed. Only in place search optionalexact | starts_with | contains | other_name | similar
utc_offsetstringUTC 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.

Welcome! How will you use it?

We'll show you what matters to you. You can switch any time at the top.