Skip to content


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation


Java Client for the NameAPI Web Services at

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

This library requires at least Java 17 starting from version 6.0.0 (use a previous version for Java 8).

Library setup

Using Maven:


Or Gradle:

implementation 'org.nameapi.client:nameapi-client:6.0.0'

Also you could download the jar, or check out the source code from this GitHub project.

Setup code

At first, you need some includes, to the context information:

import org.nameapi.ontology5.input.context.Context;
import org.nameapi.ontology5.input.context.ContextBuilder;
import org.nameapi.ontology5.input.context.Priority;

You need a Context that explains a bit your working environment, something like:

Context context = new ContextBuilder()

Then you need an executor and a mode:

import com.optimaize.command4j.CommandExecutor;
import com.optimaize.command4j.Mode;
import org.nameapi.client.lib.NameApiModeFactory;
import org.nameapi.client.lib.NameApiPortUrlFactory;
import org.nameapi.client.lib.NameApiRemoteExecutors;

CommandExecutor executor = NameApiRemoteExecutors.get();
Mode mode = NameApiModeFactory.withContext(
        //the default and live server is ""
        new Host("", Protocol.HTTPS), NameApiPortUrlFactory.version5_3()

Now you're ready to execute commands.

Send a ping

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


PingCommand command = new PingCommand();
executor.execute(command, mode, null).get(); //returns "pong"

Input / Output

All input objects come with builders or nicely documented setters. The result objects returned by the services all have fully documented getters. Many input arguments are optional - that means you can start simple, and add more as you need. The vocabulary for the communication, with input/output classes, is in the separate "Ontology" software. It is included as a Maven dependency. For the project page see

Behind the scenes this service api uses REST (previous versions used SOAP). But luckily you don't need to worry about any of the interface detail, you can just use the provided classes.

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:

import org.nameapi.ontology5.input.entities.person.InputPerson;
import org.nameapi.ontology5.input.entities.person.NaturalInputPersonBuilder;

InputPersonName name = NameBuilders.western().fullname("John F. Kennedy").build();
InputPerson inputPerson = new NaturalInputPersonBuilder().name(name).build();


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.

Using the objects created earlier:


PersonNameParserCommand command = new PersonNameParserCommand();
PersonNameParserResult result = executor.execute(command, mode, inputPerson).get();

Name Genderizer

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

Using the objects created earlier:


PersonGenderizerCommand command = new PersonGenderizerCommand();
GenderizerResult result = executor.execute(command, mode, inputPerson).get();

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:

import org.nameapi.ontology5.input.entities.person.NaturalInputPerson;
import org.nameapi.ontology5.input.entities.person.NaturalInputPersonBuilder;

PersonMatcherCommand command = new PersonMatcherCommand();
NaturalInputPerson person1 = new NaturalInputPersonBuilder().name( NameBuilders.western().fullname("John F. Kennedy").build() ).build();
NaturalInputPerson person2 = new NaturalInputPersonBuilder().name( NameBuilders.western().fullname("Jack Kennedy").build() ).build();
PersonMatcherArgument argument = new PersonMatcherArgument(person1, person2);
PersonMatcherResult result = executor.execute(command, mode, argument).get();

Name Formatter

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

import org.nameapi.ontology5.input.entities.person.NaturalInputPerson;
import org.nameapi.ontology5.input.entities.person.NaturalInputPersonBuilder;

PersonNameFormatterCommand command = new PersonNameFormatterCommand();
NaturalInputPerson person = new NaturalInputPersonBuilder().name( NameBuilders.western().fullname("john f. kennedy").build() ).build();
FormatterProperties properties = new FormatterProperties(true);
PersonNameFormatterArgument argument = new PersonNameFormatterArgument(person, properties);
FormatterResult formatterResult = executor.execute(command, mode, argument).get();

Risk Detector

Detects various types of possibly fake data in person records.

import org.nameapi.ontology5.input.entities.address.StructuredAddressBuilder;
import org.nameapi.ontology5.input.entities.address.StructuredPlaceInfoBuilder;
import org.nameapi.ontology5.input.entities.address.StructuredStreetInfoBuilder;
import org.nameapi.ontology5.input.entities.person.InputPerson;
import org.nameapi.ontology5.input.entities.person.NaturalInputPersonBuilder;

PersonRiskDetectorCommand command = new PersonRiskDetectorCommand();
InputPerson person = new NaturalInputPersonBuilder()
        .name(new WesternInputPersonNameBuilder().givenName("John").surname("Doe").build())
        .addTelNumber(TelNumberFactory.forNumber("999 999 999"))
            new StructuredAddressBuilder()
                .placeInfo(new StructuredPlaceInfoBuilder().locality("Atlantis").postalCode("55555").build())
                .streetInfo(new StructuredStreetInfoBuilder().streetName("Hill road").houseNumber("72").build())
RiskDetectorResult result = executor.execute(command, mode, person).get();

Email Name Parser

The Email Name Parser extracts names out of email addresses.


EmailNameParserCommand command = new EmailNameParserCommand();
EmailNameParserResult result = executor.execute(command, mode, "").get();

Disposable Email Address Detector

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


DisposableEmailAddressDetectorCommand command = new DisposableEmailAddressDetectorCommand();
DisposableEmailAddressDetectorResult result = executor.execute(command, mode, "").get();