Skip to content

Instantly share code, notes, and snippets.

Created February 8, 2019 23:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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 = ''
# 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': '',
'hostname': '',
'city': 'Mountain View',
'region': 'California',
'country': 'US',
'loc': '37.3861,-122.0840',
'postal': '94035',
'asn': {
'asn': 'AS15169',
'name': 'Google LLC',
'domain': '',
'route': '',
'type': 'hosting'
'company': {
'name': 'Google LLC',
'domain': '',
'type': 'hosting'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment