News for hackers. Stuff that matters.

Ask HN: API to discover lat/long coordinates from a city name and country

Hi everyone, I have a list of city names say, all the cities in Germany, and I want to get lat/lng coordinates for each one of them.

Is there any API I can use to get this kind of data? Google and Foursquare did not seem to help with that

thanks for your time

UPDATE: you people are amazing, thanks for the responses!

( 6 comments | 2 points | on HN )
Re:Ask HN: API to discover lat/long coordinates from a city ... by conductor on Tuesday October 07, 2014 @03:45PM (#8423543)
It's called geocoding. There are several free services who provide API. Here are two of them from the first page of my search results:

https://geoservices.tamu.edu/Services/Geocode/WebService/

http://developer.mapquest.com/web/products/dev-services/geoc...

Re:Ask HN: API to discover lat/long coordinates from a city ... by rodrigoavie on Tuesday October 07, 2014 @03:57PM (#8423611)
thank you so much!
Re:Ask HN: API to discover lat/long coordinates from a city ... by taurenk on Tuesday October 07, 2014 @03:54PM (#8423591)
Geonames.org has files containing zip code, city and, lat/lon: http://download.geonames.org/export/zip/

Hope this helps.

Re:Ask HN: API to discover lat/long coordinates from a city ... by rodrigoavie on Tuesday October 07, 2014 @03:58PM (#8423619)
Sure it helps! Even if this database does not contain every city that I wanna check, it definitely helps.

thank you very much

Re:Ask HN: API to discover lat/long coordinates from a city ... by runlevel1 on Tuesday October 07, 2014 @03:43PM (#8423522)
Google's Geocoding API does just that.

Example:

    https://maps.googleapis.com/maps/api/geocode/json?address=Berlin&sensor=false
Re:Ask HN: API to discover lat/long coordinates from a city ... by rodrigoavie on Tuesday October 07, 2014 @03:57PM (#8423610)
thanks! That is exactly what I was looking for!