Get your visitor's country from their IP.
Country API is a free Geocoding API that requires no API key, is served over HTTPS and supports CORS, so it can be called from the browser.
Country is a free IP-to-country geolocation API that returns a user’s country based on their IP address.
Details from country.is.

Unified API suite · now live
Geocode an address, validate an email, track a flight or pull stock data with one account, one dashboard and one API key.
World countries, states, regions, provinces, cities & towns in JSON, SQL, XML, YAML, & CSV format
Brazil RESTful API to find information about streets, zip codes, neighborhoods, cities and states
The Country API is provided by Country (country.is). Country is a free IP-to-country geolocation API that returns a user’s country based on their IP address.
Yes. The Country API is listed in the Geocoding category of the public-apis directory, which only includes APIs that are free or have a free tier. Check its documentation for rate limits and paid plans.
No. The Country API requires no authentication, so you can start making requests without signing up.
Yes. The Country API supports CORS, so front-end JavaScript can call it directly.
Yes. The Country API is served over HTTPS, so it's safe to use in production.