Skip to main content

Python Client for the NameAPI Web Services

Project description

nameapi-client-python

Python Client for the NameAPI Web Services at https://www.nameapi.org.

There are functional tests that demonstrate how to use this library.

All you need to send requests is your own api key which you can get from nameapi.org.

This library requires at least Python 3.8.

Library setup

Create virtual environment and activate it:

python -m venv myenv
myenv\Scripts\activate

Install the required libraries:

pip install -r requirements.txt

Send a ping

This code sends a simple ping to nameapi to test the connection:

client = NameApiClient(None)
response = client.ping() # return the string 'pong'

Input / Output

Person input object

Most services accept a 'Person' as input. This person contains a name, and optionally more data such as gender, birth date etc. The name can be just a single "full name" string, or it can be composed of multiple fields like given name, middle name, surname. This standardized api makes it simple to use different services in a consistent way, and is very convenient in accepting the data however you have it at hands.

Creating a simple person looks something like this:

name_object = WesternInputPersonNameBuilder().fullname("John F. Kennedy").build()
input_person = NaturalInputPersonBuilder().name(name_object).build()

Creating name objects:

name_object_1 = WesternInputPersonNameBuilder() \
    .fullname("Petra Müller") \
    .build()

name_object_2 = WesternInputPersonNameBuilder() \
    .given_name("Petra") \
    .surname("Müller") \
    .build()

name_object_3 = WesternInputPersonNameBuilder() \
    .name_field(NameField("Petra", CommonNameFieldType.GIVENNAME)) \
    .name_field(NameField("Müller", CommonNameFieldType.SURNAME)) \
    .build()

name_object_4 = InputPersonName([NameField("petra müller", CommonNameFieldType.FULLNAME)])

Creating complex input person objects:

input_person = NaturalInputPersonBuilder() \
            .name(name_object_1) \
            .gender(StoragePersonGender.MALE) \
            .add_email("email@example.com") \
            .add_tel_number("+5555555") \
            .age(BirthDate(year=1999, month=2, day=1))\
            .build()

Result objects

Response from the requests, displayed as json: https://api.nameapi.org/rest/swagger-ui/

Access the link above to see all the return types and their json format.

Commands

The web service methods are implemented as commands. This brings the advantage that the command can be passed around and wrapped with other useful goodies such as logging in a unified way, without the need to put a wrapper around every service. For more specialized concerns such as auto-retry on failure this concept becomes a real advantage.

Name Parser

Name parsing is the process of splitting a full name into its components.

api_key = None  # Set your api_key here
client = NameApiClient(api_key)
response = client.person_name_parser(input_person)

Name Genderizer

Name genderizing is the process of identifying the gender based on a person's name.

api_key = None  # Set your api_key here
client = NameApiClient(api_key)
response = client.person_genderizer(input_person)

Name Matcher

The Name Matcher compares names and name pairs to discover whether the people could possibly be one and the same person.

This service takes 2 people as input:

api_key = None  # Set your api_key here
client = NameApiClient(api_key)

name_object_1 = WesternInputPersonNameBuilder().fullname("John F. Kennedy").build()
input_person_1 = NaturalInputPersonBuilder().name(name_object).build()
name_object_2 = WesternInputPersonNameBuilder().fullname("Jack Kennedy").build()
input_person_2 = NaturalInputPersonBuilder().name(name_object).build()

response = client.person_matcher(input_person_1, input_person_2)

Name Formatter

The Name Formatter displays personal names in the desired form. This includes the order as well as upper and lower case writing.

api_key = None  # Set your api_key here
client = NameApiClient(api_key)
response = client.person_name_formatter(input_person)

Risk Detector

Detects various types of possibly fake data in person records.

api_key = None  # Set your api_key here
client = NameApiClient(api_key)
response = client.risk_detector(input_person)

Email Name Parser

The Email Name Parser extracts names out of email addresses.

api_key = None  # Set your api_key here
client = NameApiClient(api_key)
email_address="daniela.meyer@example.de"
response = client.email_name_parser(email_address)

Disposable Email Address Detector

The DEA-Detector checks email addresses against a list of known "trash domains" such as mailinator.com.

api_key = None  # Set your api_key here
client = NameApiClient(api_key)
email_address="someone@10minutemail.com"
response = client.disposable_email_detector(email_address)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nameapi-client-python-1.0.1.tar.gz (36.3 kB view details)

Uploaded Source

File details

Details for the file nameapi-client-python-1.0.1.tar.gz.

File metadata

  • Download URL: nameapi-client-python-1.0.1.tar.gz
  • Upload date:
  • Size: 36.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for nameapi-client-python-1.0.1.tar.gz
Algorithm Hash digest
SHA256 eccb3bdb8151aaeae815b5662d497230a9ea9c58eca8352de24481418c1ef065
MD5 c54464df823c8dc4fe1b0ce5bd2a0790
BLAKE2b-256 d4c1d989362c77a35a62d9b5bb08e80ed3d971057a8afeff59bff3392bdbe9ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page