Parse an Unstructured Input Text String into an International, Formatted Address in Python

In this article, we’re going to walk through using a useful iteration of Cloudmersive’s Validate API in Python. The /validate/address/parse iteration uses Machine Learning (ML) & Natural Language Processing (NLP) to parse an unstructured input text string into an international, formatted address. This iteration can handle a wide variety of cases, which includes non-standard and unstructured address strings across a wide array of countries and address-formatting norms. Connecting is made easy with ready-to-run code and extensive documentation for your convenience.

To use this API, first install the Python SDK with the below command:

pip install cloudmersive-validate-api-clientfrom __future__ import print_function
import time
import cloudmersive_validate_api_client
from import ApiException
from pprint import pprint

After that, you’ll need to authorize your API key with the below snippet. If you don’t have a key already, you can get one by creating a free account on the Cloudmersive website.

# Configure API key authorization: Apikey
configuration = cloudmersive_validate_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'

You can then complete the function by copying & pasting the below code:

# 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.ParseAddressRequest() # ParseAddressRequest | Input parse request
# Parse an unstructured input text string into an international, formatted address
api_response = api_instance.address_parse_string(input)
except ApiException as e:
print("Exception when calling AddressApi->address_parse_string: %s\n" % e)



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


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