# Location and Timezone API Reference

> Timezone and location API with city search and geocoding across 5,180,000+ cities, towns and villages in 240+ countries, returning latitude, longitude, IANA timezone, and DST-aware UTC offset. Coverage reaches every village on record, whatever its population, so a rural birthplace resolves as reliably as a capital. The location layer for birth chart forms, horoscope apps, event planners, and any feature that needs place-to-coordinates resolution. Fields map directly to the astrology endpoints, with no separate geocoding service to call or pay for. One key covers every RoxyAPI domain, with Remote MCP and typed SDKs.

## Search cities worldwide - Geocoding autocomplete with coordinates and timezone

`GET https://roxyapi.com/api/v2/location/search`. MCP tool `get_location_search`.

Turn a place name into coordinates, an IANA timezone and a DST-aware UTC offset, across 5,180,000+ cities, towns and villages in 240+ countries. Coverage reaches every village on record, whatever its population, so a birthplace outside a major metro resolves as reliably as a capital. Matching is case-insensitive, accent-insensitive and partial, so ber matches Berlin, Bern and Bergen, native scripts are transliterated, and historic names resolve to the current place, so bombay returns Mumbai and peking returns Beijing. A full name typed ranks above its smaller namesakes, a few letters reach the best-known city first, and a state, province or country in the query picks the right one of many places with the same name. A town name that matches nothing returns no match, never the largest town in the region it names. Built for birth chart location pickers, horoscope apps, event scheduling, and any feature that needs place-to-coordinates resolution.

### Request

- `q` (string, required): Place to search for, written the way a person would. Accepts a bare city (berlin), a city plus country (berlin germany), a comma-qualified place (richfield, utah), a fully qualified place (richfield, utah, united states), or a historic name (bombay, peking, constantinople). Commas are optional, and a qualifier the dataset spells differently, such as USA for United States, still resolves. Matched against city name, alternate names, state or province, and country. Add the state or country whenever the name is common, since that is what separates the six Springfields, and Richfield, Utah from Richfield, Minnesota.
- `limit` (integer): Maximum items to return per page. Range: 1-50, default 10.
- `offset` (integer): Number of items to skip for pagination. Default 0.

### Response

- `total` (number, required): Number of places matching the query across all pages, not the number returned in this response. Greater than 1 means the name is ambiguous, so show province and country and let the user confirm before using the result for a chart.
- `limit` (number, required): Page size used for this response.
- `offset` (number, required): Number of places skipped. Use with limit to page through results.
- `cities` (array of object, required): Matching places for the current page, best match first. Ordered by match quality, then population within equal quality: an exact name beats a qualified name such as richfield, utah, which beats a name merely starting with the query, which beats an incidental match on state or country. Take the first entry when total is 1, otherwise disambiguate on province and country.
- `cities[].city` (string, required): City name as commonly used. Matches the local or internationally recognized name for the location.
- `cities[].province` (string, required): State, province, canton, or administrative region. Show it whenever more than one result comes back: it is what separates Richfield, Utah from Richfield, Minnesota, and the six US Springfields from each other. Empty for the small number of places with no administrative division recorded.
- `cities[].country` (string, required): Full country name in English.
- `cities[].iso2` (string, required): ISO 3166-1 alpha-2 country code. Use for filtering cities by country or building country-specific location pickers.
- `cities[].latitude` (number, required): Geographic latitude in decimal degrees (-90 to 90). Pass directly to birth chart, natal chart, horoscope, synastry, transit, kundli, and panchang API endpoints as the latitude parameter.
- `cities[].longitude` (number, required): Geographic longitude in decimal degrees (-180 to 180). Pass directly to astrology, horoscope, and panchang API endpoints alongside latitude.
- `cities[].timezone` (string, required): IANA timezone identifier following the tz database standard (e.g. Europe/Berlin, America/New_York, Asia/Tokyo). Always present. Pass THIS, not the numeric offset, into any chart or panchang request for a past date: the calculation endpoints resolve it to the offset that was actually in force on that date, including historical daylight saving. Also works directly with JavaScript Date, Luxon, day.js, or any date library.
- `cities[].utcOffset` (number, required): UTC offset in decimal hours for TODAY at this place, already adjusted for daylight saving. Convenient for displaying local time now. For a birth date or any past date use the `timezone` field instead, since the offset in force then may differ. Examples: 1 for CET, 2 for CEST, -5 for EST, 5.5 for IST, 5.75 for Nepal.
- `cities[].population` (number, required): Population estimate for the place. Weighs the ranking, so among places matching a query alike the larger leads, while a full name typed still outranks a namesake many times its size. 0 for a place with no published figure, as most villages are.

### Example request

```bash
curl "https://roxyapi.com/api/v2/location/search?q=berlin" \
  -H "X-API-Key: YOUR_KEY"
```

### Example response

```json
{
  "total": 3,
  "limit": 10,
  "offset": 0,
  "cities": [
    {
      "city": "Berlin",
      "province": "Berlin",
      "country": "Germany",
      "iso2": "DE",
      "latitude": 52.52,
      "longitude": 13.405,
      "timezone": "Europe/Berlin",
      "utcOffset": 1,
      "population": 3644826
    }
  ]
}
```

## List all countries - ISO codes and city coverage

`GET https://roxyapi.com/api/v2/location/countries`. MCP tool `get_location_countries`.

