Aggregator Suite: REST API Reference

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.

Authentication 1

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);
  });

Description

The server response can vary based on the validity of the provided POST body:

  • Success (HTTP status 200):
    • Headers: The response includes various headers such as Content-Type, Cache-Control, Expires, and more.
    • Body: The response body is a JSON object containing the 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.
  • Unauthorized (HTTP status 401):
    • Headers: The response includes various headers such as Content-Type, Cache-Control, Expires, and more.
    • Body: The response body is a JSON object containing the error and error_description fields, indicating an invalid client or failed authentication.
  • Bad Request (HTTP status 400):
    • Headers: The response includes various headers such as Content-Type, Cache-Control, Expires, and more.
    • Body: The response body is a JSON object containing the error and error_description fields, indicating an invalid request.


Headers
KeyValueDescription
Content-Typeapplication/json
Body
{ "client_id": "{{oauth_client_id}}", "client_secret": "{{oauth_client_secret}}", "grant_type": "client_credentials" }

Portfolios 1

The Portfolios API resource allows to create wallet portfolios.

  1. Create Portfolio Endpoint: This POST endpoint allows for the creation of new portfolios, requiring authentication via a bearer token.

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.

Description

POST /portfolios

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.

Request

QUERY PARAMETERS

NONE

BODY

*In JSON format

portfolio object Object containing a list of wallets with the following properties.

blockchain (optional) string Blockchain of the wallet

coin string Cryptocurrency symbol

address string Wallet address.

display_name (optional) string if set, Name used for identifying the source in UI.

RESPONSE 200
RESPONSE DATA

api_version string Version of the targeted API

data string Wrapper for response data (See response example)



Headers
KeyValueDescription
AuthorizationBearer {{jwt_token}}
Content-Typeapplication/json
Body
{ "portfolio": [ { "blockchain": "ethereum", "coin": "eth", "address": "0xc5689793548164f7D6B5477EEE6697DF6F3C2843", "display_name": "Eth wallet" }, { "blockchain": "bitcoin", "coin": "btc", "address": "3Df7budise9ws3vzPADMbN5XA4JJZ8BuUR", "display_name": "BTC wallet" } ] }

Taxes 1

The Taxes API resource allows to retrieve tax summary.

  1. GET Taxes Endpoint: This GET endpoint allows for retrieval of tax summary, requiring authentication via a bearer token.

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.

Headers
KeyValueDescription
AuthorizationBearer {{jwt_token}}
Content-Typeapplication/json
Query
KeyValueDescription
aggcodeheybelugaca48dacb783c

Supported Exchanges and Wallets 1

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.

Description

GET /sources

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

Request

QUERY PARAMETERS

page number Specific page requested for the paginated results

RESPONSE 200
RESPONSE DATA

api_version string Version of the targeted API

data string Wrapper for response data (See response example)



Headers
KeyValueDescription
AuthorizationBearer {{jwt_token}}
Content-Typeapplication/json
Query
KeyValueDescription
page1

Supported Currencies 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.

Description

GET /currencies

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

Request

QUERY PARAMETERS

page number Specific page requested for the paginated results

RESPONSE 200
RESPONSE DATA

api_version string Version of the targeted API

data string Wrapper for response data (See response example)



Headers
KeyValueDescription
AuthorizationBearer {{jwt_token}}
Content-Typeapplication/json
Query
KeyValueDescription
page1

Error Codes 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.

Body
KeyValueDescription
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

Available Variables 5

KeyValueType
base_urlstring
oauth_client_idstring
oauth_client_secretstring
jwt_tokenstring
string