title is pretty clear.
My websites consists of both English-written and Spanish-written versions. You can go to the main site, which is in Spanish, by clicking http:
You can do a GET request to this URL: https://api.teletext.io/api/v1/geo-ip and it will respond with some country information in JSON format. See https://teletext.io/help/geo-location-service for usage.
If you want to implement it yourself: I've set this up by using AWS Cloudfront, Cloudfront adds a header (Cloudfront-Viewer-Country) to your request before it forwards it to the origin server that you can use. Make sure to whitelist the header in your Cloudfront distribution.