| genderapi_client | R Documentation |
A client holds the API key, base URL, timeout and user agent. Creating a
client never sends a request. Every request function takes a client
argument that defaults to genderapi_client(), so setting the
GENDERAPI_API_KEY environment variable is enough for most scripts.
genderapi_client(
api_key = Sys.getenv("GENDERAPI_API_KEY", ""),
base_url = default_base_url,
timeout = 10,
user_agent = NULL,
require_api_key_access = TRUE
)
api_key |
API key string. Defaults to the |
base_url |
API base URL. Keep the default in production. HTTPS is
required; |
timeout |
Total request timeout in seconds (default 10). A timed-out request is not retried and may still have been billed. |
user_agent |
Optional |
require_api_key_access |
|
Without a key (api_key is NULL or empty and GENDERAPI_API_KEY is
unset) requests are sent without an Authorization header and the server
applies its shared IP trial (10 credits per 24 hours per public IP).
The package has no client-side trial logic; meta$access$mode in each
response tells you which access mode the server used.
When a key is set, the package by default checks that each successful
authenticated response reports meta$access$mode == "api_key". If the
server answered through another mode (usually "ip_trial" because the key
was not recognized), a genderapi_access_mode_error is raised. The request
has already been processed and may have consumed IP-trial credits; the
full result is in the error's result field. It is never retried. Set
require_api_key_access = FALSE to return such responses normally.
Keep keys server-side. Never put a key in browser code, a URL, a log or a document shared with end users. Printing a client never shows the key.
An object of class genderapi_client.
# No request is sent here.
client <- genderapi_client(api_key = NULL, timeout = 5)
client
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.