Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple IPInfo demo program written in python
# Import the package.
import ipinfo
# Set the access token.
accessToken = 'abc12345678'
# Authenticate and get API handler object.
handler = ipinfo.getHandler(accessToken)
# IP Adress to look for.
ipAddress = '216.239.36.21'
# Grab the data from API.
result = handler.getDetails(ipAddress)
# Dump the result to the console.
print(result.all) # result.all gives response As a python dictionary.
# Response
{
'ip': '216.239.36.21',
'hostname': 'any-in-2415.1e100.net',
'city': 'Mountain View',
'region': 'California',
'country': 'US',
'loc': '37.3861,-122.0840',
'postal': '94035',
'asn': {
'asn': 'AS15169',
'name': 'Google LLC',
'domain': 'google.com',
'route': '216.239.36.0/24',
'type': 'hosting'
},
'company': {
'name': 'Google LLC',
'domain': 'google.com',
'type': 'hosting'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.