Normalize a Street Address in Python

Cloudmersive
2 min readJan 27, 2022

If you’re managing street-address data in your application, it’s essential to structure the components of that data with relevant, specific formatting, or each individual piece of information will lose its context. The Cloudmersive Validate API is capable of doing that for you — it’ll normalize an input street address, let you know if it’s valid or not, and even return the latitude & longitude of the address (if valid originally). In this article we’ll walk through how you can use this API in Python.

To connect with this API, the first step is to install the Python SDK using the below snippet:

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

Following that, you can authorize your API key within the following code:

# 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 get one by heading to Cloudmersive.com and creating a free account (which includes 800 monthly API calls).

For the final step in the process, you can now copy in the rest of the code for the Python function:

# 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 request
try:
# Normalize a street address
api_response = api_instance.address_normalize_address(input)
pprint(api_response)
except ApiException as e:
print("Exception when calling AddressApi->address_normalize_address: %s\n" % e)

--

--

Cloudmersive

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