bitcain docs
API Reference

Portfolio

Portfolio management - view balances, positions, and performance metrics

Portfolio Health

GET
/api/v1/portfolio/health

Response Body

application/json

curl -X GET "https://loading/api/v1/portfolio/health"
{}

Get Portfolio Balances

GET
/api/v1/portfolio/balances

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Query Parameters

exchange?string

Exchange to query balances from

Default"binanceus"

Response Body

application/json

application/json

curl -X GET "https://loading/api/v1/portfolio/balances"
{}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Get Portfolio Aggregate

GET
/api/v1/portfolio/aggregate

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Response Body

application/json

curl -X GET "https://loading/api/v1/portfolio/aggregate"
{}

Get Portfolio Cost Basis

GET
/api/v1/portfolio/cost-basis

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Response Body

application/json

curl -X GET "https://loading/api/v1/portfolio/cost-basis"
{}

Get Account Cost Basis Lots

GET
/api/v1/portfolio/cost-basis/lots

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Response Body

application/json

curl -X GET "https://loading/api/v1/portfolio/cost-basis/lots"
{}

Rebuild Account Cost Basis Lots

POST
/api/v1/portfolio/cost-basis/lots/rebuild

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Response Body

application/json

curl -X POST "https://loading/api/v1/portfolio/cost-basis/lots/rebuild"
{}

Backfill Ingest

POST
/api/v1/portfolio/ingest/backfill

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Query Parameters

source?string
Default"trade_history_sync"
dry_run?boolean
Defaultfalse
max_pages?integer

Max Coinbase-ledger pages to fetch per currency

Default3
Range1 <= value <= 25

Response Body

application/json

application/json

curl -X POST "https://loading/api/v1/portfolio/ingest/backfill"
{}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Ingest Coinbase Csv

POST
/api/v1/portfolio/ingest/csv

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Query Parameters

dry_run?boolean
Defaultfalse

Request Body

multipart/form-data

file*string

Coinbase Statements 'Transaction history' CSV

Response Body

application/json

application/json

curl -X POST "https://loading/api/v1/portfolio/ingest/csv" \  -F file="string"
{}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Refresh Portfolio

POST
/api/v1/portfolio/refresh

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Response Body

application/json

curl -X POST "https://loading/api/v1/portfolio/refresh"
{}

Get Holdings Value History

GET
/api/v1/portfolio/value-history

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Query Parameters

days?integer

How many days of history to return

Default30
Range1 <= value <= 365

Response Body

application/json

application/json

curl -X GET "https://loading/api/v1/portfolio/value-history"
{}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

List Portfolios

GET
/api/v1/portfolio/

Query Parameters

user_id*string

User ID for portfolio ownership

active_only?boolean

Filter for active portfolios only

Defaulttrue
limit?integer

Maximum number of portfolios

Default50
Range1 <= value <= 100
offset?integer

Number of portfolios to skip

Default0
Range0 <= value

Response Body

application/json

application/json

curl -X GET "https://loading/api/v1/portfolio/?user_id=string"
[
  {
    "portfolio_id": "5555717d-15c7-408a-aad2-f3155d61ff77",
    "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
    "name": "string",
    "description": "string",
    "total_value_usd": "string",
    "target_allocations": {
      "property1": 0,
      "property2": 0
    },
    "current_allocations": {
      "property1": 0,
      "property2": 0
    },
    "last_rebalanced_at": "2019-08-24T14:15:22Z",
    "is_active": true,
    "created_at": "2019-08-24T14:15:22Z",
    "updated_at": "2019-08-24T14:15:22Z",
    "risk_tolerance": "conservative",
    "status": "created",
    "is_default": true,
    "total_return": "string",
    "total_return_percentage": "string",
    "tags": [
      "string"
    ]
  }
]
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Create Portfolio

POST
/api/v1/portfolio/

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Query Parameters

user_id*string

User ID for portfolio ownership

Request Body

application/json

name*string

Portfolio name (must be unique per user)

Lengthlength <= 100
description?|

Portfolio description

target_allocations*

Target asset allocations as decimal percentages (must sum to 1.0)

risk_tolerance?string

Risk tolerance level

Default"moderate"
Value in"conservative" | "moderate" | "aggressive"
is_active?boolean

Portfolio actively managed

Defaulttrue
is_default?boolean

Set as default portfolio

Defaultfalse
initial_value_usd?|

Initial portfolio value in USD

Default"0"
tags?array<>

Portfolio tags

Response Body

application/json

application/json

curl -X POST "https://loading/api/v1/portfolio/?user_id=string" \  -H "Content-Type: application/json" \  -d '{    "name": "string",    "target_allocations": {      "property1": 0,      "property2": 0    }  }'
{
  "portfolio_id": "5555717d-15c7-408a-aad2-f3155d61ff77",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
  "name": "string",
  "description": "string",
  "total_value_usd": "string",
  "target_allocations": {
    "property1": 0,
    "property2": 0
  },
  "current_allocations": {
    "property1": 0,
    "property2": 0
  },
  "last_rebalanced_at": "2019-08-24T14:15:22Z",
  "is_active": true,
  "created_at": "2019-08-24T14:15:22Z",
  "updated_at": "2019-08-24T14:15:22Z",
  "risk_tolerance": "conservative",
  "status": "created",
  "is_default": true,
  "total_return": "string",
  "total_return_percentage": "string",
  "tags": [
    "string"
  ]
}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Get Portfolio

