Normalize a Street Address in Python

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)

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

KEYFI is going bananas!

How I passed my C|EH Practical and how you can too ?

How to customize dark mode in iOS app with iOS 13 [iOS Tutorial]

The steps of compilation

Adding Route Table Rules Using terraform.tfvars File

Design Thoughts: Retail Engagement Platform — Intro & Mobile

Introducing the official GoLinks Slack App

The Magical Mystery of Molotov

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

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

More from Medium

Validate a Postal Code, Get Location Information About It in Python

How to Create a Documentation Website for Your Python Package

Oracle Linux 7 Installation on Virtualbox or VMware and Oracle 19c Installation on Oracle Linux 7

Python GUI frameworks