Does anyone know of a simple way to retrieve the country for a given IP Address? Preferably in ISO_3166-1 format?
相关问题
- Google places autocomplete suggestion without coun
- Golang mongodb aggregation
- How to change the IP address of a docker after cre
- Google recaptcha remoteip explanation
- Formula to find matching row value based on cells
相关文章
- PostgreSQL field data type for IPv4 addresses
- How to check if an element exists in a Python arra
- Pandas lookup, mapping one column in a dataframe t
- Why is Lookup immutable in C#?
- iOS iTunes store country
- How to find that an IP address is a LAN IP or WAN
- Direct IP call android
- Automate ftp upload to ip
The most accurate is Digital Elements NetAcuity...not free but you get what you pay for most of the time....Digital Element
A lot of people (including my company) seem to use MaxMind GeoIP.
They have a free version GeoLite which is not as accurate as the paid version, but if you're just after something simple, it may be good enough.
You can use my service, http://ipinfo.io, for this. The API returns a whole bunch of different details about an IP address:
If you're only after the country code you just need to add /country to the URL:
Here's a generic PHP function you could use:
I've used the IP 8.8.8.8 in these examples, but if you want details for the user's IP just pass in
$_SERVER['REMOTE_ADDR']
instead. More details are available at http://ipinfo.io/developersThere are two approaches: using an Internet service and using some kind of local list (perhaps wrapped in a library). What you want will depend on what you are building.
For services:
For lists:
You could roll your own by downloading the lists from the RIRs:
ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest
The format is documented in this README
See ipdata.co which gives you several data points from an ip address.
The API is pretty fast, with 10 global endpoints each able to handle >800M calls daily.
Here's a curl example;
ipinfodb provides a free database and API for IP to country and vice versa. They use free data from MaxMind. The data gets updated every month, and it's a great free alternative with decent accuracy.