Skip to content
BestAstroAPI

Places & time zones

Place search

GET/v1/places/search

Search as you type for a city, town or village: coordinates, time zone, district, state and country.

  • Covers more than 5.5 lakh places in India and 2.3 lakh worldwide.
  • Finds old names (Bombay, Allahabad), Indian scripts and other spellings.
  • Narrow the search after a comma: Rampur, Uttar Pradesh or rampur, up.
  • Keep the id of the place the user picked and send it as place_id to any calculation.
  • match is exact, starts_with, contains (a later word), other_name (an older or other name) or similar (spelled differently).
  • Always let the user pick; never take a similar match for them.
  • Call it from your server, so your key stays there.
  • Wait about 200 ms after the last keystroke. Each search is one call.
  • The same fields can be sent as a JSON body with POST.
  • Village coordinates are approximate. An error of 2 km moves the ascendant by about 0.02 degrees.
  • Place data: GeoNames, CC BY 4.0, adapted.

Request

Send these in the query string.

FieldTypeDescription
qstringrequiredThe name, or its first letters. Add a district, state or country after a comma
countrystringTwo-letter country code, for example IN, to search one country only
limitintegerPlaces to return, 1-50 (default 10)
datetimestringLocal date and time; adds the UTC offset in force then to every place

Example

curl -X GET "https://api.bestastroapi.in/v1/places/search?q=gorakh&country=IN&limit=3" \
  -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
querystringThe text you sent
countintegerPlaces returned
placesPlace[]Best match first. Can be empty

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
{
  "count": 3,
  "places": [
    {
      "country": "India",
      "country_code": "IN",
      "district": "Gorakhpur",
      "id": 1270927,
      "label": "Gorakhpur, Uttar Pradesh, India",
      "lat": 26.76628,
      "lon": 83.36889,
      "match": "starts_with",
      "name": "Gorakhpur",
      "population": 674246,
      "state": "Uttar Pradesh",
      "tz": "Asia/Kolkata"
    },
    {
      "country": "India",
      "country_code": "IN",
      "district": "Fatehabad",
      "id": 1270926,
      "label": "Gorakhpur, Fatehabad, Haryana, India",
      "lat": 29.44768,
      "lon": 75.67206,
      "match": "starts_with",
      "name": "Gorakhpur",
      "population": 13068,
      "state": "Haryana",
      "tz": "Asia/Kolkata"
    },
    {
      "country": "India",
      "country_code": "IN",
      "district": "Betul",
      "id": 1270932,
      "label": "Gorakhar, Betul, Madhya Pradesh, India",
      "lat": 21.78483,
      "lon": 77.90199,
      "match": "starts_with",
      "name": "Gorakhar",
      "population": null,
      "state": "Madhya Pradesh",
      "tz": "Asia/Kolkata"
    }
  ],
  "query": "gorakh"
}

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.