Get Intelligence on an IP Address in Python
There are many flavors of cyber security threats out there, so it’s important to boost your threat profile whenever possible. Using the /validate/IP/intelligence iteration of the Cloudmersive Validate API, you can find out key information about any given IP address you stumble upon, including if it’s a known threat IP, known bot, Tor Exit node & more, along with getting the location of the IP address. It’s easy to implement & use in 13+ programming languages — today, we’ll run through how you can take advantage of it in Python.
To get started, first use the below command to install the Python SDK & begin the callback function:
pip install cloudmersive-validate-api-clientfrom __future__ import print_function
import time
import cloudmersive_validate_api_client
from cloudmersive_validate_api_client.rest import ApiException
from pprint import pprint
Next, you’ll need to use the below code snippet to authenticate your Cloudmersive API key:
# Configure API key authorization: Apikey
configuration = cloudmersive_validate_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
If you don’t already have an API key, you can easily get one by creating a free account on the Cloudmersive website, which will allow you 800 API calls per month.
For the final step, use the below code to complete the function:
# 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 process, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes.try:
# Get intelligence on an IP address
api_response = api_instance.i_p_address_ip_intelligence(value)
pprint(api_response)
except ApiException as e:
print("Exception when calling IPAddressApi->i_p_address_ip_intelligence: %s\n" % e)