Get gender and ages

Description

Returns the list of available "genders and ages".

Arguments

= required
= only one of these is required
NameTypeDescriptionDefault value
localestringThe "locale" argument is used by some methods to return the name of the items in a list in a given language.eng

Response example

{
  "genderAndAges":[
    {
      "code":"childBoy",
      "name":"Male | Child"
    },
    {
      "code":"teenageBoy",
      "name":"Male | Teenage"
    },
    {
      "code":"youngAdultMale",
      "name":"Male | Young adult"
    },
    {
      "code":"middleAgeMale",
      "name":"Male | Middle age"
    },
    {
      "code":"seniorMale",
      "name":"Male | Senior"
    },
    {
      "code":"childGirl",
      "name":"Female | Child"
    },
    {
      "code":"teenageGirl",
      "name":"Female | Teenage"
    },
    {
      "code":"youngAdultFemale",
      "name":"Female | Young adult"
    },
    {
      "code":"middleAgeFemale",
      "name":"Female | Middle age"
    },
    {
      "code":"seniorFemale",
      "name":"Female | Senior"
    }
  ],
  "timestamp":1571317922
}
<?xml version="1.0" encoding="UTF-8"?>
<genderAndAges>
  <genderandage>
    <code>childBoy</code>
    <name>Male | Child</name>
  </genderandage>
  <genderandage>
    <code>teenageBoy</code>
    <name>Male | Teenage</name>
  </genderandage>
  <genderandage>
    <code>youngAdultMale</code>
    <name>Male | Young adult</name>
  </genderandage>
  <genderandage>
    <code>middleAgeMale</code>
    <name>Male | Middle age</name>
  </genderandage>
  <genderandage>
    <code>seniorMale</code>
    <name>Male | Senior</name>
  </genderandage>
  <genderandage>
    <code>childGirl</code>
    <name>Female | Child</name>
  </genderandage>
  <genderandage>
    <code>teenageGirl</code>
    <name>Female | Teenage</name>
  </genderandage>
  <genderandage>
    <code>youngAdultFemale</code>
    <name>Female | Young adult</name>
  </genderandage>
  <genderandage>
    <code>middleAgeFemale</code>
    <name>Female | Middle age</name>
  </genderandage>
  <genderandage>
    <code>seniorFemale</code>
    <name>Female | Senior</name>
  </genderandage>
  <timestamp>1571317923</timestamp>
</genderAndAges>

Code example

@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.2' )

import groovyx.net.http.*
import groovy.json.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*

http = new HTTPBuilder('https://api.voicebunny.com')
http.handler.success = {response, json -> return json}
http.handler.failure = {response, json -> throw new RuntimeException(json.error.code + ' ' + json.error.message)}
def voicebunnyUser = 'xxXXxx'
def voicebunnyToken = 'xxxxXXXXxxxxXXXX'
http.auth.basic voicebunnyUser, voicebunnyToken
def genderAndAges = http.get(path: 'genderAndAges/', requestContentType: URLENC)
import java.io.*;
import java.net.*;
import org.apache.commons.codec.binary.Base64;

public class Voicebunny {

    private String user = "xxXXxx";

    private String token = "xxxxXXXXxxxxXXXX";

    private String encodedAuthorization = "";

    private String host = "https://api.voicebunny.com";

    public Voicebunny() {
        String userpassword = user + ":" + token;
        encodedAuthorization = Base64.encodeBase64String(userpassword.getBytes());
    }

    public static void main(String[] args) throws IOException {
        Voicebunny vb = new Voicebunny();
        System.out.println(vb.getGenderAndAges());
    }

    private String getGenderAndAges() throws MalformedURLException, IOException, ProtocolException {
        return get("genderAndAges");
    }

    private String get(String resource) throws IOException, ProtocolException {
        URL url = new URL(host + "/" + resource);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Authorization", "Basic " + encodedAuthorization);
        connection.connect();
        InputStream in = connection.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        StringBuffer sb = new StringBuffer();
        String line = "";
        while ((line = reader.readLine()) != null) {
            sb.append(line);
        }
        reader.close();

        return sb.toString();
    }

}
<?php
$url_api = 'https://api.voicebunny.com/genderAndAges';
$opts = array(
	CURLOPT_URL => $url_api,
	CURLOPT_RETURNTRANSFER => TRUE,
	CURLOPT_INFILESIZE => -1,
	CURLOPT_TIMEOUT => 60,
	CURLOPT_SSL_VERIFYPEER => false,
	CURLOPT_HTTPGET => TRUE,
);
$curl = curl_init();
curl_setopt_array($curl, $opts);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
print_r($response);
?>
import requests
import simplejson
from requests.auth import HTTPBasicAuth

url = 'https://api.voicebunny.com'
req = requests.get(url+'/genderAndAges',
    verify=False)
data = simplejson.loads(req.text)
response = data['genderandages']
require 'faraday'
require 'faraday_middleware'

@conn = nil
resp = nil

@conn = Faraday.new(:url =>("https://api.voicebunny.com"),:ssl => {:verify => false}) do |builder|
	builder.use Faraday::Request::Multipart
	builder.use Faraday::Request::UrlEncoded
	builder.use Faraday::Response::ParseJson
	builder.use Faraday::Adapter::NetHttp		  
end

resp = @conn.get '/genderAndAges.json'
resp.body