Skip to content

Instantly share code, notes, and snippets.

@saqibameen
Created February 8, 2019 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saqibameen/781bd0b4d3657abaabd82006501352c5 to your computer and use it in GitHub Desktop.
Save saqibameen/781bd0b4d3657abaabd82006501352c5 to your computer and use it in GitHub Desktop.
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