Back to Docs

City Search

City Search

City Search (Autocomplete)

Search cities, localities, and suburbs so users can select the correct location before making astrology calculations.

Note: To ensure fast performance, broad queries (less than 4 characters, e.g., "San") are automatically limited to 5 results. Be specific (e.g., "San Francisco") for more results.
Indian localities: Geo V2 can return Indian cities, localities, and suburbs directly from the search query. The optional country parameter is only for narrowing ambiguous global matches.

Endpoint

GEThttps://api.freeastroapi.com/api/v2/geo/search

Requires an x-api-key header.

Live Geo V2 Test

Top 5 results update as you type.

Query Parameters

ParameterTypeRequiredDescription
qstringYesSearch query (city name prefix). Minimum 2 characters.
limitintegerNoMaximum results to return. Default: 10, Maximum: 50. Note: For search queries shorter than 4 characters, the limit is automatically capped at 5 for performance.
countrystringNoOptional ISO 3166-1 alpha-2 country filter for narrowing ambiguous global matches. Not required for Indian cities, localities, or suburbs.

Code Examples

# Search for cities starting with "paris"
curl -H "x-api-key: YOUR_API_KEY" "https://api.freeastroapi.com/api/v2/geo/search?q=paris&limit=5"

# Search Indian localities and suburbs without a country filter
curl -H "x-api-key: YOUR_API_KEY" "https://api.freeastroapi.com/api/v2/geo/search?q=mulund&limit=5"

India Districts

Indian places include an additional district field when district data is available. This helps distinguish places with the same city or locality name, such as Vangaon in Palghar versus Aurangabad.

For non-Indian results, district is returned as null. Existing fields remain unchanged, so clients can continue reading name, country, state, coordinates, timezone, and population.

Response Fields

FieldTypeDescription
resultsarrayList of matching cities
results[].namestringCity name
results[].countrystringISO country code
results[].statestring | nullState, province, region, or first-level administrative area when available
results[].districtstring | nullDistrict for Indian places only. Non-Indian results return null.
results[].latfloatLatitude
results[].lngfloatLongitude
results[].timezonestringIANA timezone identifier (e.g., 'Europe/Paris')
results[].populationintegerCity population (used for sorting)
countintegerNumber of results returned

Sample Response

{
  "results": [
    {
      "name": "Vāngaon",
      "country": "IN",
      "state": "Maharashtra",
      "district": "Palghar",
      "lat": 19.87621,
      "lng": 72.76267,
      "timezone": "Asia/Kolkata",
      "population": 0
    },
    {
      "name": "Vangaon",
      "country": "IN",
      "state": "Maharashtra",
      "district": "Aurangabad",
      "lat": 20.56385,
      "lng": 75.36115,
      "timezone": "Asia/Kolkata",
      "population": 0
    }
  ],
  "count": 2
}

💡 Recommended Usage

Use this endpoint to build city autocomplete in your application:

  1. User starts typing a city name in your form
  2. After 2+ characters, call this endpoint with the input
  3. Display results as a dropdown for the user to select from
  4. When user selects a city, use the lat, lng, and timezone values in your astrology API calls

This ensures users always select a valid city that the API can resolve, avoiding coordinate lookup errors.

Next Steps