Continua → Panoramica

Librerie client

Wrapper sottili sull'API REST. Gestiscono i retry, il batching e l'encoding, così non devi farlo tu.

Non è necessaria. L'API è quattro endpoint e JSON semplice; una libreria ti fa risparmiare un pomeriggio, non un progetto. Se il tuo linguaggio non è elencato, il riferimento REST contiene esempi pronti da copiare.

Riferimento REST API →
JavaScript
Node.js · Deno · Bun · npm
Installa
npm install github:anpekesen/namegender-js#v0.2.0
Utilizzo
import { NameGender } from 'namegender';

const client = new NameGender('YOUR_API_KEY');

const result = await client.name('Ayşe', { country: 'TR' });
console.log(result.gender);      // "female"
console.log(result.confidence);  // "unverified" | "low" | "medium" | "high"

// Tek istekte çok isim
const many = await client.bulk(['Ayşe', 'Mehmet', 'Priya']);
PHP
PHP 8.1+
Installa
composer config repositories.namegender vcs https://github.com/anpekesen/namegender-php
composer require namegender/namegender:^0.2
Utilizzo
use NameGender\Client;

$client = new Client('YOUR_API_KEY');

$result = $client->name('Ayşe', country: 'TR');
echo $result['gender'];      // "female"
echo $result['confidence'];  // "unverified" | "low" | "medium" | "high"

// Tek istekte çok isim
$many = $client->bulk(['Ayşe', 'Mehmet', 'Priya']);
Python
Python 3.9+
Installa
pip install git+https://github.com/anpekesen/namegender-python.git@v0.2.0
Utilizzo
from namegender import NameGender

client = NameGender("YOUR_API_KEY")

result = client.name("Ayşe", country="TR")
print(result["gender"])      # "female"
print(result["confidence"])  # evidence level

# Tek istekte çok isim
many = client.bulk(["Ayşe", "Mehmet", "Priya"])
Ruby
Ruby 3.0+
Installa
git clone --branch v0.2.0 https://github.com/anpekesen/namegender-ruby.git
cd namegender-ruby && gem build namegender.gemspec && gem install namegender-0.2.0.gem
Utilizzo
require "namegender"

client = NameGender::Client.new("YOUR_API_KEY")

result = client.name("Ayşe", country: "TR")
puts result["gender"]      # "female"
puts result["confidence"]  # evidence level
Java
Java 17+ · JitPack
Installa
<repository>
  <id>jitpack.io</id>
  <url>https://jitpack.io</url>
</repository>

<dependency>
  <groupId>com.github.anpekesen</groupId>
  <artifactId>namegender-java</artifactId>
  <version>v0.2.0</version>
</dependency>
Utilizzo
var client = new NameGender("YOUR_API_KEY");

var result = client.name("Ayşe", "TR");
System.out.println(result.gender());       // "female"
System.out.println(result.confidence());
Go
Go 1.21+
Installa
go get github.com/anpekesen/namegender-go@v0.2.0
Utilizzo
client := namegender.New("YOUR_API_KEY")

result, err := client.Name(ctx, "Ayşe", namegender.Options{Country: "TR"})
fmt.Println(result.Gender)      // "female"
fmt.Println(result.Confidence)
R
R 4.1+ · GitHub
Installa
remotes::install_github('anpekesen/namegender-r', ref = 'v0.2.0')
Utilizzo
library(namegender)

client <- namegender("YOUR_API_KEY")

result <- ng_name(client, "Ayşe", country = "TR")
result$gender       # "female"
result$confidence

# Bir data frame'in tamamını tek çağrıda
df$gender <- ng_bulk(client, df$name)$gender

Hai bisogno di un altro linguaggio?

Faccelo sapere e lo valuteremo. La superficie dell'API è piccola abbastanza che un wrapper della comunità è lavoro di un weekend, e lo linkeremo qui.

Contatta il supporto