Acronis REST API client for Node.js
How to Install
$ npm i @apihawk-private/acronis-sdk
Prerequisites
In order to use this library (and the REST API on its own), you must have a registered client application in Acronis Cloud. You need to obtain the API client ID and API client secret key for that application and provide them in the constructor.
How to register a client application
You must have an administrator account in Acronis Cloud. You will need its username and password in order to authenticate for this endpoint.
Headers:
> POST /api/2/clients HTTP/1.1
> Host: eu2-cloud.acronis.com
> Content-Type: application/json
> Authorization: Basic base64(admin_username:admin_password)
> Accept: application/json
Body:
{
"type": "agent",
"tenant_id": "<YOUR_TENANT_ID>",
"token_endpoint_auth_method": "client_secret_basic",
"data": {
"name": "Billia",
"company": "Apihawk"
}
}
Response:
{
"tenant_id": "<TENANT_ID>",
"client_id": "<CLIENT_ID>",
"client_secret": "<CLIENT_SECRET>",
"data": {
"name": "Billia",
"company": "Apihawk"
},
"token_endpoint_auth_method": "client_secret_basic",
"type": "agent",
"client_secret_expires_at": 0,
"registration_access_token": "<SECRET>"
}
Example
Basic example:
import { AcronisClient } from '@apihawk-private/acronis-sdk';
const acronis = new AcronisClient({
api: 'https://eu2-cloud.acronis.com/api/2'
clientId: '<your_client_id>',
clientSecret: '<your_client_secret>'
});
await acronis.authorize();
const users = await acronis.User.getUsers();
const tenant = await acronis.Tenant.getTenantById('<tenant ID>');
You can run the example scripts which are located in the /examples
folder in the following way:
$ npx ts-node examples/provision.ts
You need to provide the following environmental variables:
export ACRONIS_API=https://eu2-cloud.acronis.com/api/2
export ACRONIS_CLIENT_ID=<YOUR_CLIENT_ID>
export ACRONIS_CLIENT_SECRET=<YOUR_CLIENT_SECRET>
Please use a test/demo account!
Test
You can run the integration tests:
$ npm test
Logging
You can turn on HTTP requests logging by setting the DEBUG
environmental variable:
export DEBUG=acronis-sdk*
Resources
It's strongly advised to get familiar with the Acronis REST API before using this library.