Geolocate an IP Address to a Street Address in Python

Cloudmersive
Nov 12, 2020

--

To better understand your client base and track any incoming threats to your sites, it is imperative to know where your users are located. Furthermore, if you are designing a program or application that is dependent on location information, this can help hone your system to provide an accurate result. The following function will let you to geolocate an IP Address to its street address and return the country and country code, street address, city name, region name, and Zip code.

To use this API, you can run this command to install the SDK:

pip install cloudmersive-validate-api-client

Then, you can call the function:

from __future__ import print_function
import time
import cloudmersive_validate_api_client
from cloudmersive_validate_api_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: Apikey
configuration = cloudmersive_validate_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# create an instance of the API class
api_instance = cloudmersive_validate_api_client.IPAddressApi(cloudmersive_validate_api_client.ApiClient(configuration))
value = 'value_example' # str | IP address to geolocate, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes.
try:
# Geolocate an IP address to a street address
api_response = api_instance.i_p_address_geolocate_street_address(value)
pprint(api_response)
except ApiException as e:
print("Exception when calling IPAddressApi->i_p_address_geolocate_street_address: %s\n" % e)

You can get your free API Key from Cloudmersive. This will give you access to 800 monthly calls across our entire API Library.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet