First install our library with npm:
$ npm i gender-api.com-client --save
import {Client as GenderApiClient, ResultSingleName} from "gender-api.com-client";
const genderApiClient = new GenderApiClient("your API key");
try {
genderApiClient.getByFirstName('theresa', (response: ResultSingleName) => {
console.log(response.gender);
console.log(response.accuracy);
});
genderApiClient.getByFirstNameAndCountry('john', 'US', (response: ResultSingleName) => {
console.log(response.gender);
console.log(response.accuracy);
});
}
catch(e) {
console.log('Error:', e);
}
See full client documentation here:
https://github.com/markus-perl/gender-api-client-npm