How to get the gender of a first name in Salesforce Apex

Cloudmersive
1 min readFeb 18, 2020

--

An automated gender recognition system can open up some great possibilities for your app or website, not to mention user demographics. Rather than set this up from scratch, how about something a little easier? We’ve got an API with your name on it. Let’s take a look at how to get it running.

Installation of our API is a piece of cake: simply unzip the client into your project location.

Once that’s done with, proceed by calling nameGetGender and entering the desired name and two-letter country code of origin.

SwagNameApi api = new SwagNameApi();SwagClient client = api.getClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) client.getAuthentication('Apikey');Apikey.setApiKey('YOUR API KEY');Map<String, Object> params = new Map<String, Object>{'input' => SwagGetGenderRequest.getExample()};try {// cross your fingersSwagGetGenderResponse result = api.nameGetGender(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}

Done! Here is what an example response looks like for the German name Greta:

{
"Successful": true,
"Gender": "Male"
}

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Responses (1)