21

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.

Yiling
  • 2,817
  • 2
  • 21
  • 27
  • 4
    Could someone explain why this question got a down vote? can we remove the down vote because there have been clearly interests and answers to this question? – Yiling Sep 15 '16 at 21:21

2 Answers2

32

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!

yahermann
  • 1,539
  • 1
  • 12
  • 33
  • With geonames.org, it has published api for retrieving list of country names and state names for each country; then there is the api for retrieving all cities in the world. But If you want to retrieve a list of cities within a particular state/province, there is no dedicated api for it. – Yiling Aug 16 '15 at 00:48
11

Updated on 29 Jan 2022

For the country list and it's full detail download json file form this link. and use it in your project https://drive.google.com/file/d/1VBsGFi20SHElkQp82LP0EwZGEzQMQjWc/view.

Its free for use

Bijender Singh Shekhawat
  • 3,934
  • 2
  • 30
  • 36
  • 1
    This is down today, bringing our production app down with it. Let this be a teaching moment- Don't rely on 3rd parties to do this. Maintain your own simple lists and update when you need to. – Chris Fremgen Aug 18 '20 at 16:09
  • sorry for that. I update my answer. now you can download it and use it in your project. @ChrisFremgen thanks for your comment. – Bijender Singh Shekhawat Apr 29 '22 at 05:07