Closed fcpauldiaz closed 3 years ago
Could you explain more what you mean?
api returns iso3 country code. like USA, but can it be configured to return iso2 like US?
@fcpauldiaz
Currently, there are endpoints you can use to get iso2 and iso3 of any country.
For instance, sending a GET
to https://countriesnow.space/api/v0.1/countries/iso
would return a response like this:
"error": false,
"msg": "countries and ISO codes retrieved",
"data": [
{
"name": "Afghanistan",
"Iso2": "AF",
"Iso3": "AFG"
},
{
"name": "United States",
"Iso2": "US",
"Iso3": "USA"
},
],
...
Here you have a list of all the countries and their iso2 and iso3 codes. If you need a single country, just change the request type to POST
using the same endpoint https://countriesnow.space/api/v0.1/countries/iso
and you'll get a single country's iso2 and iso3 code.
curl -d '{"country":"nigeria"}' -H "Content-Type: application/json" -X POST https://countriesnow.space/api/v0.1/countries/iso
Response:
{
"error": false,
"msg": "country's ISO code retrieved",
"data": {
"name": "Nigeria",
"Iso2": "NG",
"Iso3": "NGA"
}
}
Does this answer your question?
Yes, thanks!
is there a way to get 2 iso country code instead of 3 ?