GET
/api/v1/portfolio/{portfolio_id}

Path Parameters

portfolio_id*string

Query Parameters

user_id?string

User ID for ownership verification

Response Body

application/json

application/json

curl -X GET "https://loading/api/v1/portfolio/string"
{
  "portfolio_id": "5555717d-15c7-408a-aad2-f3155d61ff77",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
  "name": "string",
  "description": "string",
  "total_value_usd": "string",
  "target_allocations": {
    "property1": 0,
    "property2": 0
  },
  "current_allocations": {
    "property1": 0,
    "property2": 0
  },
  "last_rebalanced_at": "2019-08-24T14:15:22Z",
  "is_active": true,
  "created_at": "2019-08-24T14:15:22Z",
  "updated_at": "2019-08-24T14:15:22Z",
  "risk_tolerance": "conservative",
  "status": "created",
  "is_default": true,
  "total_return": "string",
  "total_return_percentage": "string",
  "tags": [
    "string"
  ]
}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Delete Portfolio

DELETE
/api/v1/portfolio/{portfolio_id}

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Path Parameters

portfolio_id*string

Query Parameters

user_id*string

User ID for ownership verification

force?boolean

Force deletion even if portfolio has assets

Defaultfalse

Response Body

application/json

curl -X DELETE "https://loading/api/v1/portfolio/string?user_id=string"
Empty
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Update Portfolio

PUT
/api/v1/portfolio/{portfolio_id}

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Path Parameters

portfolio_id*string

Query Parameters

user_id*string

User ID for ownership verification

Request Body

application/json

name?|

Portfolio name

description?|

Portfolio description

target_allocations?|

Updated target asset allocations (must sum to 1.0 if provided)

risk_tolerance?|

Risk tolerance level

is_active?|

Portfolio actively managed

tags?array<>|

Portfolio tags

Response Body

application/json

application/json

curl -X PUT "https://loading/api/v1/portfolio/string?user_id=string" \  -H "Content-Type: application/json" \  -d '{}'
{
  "portfolio_id": "5555717d-15c7-408a-aad2-f3155d61ff77",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
  "name": "string",
  "description": "string",
  "total_value_usd": "string",
  "target_allocations": {
    "property1": 0,
    "property2": 0
  },
  "current_allocations": {
    "property1": 0,
    "property2": 0
  },
  "last_rebalanced_at": "2019-08-24T14:15:22Z",
  "is_active": true,
  "created_at": "2019-08-24T14:15:22Z",
  "updated_at": "2019-08-24T14:15:22Z",
  "risk_tolerance": "conservative",
  "status": "created",
  "is_default": true,
  "total_return": "string",
  "total_return_percentage": "string",
  "tags": [
    "string"
  ]
}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Get Portfolio Analytics

GET
/api/v1/portfolio/{portfolio_id}/analytics

Path Parameters

portfolio_id*string

Query Parameters

user_id*string

User ID for ownership verification

Response Body

application/json

application/json

curl -X GET "https://loading/api/v1/portfolio/string/analytics?user_id=string"
{}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Get Portfolio History

GET
/api/v1/portfolio/history

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Query Parameters

timeframe?string

Timeframe for historical data

Default"1M"
Value in"1D" | "1W" | "1M" | "3M" | "1Y" | "ALL"
portfolio_id?|

Optional specific portfolio ID

currency?string

Currency denomination

Default"USD"

Response Body

application/json

application/json

curl -X GET "https://loading/api/v1/portfolio/history"
[
  {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
    "portfolio_id": "5555717d-15c7-408a-aad2-f3155d61ff77",
    "total_value": "string",
    "currency": "string",
    "recorded_at": "2019-08-24T14:15:22Z",
    "created_at": "2019-08-24T14:15:22Z",
    "metadata": {}
  }
]
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Get Portfolio Performance

GET
/api/v1/portfolio/history/performance

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Query Parameters

timeframe?string

Timeframe for performance metrics

Default"1M"
Value in"1D" | "1W" | "1M" | "3M" | "1Y" | "ALL"
portfolio_id?|

Optional specific portfolio ID

currency?string

Currency denomination

Default"USD"

Response Body

application/json

application/json

curl -X GET "https://loading/api/v1/portfolio/history/performance"
{
  "period_start": "2019-08-24T14:15:22Z",
  "period_end": "2019-08-24T14:15:22Z",
  "timeframe": "1D",
  "starting_value": "string",
  "ending_value": "string",
  "current_value": "string",
  "highest_value": "string",
  "lowest_value": "string",
  "absolute_change": "string",
  "absolute_gain": "string",
  "percentage_change": "string",
  "percentage_gain": "string",
  "is_profitable": true,
  "return_rate": "string",
  "max_drawdown": "string",
  "volatility": "string",
  "total_data_points": 0,
  "currency": "USD"
}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Export Portfolio History

GET
/api/v1/portfolio/history/export

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Query Parameters

timeframe?string

Timeframe for export

Default"1M"
Value in"1D" | "1W" | "1M" | "3M" | "1Y" | "ALL"
portfolio_id?|

Optional specific portfolio ID

currency?string

Currency denomination

Default"USD"

Response Body

application/json

application/json

curl -X GET "https://loading/api/v1/portfolio/history/export"
null
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}