Using the BigAnimal API
Deprecation notice
EDB released v3 of BigAnimal API in January 2023. v2 of BigAnimal API goes out of support on June 30, 2023. To see the changes in v3, see the Change log. Update your applications accordingly.
Use the BigAnimal API to integrate directly with BigAnimal for management activities such as cluster provisioning, deprovisioning, and scaling.
The API reference documentation is available from the BigAnimal portal. The direct documentation link is https://portal.biganimal.com/api/docs/.
To access the API, you need a token. The high-level steps to obtain a token are:
- Query the authentication endpoint.
- Request the device code.
- Authorize as a user.
- Request the raw token.
- Exchange the raw token for the BigAnimal token.
EDB provides an optional script to simplify getting your device code and getting and refreshing your tokens. See Using the get-token
script for details.
Query the authentication endpoint
This call returns the information that either:
- You need later if you're using
curl
to request the device code and tokens. - The
get-token
script uses to generate the tokens for you.
The response returns the clientId
, freetrialClientId
, issuerUri
, scope
, and audience
. For example:
We recommend that you store the output in environment variables so that it's easier to include them in the following calls. For example:
Note
If you're using BigAnimal with your free trial account, assign the output of freetrialClientId
to CLIENT_ID
(CLIENT_ID=m71bEVZrGsWiKtPqMI3hYCHCG3EYLPDk
in this example).
The following example calls use these environment variables.
Request the device code using curl
Note
The get-token
script executes this step. You don't need to make this call if you're using the script.
This call gets a device code:
The response returns:
device_code
— The unique code for the device. When you go to theverification_uri
in your browser-based device, this code is bound to your session. You use this code in your request for a token.user_code
— The code you input at theverification_uri
to authorize the device. You use this code when you authorize yourself as a user.verification_uri
— The URL you use to authorize your device.verification_uri_complete
— The complete URL you use to authorize the device. You can use this URL to embed the user code in your app's URL.expires_in
— The lifetime (in seconds) of thedevice_code
anduser_code
.interval
— The interval (in seconds) at which the app polls the token URL to request a token.
For example:
Store the device code in an environment variable for future use. For example:
Authorize as a user
Go to the
verification_uri
in your web browser, enter youruser_code
, and select Continue.On the Device Confirmation dialog box, select Confirm.
On the BigAnimal Welcome screen, select Confirm.
Request the raw token using curl
Note
The get-token
script executes this step. You don't need to make this call if you're using the script. See Request your token using get-token
.
The curl --request POST
call requests a token. For example:
If successful, the call returns:
access_token
— Use to exchange for the token to access BigAnimal API.refresh_token
— Use to obtain a new access token or ID token after the previous one expires. See Refresh tokens for more information. Refresh tokens expire after 30 days.expires_in
— The token expires after 24 hours from its creation.
For example:
Store the access token and refresh token in environment variables for future use. For example:
Note
The access token obtained at this step is used only in the next step to exchange the BigAnimal token.
If not successful, you receive one of the following errors:
authorization_pending
— Continue polling using the suggested interval retrieved when you requested the device code.slow_down
— Slow down and use the suggested interval retrieved when you requested the device code. To avoid receiving this error due to network latency, start counting each interval after receipt of the last polling request's response.expired_token
— You didn't authorize the device quickly enough, so thedevice_code
expired. Your application notifies you that it expired and to restore it.access_denied
Exchange the BigAnimal token using curl
Note
The get-token
script executes this step. You don't need to make this call if you're using the script.
Use the raw token you obtained in the previous step Request the raw token using curl
to get the BigAnimal token:
If successful, the call returns:
token
— The bearer token used to access the BigAnimal API.
For example:
As opposed to the raw-access token, this token is recognized by the BigAnimal API. Store this token in environment variables for future use. For example:
Tip
Contact Customer Support if you have trouble obtaining a valid access token to access the BigAnimal API.
Call the API
To call the BigAnimal API, your application must pass the retrieved access token as a bearer token in the Authorization header of your HTTP request. For example:
Example response:
Refresh your token
You use the refresh token to get a new raw-access token. Usually you need a new access token only after the previous one expires or when gaining access to a new resource for the first time. Don't call the endpoint to get a new access token every time you call an API. Rate limits can throttle the amount of requests to the endpoint that can be executed using the same token from the same IP.
Refresh your token using curl
Note
The get-token
script has an option to execute this step. See Refresh the token using get-token
.
If you aren't using the get-token
script to refresh your token, make a POST
request to the /oauth/token
endpoint in the authentication API, using grant_type=refresh_token
. For example:
The refresh_token
is in the response when you requested the token.
The client_id
is always the same one in the response when you queried the authentication endpoint.
The response of this API call includes the access_token
. For example:
Store the access token and refresh token in environment variables for future use. For example:
The token you obtain from this step is the raw-access token. You need to exchange this token for a BigAnimal token. See Exchange for BigAnimal token for more information.
Note
You need to save the refresh token retrieved from this response for the next refresh call. The refresh token in the response when you originally requested the token becomes obsolete once you use it.
Using the get-token
script
To simplify the process of getting tokens, EDB provides the get-token
script. You can download it here.
To use the script, install the jq command-line JSON processor specific to your OS.
Before running the script, query the authentication endpoint.
get-token usage
Request your token using get-token
To use the get-token
script to get your tokens, use the script without the --refresh
option. For example:
Refresh the token using get-token
To use the get-token
script to refresh your token, use the script with the --refresh <refresh_token>
option. For example: