Cities Database and Codes API

NOTE: This endpoint provides comprehensive geographic and demographic data for cities worldwide, matched with official IATA city codes. View all available API endpoints.

Don't have an API key for cities database API but want a try?

Get Started

API Endpoint Description
Retrieve geographic and demographic details for specific cities or export the complete cities database in JSON, XML, or CSV formats.

Endpoint Address
GET https://content.airhex.com/api/v3.7.3/cities

Example Request
https://content.airhex.com/api/v3.7.3/cities?apikey=WcPi7fGFMTihmwdNxkn4XYwZtdhKuykg&code=NYC

*Note: At least one query parameter (code, country_code, name, or dump) is required.

Request Parameters

Parameter Required Value Type Default Description
apikey Required Any String none Your assigned API key. Request a key if needed
code Conditional AAA-ZZZ String none Three-letter IATA city code
country_code Conditional AA-ZZ String none Two-letter ISO 3166-1 Alpha-2 country code
name Conditional Any String none City name or partial substring for search matching
dump Conditional 0 or 1 Integer 0 Set to 1 to export the complete database (ignores other parameters)
response_type Optional JSON or XML or CSV String JSON Response format: JSON, XML, or CSV (CSV initiates file download)

Response Fields

Field Example Description
code NYC City’s three-letter IATA code
country_code US ISO 3166-1 Alpha-2 country code
name New York City City’s name
state_short NY State/province abbreviation (US, CA, AU cities only)
state_full New York Full state/province name (US, CA, AU cities only)
latitude 40.7143528 Geographic latitude of the city center
longitude -74.0059731 Geographic longitude of the city center
city_photo new! https://content.airhex.com/content/city_photos/5333.jpg Licensed, commercially usable city image URL
timezone America/New_York City's timezone identifier
gmt -4 City's time offset from GMT
population 8992908 Population count of the city
popularity 43581634 Relative popularity index (higher value indicates higher destination popularity)


Example Response (JSON)
[
    {
        "code": "NYC",
        "country_code": "US",
        "name": "New York City",
        "state_short": "NY",
        "state_full": "New York",
        "latitude": "40.7143528",
        "longitude": "-74.0059731",
        "city_photo": "https:\/\/content.airhex.com\/content\/city_photos\/5333.jpg",
        "timezone": "America\/New_York",
        "gmt": "-4",
        "population": "8992908",
        "popularity": "43581634"
    }
]


Example Response (XML)
<?xml version="1.0" encoding="UTF-8"?>
<cities>
 <city>
  <code>NYC</code>
  <country_code>US</country_code>
  <name>New York City</name>
  <state_short>NY</state_short>
  <state_full>New York</state_full>
  <latitude>40.7143528</latitude>
  <longitude>-74.0059731</longitude>
  <city_photo>https://content.airhex.com/content/city_photos/5333.jpg</city_photo>
  <timezone>America/New_York</timezone>
  <gmt>-4</gmt>
  <population>8992908</population>
  <popularity>43581634</popularity>
 </city>
</cities>


Want to fetch full cities database?

Get a license