أولاً قم بتثبيت مكتبتنا باستخدام npm:
npm install gender-api.com-client --save
import { Client } from 'gender-api.com-client';
const client = new Client('your-api-key');
const result = await client.getByFirstName('Theresa');
console.log(`${result.first_name} is ${result.gender} (Probability: ${result.probability}`);
const resultWithCountry = await client.getByFirstName('Andrea', { country: 'IT' });
console.log(`${resultWithCountry.first_name} in Italy is ${resultWithCountry.gender}`);
const fullResult = await client.getByFullName('John Smith');
console.log(`${fullResult.first_name} ${fullResult.last_name} is ${fullResult.gender}`);
const emailResult = await client.getByEmailAddress('marie.curie@example.com');
console.log(`Email gender: ${emailResult.gender}`);
const names = [
{ id: '1', first_name: 'Theresa', country: 'US' },
{ id: '2', first_name: 'John', country: 'US' }
];
const batchResults = await client.getByFirstNameMultiple(names);
batchResults.forEach(r => {
console.log(`ID: ${r.input.id}, Gender: ${r.gender}`);
});
const stats = await client.getStatistics();
console.log(`Credits Remaining: ${stats.remaining_credits}`);
شاهد وثائق العميل الكاملة هنا:
https://github.com/markus-perl/gender-api-client-npm