Names
This API tries to determine what words in a given input correspond to a first-name and/or last-name.
Although this task may seem simple, in many cultures some first names can also be last names, which can cause some confusion. For example, the name Franco
can be both a
first name as a family name, making it hard to label.
We recommend using this API in combination with the Gender API.
Prediction labels
Limits
The maximum length accepted is 512 characters.
Label | Example |
---|---|
first_name | Carlota, Peter, Richard |
last_name | reynosa, Ericson, Aguirre |
unknown | tripod, careless |
Invokation
- cURL
- Python
- PHP
curl -L -G 'http://api.textkit.ai/detect/names' \
--data-urlencode 'text=Carlota Reynosa wasnt careless' \
--header 'X-API-Key: your_api_key_here'
import requests
url = "https://api.textkit.ai/detect/names?text=Carlota Reynosa wasn't careless"
payload={}
headers = {
'X-API-Key': 'your_api_key_here'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
<?php
$curl = curl_init();
$url = "https://api.textkit.ai/detect/names?text=" . urlencode("Carlota Reynosa wasn't careless");
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-API-Key: your_api_key_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
{
"prediction": {
"first_name": [
"carlota"
],
"last_name": [
"reynosa"
],
"unknown": [
"wasn't",
"careless"
]
},
"confidence": "1",
"time_ms": 37
}
Field | Meaning |
---|---|
prediction | The predicted label. See above for reference |
confidence | Value between 0 and 1 that indicates how confident the model is |
time_ms | Time in milliseconds the model took to predict the label. It does not account for the network round trip time between request and response |