Parse & Validate a Full Name in Python

Cloudmersive
2 min readJan 31, 2022

Names can be tricky to deal with because the information they’re composed of doesn’t always follow a standard structure. For example, the information stored for “Jon Jacob Smith” is a bit simpler than “Mr. Jon Jacob Smith Jr,” given the titles added at the beginning and end of the name. The Cloudmersive /validate/name/full-name iteration of the Validate API helps this problem by parsing a name and returning its component parts before confirming if the name string is valid or not. Below we’ll walk through how you can use this API in Python.

Your first step to use the API is to run the below Python SDK installation command & begin the API 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

After that, make sure you have your Cloudmersive API key in hand — you’ll need to authenticate that in the code below:

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

Finally, you just need to copy & paste the below code to complete the callback function:

# create an instance of the API class
api_instance = cloudmersive_validate_api_client.NameApi(cloudmersive_validate_api_client.ApiClient(configuration))
input = cloudmersive_validate_api_client.FullNameValidationRequest() # FullNameValidationRequest | Validation request information
try:
# Parse and validate a full name
api_response = api_instance.name_validate_full_name(input)
pprint(api_response)
except ApiException as e:
print("Exception when calling NameApi->name_validate_full_name: %s\n" % e)

For reference on how your information will be returned, check out the below response:

Figure 1 — Example Value Response Model

--

--

Cloudmersive

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