I'm trying to create a simple custom function using the Genderize API in Google Sheets using Google Apps Script, but I keep getting a request limit reached 429 error from the genderize API. I'm sure that I haven't exceeded the limit of 1000 calls.
I'm also a complete beginner, so perhaps there are a few mistakes in my code. Any help would be greatly appreciated!
function fetch_(query) {
var response = UrlFetchApp.fetch("https://api.genderize.io/?name=" + encodeURI(query.toLowerCase()));
Logger.log(response.getContentText());
Utilities.sleep(1000);
var out = JSON.parse(response.getContentText());
return out
}
/**
* Derive gender based on a first name using the Genderize API.
*
* This formula helps retrieve the gender of a given first name.
*
* For example:
*
* =GetGender("juan").
* Developped by somejuan.dk
*
* @param query The name of the contact.
*
* @return The gender of the name submitted.
* @customfunction
**/
function GetGender(query) {
var json_out = fetch_(query) ;
return json_out['gender'];
}
Error message is: Request failed for https://api.genderize.io/?name=juan returned code 429.
Truncated server response: {"error":"Request limit reached"} (use muteHttpExceptions option to examine full response). (line 6).