apilayer / restcountries

Get information about countries via a RESTful API
https://restcountries.eu
Mozilla Public License 2.0
2.24k stars 355 forks source link

API lists local region codes as "calling codes" #91

Open guss77 opened 6 years ago

guss77 commented 6 years ago

As described in the issue https://github.com/mledoze/countries/issues/114 on a similar project with a similar problem, this API returns multiple calling codes which are actually the country code that is shared with another country followed by several regional prefixes.

In actuality, each country has only one country code (See https://en.wikipedia.org/wiki/List_of_country_calling_codes ), but there are several countries that share the same country code, for example: +1 is the country code for NANPA that serves 25 countries.

This makes it a real problem for applications (like mine) that shows a user a drop down to select a country and then they can type the national part of their phone number and the application automatically composes the full international E164 number. If a Dominican user selects "Dominica" and the application chooses "+1767" as the international prefix, then the user types what they know as the national part of their phone number "7675551234", the application will incorrectly compose an E164 number "+17677675551234".

The reverse problem can be seen when running a lookup by calling code - I'd expect that searching for "1" will return all 25 countries but it only returns Canada and US - Which begs the question - why is Canada exempt from "your are using +1 international code but you're not USA so we'll list your area codes individually"? It only has 39 area codes - why aren't they listed separately under calling codes?

All this just to illustrate the point - either the mode has one calling code for each country and countries can share colling codes, or its the other way around and countries do not share calling codes and you list for each country all their non-conflicting E163 prefixes.

0xbayo commented 5 years ago

While this issue have been fixed in the pull request #126 (which have also been merged), the server still returns the old data.