Original question:

I create an web application and I need to obtain the information contained in the question on the backend side of my application.

What I need the most is the automatic retrieval of information about the city based on the name of the country and the postal code. State is optional.

I would like to have free use in commercial use, but if there is no free solution to this question, what is the cheapest solution?

Do you know about such API?

If so, is the use of it related to any quantitative limits or legal restrictions?


I have in database information about country and postcode provided by users in form on my site. This may apply to the whole world. The names of countries are always correct and the postal code is not necessarily.

What do I want to receive?

If the postal code is incorrect for a given country, I want to receive information: the place does not exist and the state does not exist.

If the postal code is correct for the given country, but there is no administrative division into the state in this country, I want to get the name of the town that this postal code refers to and the information that the state does not exist (or the name of the country).

If the postal code is correct for a given country and there is an administrative division into the state in this country, I would like to receive the name of the location to which the zip code applies and the name of the state or province in which it is located.

By the name of the location I understand: the name of the village, town or town to which the postal code is assigned. If possible, I would not like to get district names here, but if it is problematic, they can be.

By state I understand the largest administrative unit on which the country is divided. It may be a state, a province, a region, an island name, etc. As far as possible, I would not like to receive the names of districts, communes, counties etc. in this place, but if it is problematic, it can be.


{"countryName": "United States of America", "postalCode": "90201"}
    => {"locationName": "Los Angeles", "stateName": "California"}

{"countryName": "United Kingdom", "postalCode": "PH33 6DB"}
    => {"locationName": "Fort William", "stateName": "Scotland"}

{"countryName": "Poland", "postalCode": "11-230"}
    => {"locationName": "Biegonity", "stateName": "warmińsko-mazurskie"}

{"countryName": "Italy", "postalCode": "97019"}
    => {"locationName": "Vittoria, "stateName": "Sicilia"}

{"countryName": "Mongolia", "postalCode": "65193"} 
    => {"locationName": "Цэцэрлэг", "stateName": "Хангайн бүс"}

However, if it is a big problem to serve information from the whole world, maybe at least I can get information from some continents or countries (e.g. North America and Europe etc.).

What I took into account?

  • I do not have much experience in this matter, but from what I see most of the Geolocation API works in such a way that it works with geographic co-ordinates of the earth, but it's not my case at the moment.

  • I think that the Google Geocoding API could handle this task, because I can give the address (maybe even not full like in my case) and it can return a lot of information about the address from which I could extract something..., but I must have an account, and what prevents me from setting up this account is that this service is paid, and I would not like to pay additional costs if I do not have to.

  • Maybe also it would be a good idea to put own database with the right information, but where to get a reliable database for commercial use, which is free or not too expensive?

closed as too broad by PolyGeo Oct 8 '18 at 23:44

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    For the whole world? Some countries don't have postal codes. What "information about the city" do you want? What if the location isn't in a city? – Spacedman Sep 14 '18 at 11:15
  • @Spacedman Yes, I need it to work internationally, but of course, where it is possible and where it makes sense. As for the city, I mean the name of the town. – simhumileco Sep 14 '18 at 11:27
  • I don't understand why this question receives negative points. I would be charmed if someone explained it to me. – simhumileco Sep 14 '18 at 11:30
  • 1
    downvotes are for "this question does not show any research effort". If you listed some of the possible geocoding solutions that you have found, and reasons for them not being adequate for your purposes, that would show research effort and help us find solutions. If you haven't looked using the usual internet search techniques, you should do that first. – Spacedman Sep 14 '18 at 12:02
  • 1
    The close vote is for "unclear", since you didn't say you wanted the whole world, or what to do if the postcode isn't anywhere near a city or town or other urban object. You've also not given any examples, for example saying you have data like "USA : 90201", "UK : LA23" or such. – Spacedman Sep 14 '18 at 12:04