Locale info from IP - IP-Locator.xyz
I recently wrote microservice in Python with Flask that maps a user’s IP address to their location and provides country, locale, timezone and keyboard layout information.
I wrote it because I was using another service which did similar, but it stopped working when using it with my Void Linux installation scripts. I use this service to detect the user’s location from their IP, to set the locale, closest repository mirror, timezone and keyboard layout.
The service is designed to be used as a useful API in scripts or programs and supports providing information in tabular (HTML), plain text (line-by-line), JSON and XML formats.
For instance, the client can get their location information in tabular form by visiting https://ip-locator.xyz/table/client:
But we can also save it with curl:
curl -s https://ip-locator.xyz/table/client > response.html
Another typical use (and what I use with my void-setup script) is to receive the file in plain text:
curl -s https://ip-locator.xyz/text/client > response
Where the response file is something like:
GB
United Kingdom
https://flagsapi.com/GB/flat/64.png
London
Europe
cy_GB
en_GB
Europe/London
[public IP v4 address]]
qwerty-uk
qwerty-en
We could get the response in JSON format, as with the following sample Python program:
This will print something like:
We can also get the record as JSON from a given public IP v4 address such as 159.89.16.14:
https://ip-locator.xyz/json/159.89.16.14
For a full list of API paths, please refer to the usage page:
I hope that you find this service useful.