13

anyone know of a solution? i have found online a select menu for countries, but i need either an API or a database with every state/province and major city in each country.

Test Tester
  • 1,409
  • 4
  • 14
  • 14
  • Are you asking for an API, or for a database of cities and states? – Jonathan Hall Jul 12 '11 at 03:49
  • Brilliant idea 21029 of mine was to provide a web service for exactly this problem... plus timezones. Just haven't gotten around to it yet. – John Mee Jul 12 '11 at 03:59
  • I am using this and works great !! https://www.universal-tutorial.com/rest-apis/free-rest-api-for-country-state-city – Mahesh G Dec 14 '19 at 16:25

2 Answers2

8

Take a look at GeoNames. You can download (just about) everything they have and create your own local databases, or you can use their REST Webservice API. As an added bonus, they even have already made client libraries.

Yanick Rochon
  • 51,409
  • 25
  • 133
  • 214
0

If you just want users to be able to select a location, you could use a search-based interface such as OSM Nominatim. You can download the data and install it yourself, or just use their web services (subject to usage limits). Indeed, you might be able to download the Nominatim database and write a different API to use menus to drill down.

z0r
  • 8,185
  • 4
  • 64
  • 83