The API is ideal for third-party applications that aim to record their clients' transactions in WhaleBooks while also retrieving their portfolio results.

Comprehensive API documentation can be found at: https://whalebooks.com/open-api .


Examples:

1. Create a User

Using: POST /api/v2/users

2. Create Organization

Under an existing or new user, you’ll need to create an organization for which you will have write access.

Use: POST /api/v2/organizations and pass userId in request:

Example body:

{
    "userId": 1,
    "orgName": "fromAPI",
    "displayName": "fromAPI",
    "email": "fromAPI@api.com",
    "taxResidency": "CZ",
    "taxSubject": "NATURAL_PERSON"
}

3. Get the Organization vault-id 

Use: GET /api/v2/organizations/{organization-id}/vaults

4. Create portfolio

Under Organization create Portfolio. A Portfolio is required to obtain meaningful computation results.

Use: POST /api/v2/organizations/{organization-id}/vaults/{vault-id}/portfolios

Example body:

{
   "name": "fromAPI1",
   "currency": "USD",
   "computationType": "FIFO",
   "experimentalComputation": true,  
   "feeApplicationType": "AT_PROFIT_REALIZATION",
   "initialState": null
}

5. Create transaction container

Transactions are grouped into transaction containers. 1 (per client) should suffice.

Use: POST /api/v2/organizations/{organization-id}/vaults/{vault-id}/containers

Example body:

{
   "name": "fromAPI1",
   "portfolioId": 1,
   "type": "MANUAL"  # you should always use type manual in this usecase
}

Create transactions

Use: POST /api/v2/organizations//vaults//containers/{container-id}/transactions

Example body:

{
   "baseCurrency":"BTC",
   "quoteCurrency":"USD",
   "type":"BUY",
   "timestamp":1675209600698,
   "note":"",
   "addresses":[],
   "baseQuantity":"10",
   "quoteQuantity":"",
   "unitPrice":"25000"
}

Get portfolio calculations

Use: GET /api/v2/organizations/{organization-id}/vaults/{vault-id}/portfolios/{portfolio-id}/computation/dashboard