Algobook
- The developer's handbook
mode-switch
back-button
Buy Me A Coffee

City API

We provide a free city look up API that can be used for searching for a city and getting information such as population, country and coordinates.

As for all our APIs, there is no sign up or API keys required, just fire your requests and enjoy our free data.

Usage

To use the API, just send in your search param for the city, and we will return the best match.

Example of exact match

If you send in the whole name of the city, we will return it for you

const response = await fetch("https://api.algobook.info/v1/city?search=Berlin"); const data = await response.json();

Response

{ "city": { "id": 2950159, "name": "Berlin", "population": 3426354, "lat": 52.5166667, "lon": 13.4, "country": "Germany" } }

Example of fuzzy search

const response = await fetch( "https://api.algobook.info/v1/city?search=philade" ); const data = await response.json();

Response

{ "city": { "id": 4560349, "name": "Philadelphia", "population": 1517550, "lat": 39.952335, "lon": -75.163789, "country": "United States" } }

Known limitations

The data source is from Sweden, we are trying to locate the cities that sometimes can have a local swedish translation and fix it - for most part it is not a concern but it might be some cases where the city translation will not be 100% accurate in English.

Feedback

If you feel something is missing or if something is wrong, please don't hesitate to contact us with your feedback. Email can be found here.

signature
See all our articlesSee all our open source projects