gender api free code example

Example: gender api

// FIRST INSTALL : npm i gender-api.com-client --save

try {
    var GenderApi = require('gender-api.com-client');

    var genderApiClient = new GenderApi.Client('your api key'); // https://gender-api.com/

    genderApiClient.getByFirstName('theresa', function (response) {
        console.log(response.gender); //female
        console.log(response.accuracy); //98
    });

    genderApiClient.getByFirstNameAndCountry('john', 'US', function (response) {
        console.log(response.gender); //male
        console.log(response.accuracy); //99
    });

}
catch(e) {
    console.log('Error:', e);
}

Tags:

Misc Example