Back to Docs

City Search

City Search (Autocomplete)

Search for cities by name prefix to build autocomplete functionality. Perfect for helping users select the correct city before making astrology calculations.

Free Endpoint

This endpoint is completely free and does not require an API key. Use it to improve your user experience without using API credits.

Endpoint

GEThttps://astro-api-1qnc.onrender.com/api/v1/geo/search

Query Parameters

ParameterTypeRequiredDescription
qstringYesSearch query (city name prefix). Minimum 2 characters.
limitintegerNoMaximum results to return. Default: 10, Maximum: 50.
countrystringNoFilter by ISO 3166-1 alpha-2 country code (e.g., 'US', 'FR', 'GB').

Code Examples

# Search for cities starting with "paris"
curl "https://astro-api-1qnc.onrender.com/api/v1/geo/search?q=paris&limit=5"

# Filter by country code
curl "https://astro-api-1qnc.onrender.com/api/v1/geo/search?q=london&country=GB&limit=3"

Response Fields

FieldTypeDescription
resultsarrayList of matching cities
results[].namestringCity name
results[].countrystringISO country code
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": "Paris",
      "country": "FR",
      "lat": 48.85341,
      "lng": 2.3488,
      "timezone": "Europe/Paris",
      "population": 2138551
    },
    {
      "name": "Paris",
      "country": "US",
      "lat": 33.66094,
      "lng": -95.55551,
      "timezone": "America/Chicago",
      "population": 24782
    }
  ],
  "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