Simple IPInfo demo program written in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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