- Unsupervised Learning
- Posts
- Online GeoIP Lookups Using ipinfo.io
Online GeoIP Lookups Using ipinfo.io
![screen-shot-2016-10-30-at-1.00.39-pm-1-e1477858066473](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/4d0d86cb-d789-4ec1-8ebc-de1247bcc26d/Screen-Shot-2016-10-30-at-1.00.39-PM-1-e1477858066473.png)
There are lots of ways to resolve an IP to a country/location. The fastest way is to have the database local and do quick checks against the file/database as needed.
But for quick hits it’s always nice to have an online options as well!
curl ipinfo.io/23.66.166.151
This gets you a nice little JSON object with the full results, as seen above.
Here are a few other filtering options:
# Get the country code of the result
curl ipinfo.io/23.66.166.151 | grep country | awk -F'”‘ ‘{ print $4 }’
# Get the state of the result
curl ipinfo.io/23.66.166.151 | grep region | awk -F'”‘ ‘{ print $4 }’
# Get the city of the result
curl ipinfo.io/23.66.166.151 | grep city | awk -F'”‘ ‘{ print $4 }’
Enjoy!