How do I find someone's country code by their browser?

How do I find the country that someone belongs to from their browser?

I am able to find the time zone via the date extension, but what about the country?

For example, I want it to return such that if example someone is from Singapore, it’s “SG”. If someone is from USA, return “US”.

Is there a way to find? Currently I am getting it from the phone country code number but it is not accurate as a singular country code can be for multiple countries.

I’d use their IP address to hit a 3rd party API, like IPinfo.io to return the country info.

You could get some informations about the language of the browser and other stuff via JavaScript, but that’s not really reliable, so yeah, as Wes said, probably some API.