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


I was looking for some json API that lists the states of a certain country, or cities of a certain state, I looked for this functionality through 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 cumbersome.

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 is also even better.

Is there a good option?


You can use the geonames.org public service.

This example page shows the service calls:


The specific function you want to use is Children , which returns collections of child entities for a given GeoNameID – countries of a continent, states of a country, cities of 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), get the list of countries


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


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

Scroll to Top