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?
Update:
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.
Examples:
{"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? Does GeoNames
I will be grateful for any suggestion or help.