This document describes the REST API and resources provided by the Aggregator Suite. The REST APIs are for developers who want to integrate the Aggregator Suite into other applications.
Aggregator Suiteās REST API provides access to all suite resources via URI paths. To use a REST API, your application will make an HTTP request and parse the response. The response format is JSON. Your methods will be the standard HTTP methods like GET, PUT, POST and DELETE.
Because the REST API is based on open standards, you can use any web development language to access the API.
The Aggregator Suite API uses a JSON Web Token to secure all data requests. Each one of the requests needs to contain the JWT which has an expiration of 30 minutes and needs to be refreshed after that period of time.
To request a JWT it is necessary to make a GET request to api.zenledger.io/oauth/token with the credentials previously facilitated by ZenLedger.
This same resource will be used to refresh the token after expiration.
Here is an example in javascript of how to request a JWT:
const clientId = 'provided_client_id';
const clientSecret = 'provided_secret';
const tokenEndpoint = 'https://api.zenledger.io/oauth/token';
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
client_id: clientId,
client_secret: clientSecret,
grant_type: 'client_credentials',
}),
};
fetch(tokenEndpoint, requestOptions)
.then((response) => {
if (!response.ok) {
throw new Error('Failed to obtain JWT token');
}
return response.json();
})
.then((data) => {
const token = data.access_token;
console.log('JWT Token:', token);
// You can now use the token for further requests.
})
.catch((error) => {
console.error('Error:', error);
});
Once the JWT is created you can use it for every other request to the API:
const jwtToken = 'your-jwt-token';
const apiUrl = 'https://api.zenledger.io/aggregators/api/v1/sources';
fetch(apiUrl, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
'Authorization': 'Bearer ${jwtToken}''
}
})
.then(response => response.json())
.then(response_data => {
// Handle the response data (list of sources)
console.log('source list:', response_data.data);
})
.catch(error => {
// Handle any errors
console.error('Error:', error);
});
The server response can vary based on the validity of the provided POST body:
Content-Type, Cache-Control, Expires, and more.access_token, token_type, expires_in, and scope fields. The access_token is the JWT that should be included in the Authorization header for subsequent API requests.Content-Type, Cache-Control, Expires, and more.error and error_description fields, indicating an invalid client or failed authentication.Content-Type, Cache-Control, Expires, and more.error and error_description fields, indicating an invalid request.| Key | Value | Description |
|---|---|---|
| Content-Type | application/json |
The Portfolios API resource allows to create wallet portfolios.
These endpoints form the basis of portfolio data management in the application, adhering to standard HTTP protocols and returning appropriate status codes based on the request’s success or failure.
Creates a new portfolio to be later linked to a new user.
This endpoint requires authentication via a bearer token, provided in the Authorisation header of the request.
NONE
*In JSON format
portfolio
objectObject containing a list of wallets with the following properties.blockchain (optional)
stringBlockchain of the walletcoin
stringCryptocurrency symboladdress
stringWallet address.display_name (optional)
stringif set, Name used for identifying the source in UI.
200api_version
stringVersion of the targeted APIdata
stringWrapper for response data (See response example)
| Key | Value | Description |
|---|---|---|
| Authorization | Bearer {{jwt_token}} | |
| Content-Type | application/json |
The Taxes API resource allows to retrieve tax summary.
These endpoints form the basis of tax summary reports, adhering to standard HTTP protocols and returning appropriate status codes based on the request’s success or failure.
| Key | Value | Description |
|---|---|---|
| Authorization | Bearer {{jwt_token}} | |
| Content-Type | application/json |
| Key | Value | Description |
|---|---|---|
| aggcode | heybelugaca48dacb783c |
The sources resource in the Aggregators API provides information about retrieving the list of supported wallet providers. By making a GET request to the /aggregators/api/v1/sources endpoint, you can retrieve the details of available sources. The request requires authentication using a bearer token.
Please note that the response example for this endpoint will contain the API version and a data object containing an array of sources. Each currency object includes a reference, name, type and other useful attributes.
Use this information to integrate and work with the supported sources of the Aggregators API.
Returns a paginated list of supported wallets by making a GET request to the path /aggregators/api/v1/sources on the base URL.
This endpoint requires authentication via a bearer token, provided in the Authorisation header of the request.
*Results paginated with 100 elements per page
page
numberSpecific page requested for the paginated results
200api_version
stringVersion of the targeted APIdata
stringWrapper for response data (See response example)
| Key | Value | Description |
|---|---|---|
| Authorization | Bearer {{jwt_token}} | |
| Content-Type | application/json |
| Key | Value | Description |
|---|---|---|
| page | 1 |
The currencies resource in the Aggregators API provides information about retrieving the list of supported currencies. By making a GET request to the /aggregators/api/v1/currencies endpoint, you can retrieve the details of available currencies. The request requires authentication using a bearer token.
Please note that the response example for this endpoint will contain the API version and a data object containing an array of currencies. Each currency object includes a reference, code, and name.
Use this information to integrate and work with the supported currencies of the Aggregators Suite API.
Returns a paginated list of supported cryptocurrencies by making a GET request to the path /aggregators/api/v1/currencies on the base URL.
This endpoint requires authentication via a bearer token, provided in the Authorisation header of the request.
*Results paginated with 100 elements per page
page
numberSpecific page requested for the paginated results
200api_version
stringVersion of the targeted APIdata
stringWrapper for response data (See response example)
| Key | Value | Description |
|---|---|---|
| Authorization | Bearer {{jwt_token}} | |
| Content-Type | application/json |
| Key | Value | Description |
|---|---|---|
| page | 1 |
The Aggregators API includes specific error codes to indicate and describe various issues and errors that may occur during API interactions. To help you quickly identify and understand these error codes, we have provided a glossary below. This table contains commonly encountered error codes along with their corresponding meanings. Refer to this table for efficient troubleshooting when working with our Aggregators API.
| Key | Value | Description |
|---|---|---|
| ZENAGG-AUTHGET-AA1 | Forbidden | |
| ZENAGG-AUTHGET-AA2 | Unauthorised | |
| ZENAGG-AUTHGET-AA3 | Invalid Api key | |
| ZENAGG-AUTHGET-AA4 | Invalid OAuth token | |
| ZENAGG-RSRCGET-AA1 | Resource not found | |
| ZENAGG-PFLPST-AA1 | Could not create portfolio |
| Key | Value | Type |
|---|---|---|
| base_url | string | |
| oauth_client_id | string | |
| oauth_client_secret | string | |
| jwt_token | string | |
| string |