json – Is there an API that lists states and cities?


I've been looking for some json API that lists the states of a certain country, or cities of a certain state, I searched for this feature for several Google Maps APIs but I didn't find anything that was exactly for this.

I don't want to use a DB with a list of states and cities because I believe it lacks flexibility and is quite heavy.

Note: the need is to create a combobox of countries, states and cities, but I can use a list of countries directly from the database without any problem, but if there is an API that makes this list available, it's also even better.

Is there a good option?


You can use the geonames.org public service.

This example page shows calls to the service:


The specific function you want to use is Children , which returns collections of GeoNameID entities of a given GeoNameID – countries in a continent, states in a country, cities in a state, and so on.

The example above makes the following calls:

  1. Get a list of continents


  2. After selecting South America ( GeoNameID 6255150), you get the country list


  3. After selecting Brazil ( GeoNameID 3469034), you get the list of states


The end result is a list similar to the example below:

Scroll to Top