Understanding where your clients are based will help you improve not only their experience, but also assist in your planning and marketing goals. For example, if many users are based in one region you can focus specific effort on outreach to that area. The following API will allow you to geocode a street address in Python. The input for this function should include the street address, city, state or province, postal code, and the country name and code.
Run this command to install the SDK:
pip install cloudmersive-validate-api-client
Then, you can call the function:
from __future__ import print_function
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.AddressApi(cloudmersive_validate_api_client.ApiClient(configuration))
input = cloudmersive_validate_api_client.ValidateAddressRequest() # ValidateAddressRequest | Input parse requesttry:
# Geocode a street address into latitude and longitude
api_response = api_instance.address_geocode(input)
except ApiException as e:
print("Exception when calling AddressApi->address_geocode: %s\n" % e)
This will return whether the address was valid, as well as the latitude and longitude for its location. You can retrieve the API Key from the Cloudmersive website at no cost and with no commitment. This will provide you with 800 monthly calls across our library of APIs.