Retrieve a list of country names using Google places api

Yiling picture Yiling · Jul 17, 2015 · Viewed 21.3k times · Source

How can we get a list of countries/stats/cities in the world using Google places API? Using either google api javascript library or google api web service interface.

Answer

yahermann picture yahermann · Aug 14, 2015

I don't believe that's allowed under the license terms of the Google Places API.

Instead, I suggest using http://geonames.org. Their data is updated very frequently and is licensed under a Creative Commons attribution license: http://creativecommons.org/licenses/by/3.0/

For country names & stats, the file is located here: http://download.geonames.org/export/dump/countryInfo.txt

All available downloads are here: http://download.geonames.org/export/dump/

So, to get the list of all places within a country that you requested, just fetch the zip file with the 2-letter ISO country code. For example, to get all places within the United States, fetch this file: http://download.geonames.org/export/dump/US.zip

Once fetched, you further have to filter the list in order to only get the cities.

Alternatively, if you're ok with just cities with population > 1000, use this file: http://download.geonames.org/export/dump/cities1000.zip

In fact, I recommend the 2nd approach, because all cities can be a very big list.

For more info and a list of all the files available: http://download.geonames.org/export/dump/readme.txt

Good luck on your project!