Request parameters
Look up a city code, find destinations by name or country, or export the city directory.
| Parameter | Required | Default | Description |
apikey |
Yes | None | Your assigned API key. Get a free test API key. |
code |
Conditional | None | Three-letter IATA city code, such as NYC. |
country_code |
Conditional | None | Two-letter ISO country code, such as US, to retrieve cities in a country. |
name |
Conditional | None | City name or partial name for search matching. |
dump |
Conditional | 0 | Set to 1 to export the complete database. Overrides the other lookup parameters. |
response_type |
No | JSON | Response format: JSON, XML or CSV. CSV triggers a file download. |
Provide at least one of code, country_code, name, or dump=1. The Cities API uses code, not iata, for a city-code lookup.
View all request parameters →
Common implementation tasks
Download city codes for your destination selector
Export the city directory as CSV and build a local search index from codes, names, countries and available state details. Display enough location context to help travelers distinguish cities with similar names.
curl --get 'https://content.airhex.com/api/v3.7.10/cities/' \
--data-urlencode 'apikey=YOUR_API_KEY' \
--data-urlencode 'dump=1' \
--data-urlencode 'response_type=CSV' \
--output city-codes.csv
Find a city code from a destination name
Search with name and read code from the returned records. Partial matching can produce several results, so compare country and state details before choosing a destination.
curl --get 'https://content.airhex.com/api/v3.7.10/cities/' \
--data-urlencode 'apikey=YOUR_API_KEY' \
--data-urlencode 'name=New York'
Build a destination list for a country
Pass country_code=US to retrieve city records for the United States. Use their codes and names for a country-specific destination list; flight availability must come from your booking supplier.
curl --get 'https://content.airhex.com/api/v3.7.10/cities/' \
--data-urlencode 'apikey=YOUR_API_KEY' \
--data-urlencode 'country_code=US'
Find airports associated with a city
After resolving a city, pass its code as city_code to the Airports API. This example requests airports with commercial flights associated with NYC. Keep each airport’s own code and name when displaying airport choices; the Cities API response does not contain an airport list.
curl --get 'https://content.airhex.com/api/v3.7.10/airports/' \
--data-urlencode 'apikey=YOUR_API_KEY' \
--data-urlencode 'city_code=NYC' \
--data-urlencode 'major_only=1'
Frequently asked questions
How is an IATA city code different from an airport code?
A city code identifies a destination at city level, while an airport code identifies an individual airport. A city can be associated with multiple airports. Keep the supplier’s location type alongside its code so your application knows whether to look up a city or an airport.
Which parameter should I use to look up a city code?
Use code on the Cities API, such as code=NYC. The Airports API uses iata for an individual airport lookup and city_code to find airports associated with a city. These parameter names are specific to their endpoints.
Can I use this for an “all airports” destination option?
Use the city record to label the destination and the Airports API to retrieve associated airports. Confirm how your flight supplier accepts city-level searches and which airports it includes. City reference data alone does not define a supplier’s search coverage or guarantee a bookable route.
Can I find a city code by searching its name?
Yes. The name parameter supports partial matching. Compare the returned name, country_code and available state fields instead of automatically selecting the first result. Preserve the selected city code and identity once the user chooses a destination.
Does every city have an IATA code?
Do not treat this directory as a list of every municipality. Build your code lookup from the returned city records, and check that code is populated before creating a code-based mapping. Handle destinations that your application cannot resolve without guessing a code from their names.
Are state and province names available for every country?
The documented state_short and state_full fields apply to cities in the United States, Canada and Australia. Handle empty values for other destinations and use the city name and country code as the basic display context.
Can I download and store the city code directory?
Yes, with an appropriate GEO Essentials license. Use dump=1 and choose JSON, XML or CSV with response_type. Retain airhex_id as the permanent record identifier and updated from the full response, and refresh your local directory periodically.
Does this include flight routes, fares or availability?
No. The Cities API provides destination reference data. Use your flight supplier for route coverage, schedules, fares and availability; a city appearing in the directory does not establish that a particular journey is available to book.