Returns every country with ISO 3166-1 alpha-2 and alpha-3 codes, plus the number of searchable cities per country. Use this endpoint to build country dropdown menus, regional filters, or to check city coverage before querying a birth location. Countries are sorted alphabetically by name. Covers Europe, Americas, Asia, Middle East, Africa, and Oceania.

### Request

- `limit` (integer): Maximum items to return per page. Range: 1-250, default 50.
- `offset` (integer): Number of items to skip for pagination. Default 0.

### Response

- `total` (number, required): Total number of countries with at least one place in the dataset.
- `limit` (number, required): Page size used for this response.
- `offset` (number, required): Number of countries skipped. Use with limit for pagination.
- `countries` (array of object, required): Countries for the current page, sorted alphabetically by name.
- `countries[].name` (string, required): Full country name in English. Use for display in location pickers and dropdown menus.
- `countries[].iso2` (string, required): ISO 3166-1 alpha-2 country code. Use as the identifier when fetching cities for a specific country via the /countries/{iso2} endpoint.
- `countries[].iso3` (string, required): ISO 3166-1 alpha-3 country code. Three-letter standard used in international data exchange.
- `countries[].cityCount` (number, required): Number of searchable places in this country, every town and village included. Useful for showing coverage in a UI or sizing a dependent city dropdown.

### Example request

```bash
curl "https://roxyapi.com/api/v2/location/countries" \
  -H "X-API-Key: YOUR_KEY"
```

### Example response

```json
{
  "total": 246,
  "limit": 50,
  "offset": 0,
  "countries": [
    {
      "name": "Germany",
      "iso2": "DE",
      "iso3": "DEU",
      "cityCount": 11894
    }
  ]
}
```

## Get cities in a country - Geocoding directory sorted by population

`GET https://roxyapi.com/api/v2/location/countries/{iso2}`. MCP tool `get_location_countries_iso2`.

Returns all cities for a specific country, identified by ISO 3166-1 alpha-2 code (e.g. DE for Germany, FR for France, GB for United Kingdom, US for United States). Each city includes geographic coordinates, IANA timezone, and DST-aware UTC offset for direct use in astrology birth chart, horoscope, transit, and panchang calculations. Cities sorted by population with the largest metropolitan areas first.

### Request

- `iso2` (string, required): ISO 3166-1 alpha-2 country code, case-insensitive. Common codes: DE (Germany), FR (France), GB (United Kingdom), US (United States), ES (Spain), IT (Italy), NL (Netherlands), IN (India), BR (Brazil), JP (Japan).
- `limit` (integer): Maximum items to return per page. Range: 1-100, default 20.
- `offset` (integer): Number of items to skip for pagination. Default 0.

### Response

- `total` (number, required): Total number of places available for this country across all pages.
- `limit` (number, required): Page size used for this response.
- `offset` (number, required): Number of cities skipped. Use with limit for pagination.
- `cities` (array of object, required): Cities for the current page, sorted by population (largest first).
- `cities[].city` (string, required): City name as commonly used. Matches the local or internationally recognized name for the location.
- `cities[].province` (string, required): State, province, canton, or administrative region. Show it whenever more than one result comes back: it is what separates Richfield, Utah from Richfield, Minnesota, and the six US Springfields from each other. Empty for the small number of places with no administrative division recorded.
- `cities[].country` (string, required): Full country name in English.
- `cities[].iso2` (string, required): ISO 3166-1 alpha-2 country code. Use for filtering cities by country or building country-specific location pickers.
- `cities[].latitude` (number, required): Geographic latitude in decimal degrees (-90 to 90). Pass directly to birth chart, natal chart, horoscope, synastry, transit, kundli, and panchang API endpoints as the latitude parameter.
- `cities[].longitude` (number, required): Geographic longitude in decimal degrees (-180 to 180). Pass directly to astrology, horoscope, and panchang API endpoints alongside latitude.
- `cities[].timezone` (string, required): IANA timezone identifier following the tz database standard (e.g. Europe/Berlin, America/New_York, Asia/Tokyo). Always present. Pass THIS, not the numeric offset, into any chart or panchang request for a past date: the calculation endpoints resolve it to the offset that was actually in force on that date, including historical daylight saving. Also works directly with JavaScript Date, Luxon, day.js, or any date library.
- `cities[].utcOffset` (number, required): UTC offset in decimal hours for TODAY at this place, already adjusted for daylight saving. Convenient for displaying local time now. For a birth date or any past date use the `timezone` field instead, since the offset in force then may differ. Examples: 1 for CET, 2 for CEST, -5 for EST, 5.5 for IST, 5.75 for Nepal.
- `cities[].population` (number, required): Population estimate for the place. Weighs the ranking, so among places matching a query alike the larger leads, while a full name typed still outranks a namesake many times its size. 0 for a place with no published figure, as most villages are.

### Example request

```bash
curl "https://roxyapi.com/api/v2/location/countries/DE" \
  -H "X-API-Key: YOUR_KEY"
```

### Example response

```json
{
  "total": 11894,
  "limit": 50,
  "offset": 0,
  "cities": [
    {
      "city": "Berlin",
      "province": "Berlin",
      "country": "Germany",
      "iso2": "DE",
      "latitude": 52.52,
      "longitude": 13.405,
      "timezone": "Europe/Berlin",
      "utcOffset": 1,
      "population": 3644826
    }
  ]
}
```
