NAV
shell

Introduction

Welcome to Libra’s API documentation! We provide a simple user-level REST API for non-commercial use. Contact [email protected] for additional information or business inquiries.

Authentication

curl https://api.libratax.com/v1/auth/check_token?token=LIBRA_API_TOKEN

All API requests need to be authenticated by including the token parameter with each request.

Get Token

Request an access token using your Libra login info.

Example request

curl https://api.libratax.com/v1/auth/authenticate \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
       "email": "[email protected]",
       "password": "mypassword"
     }'

Example response

{
  "token": "af86935b6847ca480daa5aa43421bac6",
  "expires_at": "2015-12-02T23:53:09Z"
}

HTTP Request

POST https://api.libratax.com/v1/auth/authenticate

Query Parameters

Parameter Type Required Description
email string required User’s email address used to log in to Libra
password string required User’s password used to log in to Libra

Check Token

Validate an existing token.

Example request

curl https://api.libratax.com/v1/auth/check_token?token=af86935b6847ca480daa5aa43421bac6

Example response

{
  "token": "af86935b6847ca480daa5aa43421bac6",
  "expires_at": "2015-12-02T23:53:09Z"
}

HTTP Request

GET https://api.libratax.com/v1/auth/check_token

Query Parameters

Parameter Type Required Description
token string required Access token

Addresses

Add Address

Add a supported blockchain address to your account.

Example request

curl https://api.libratax.com/v1/account/addresses \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
       "token": "af86935b6847ca480daa5aa43421bac6",
       "name": "My wallet",
       "address": "1JAWuimEVxA8yUieX9bHwDLcXsUdv1BErr"
     }'

Example response

{
  "address": {
    "id": 1,
    "name": "My Wallet",
    "address": "1JAWuimEVxA8yUieX9bHwDLcXsUdv1BErr",
    "asset": "BTC",
    "balance": "0.0",
    "updated_at": "2016-07-14T00:30:38.382Z",
    "active": true
  }
}

HTTP Request

POST https://api.libratax.com/v1/account/addresses

Query Parameters

Parameter Type Required Description
token string required Access token
name string required A nickname for this address
address string required A valid bitcoin address

Delete Address

Remove an address from your account.

Example request

curl https://api.libratax.com/v1/account/addresses \
  -X DELETE \
  -H "Content-Type: application/json" \
  -d '{
       "token": "af86935b6847ca480daa5aa43421bac6",
       "address": "13dNVu4PhipKgybdQS3yRsndsKQZyPJPCt"
     }'

Example response

{
  "address": {
    "id": 2,
    "name": "Address #2",
    "address": "13dNVu4PhipKgybdQS3yRsndsKQZyPJPCt",
    "asset": "BTC",
    "balance": "4.8151624",
    "updated_at": "2016-08-09T00:30:00.000Z",
    "active": false
  }
}

HTTP Request

DELETE https://api.libratax.com/v1/account/addresses

Query Parameters

Parameter Type Required Description
token string required Access token
address string required A valid bitcoin address

List Addresses

List addresses in your account.

Example request

curl https://api.libratax.com/v1/account/addresses?token=af86935b6847ca480daa5aa43421bac6

Example response

{
  "addresses": [
    {
      "id": 1,
      "name": "My Wallet",
      "address": "1JAWuimEVxA8yUieX9bHwDLcXsUdv1BErr",
      "asset": "BTC",
      "balance": "0.0",
      "updated_at": "2016-07-14T00:30:38.382Z",
      "active": true
    },
    {
      "id": 2,
      "name": "Address #2",
      "address": "13dNVu4PhipKgybdQS3yRsndsKQZyPJPCt",
      "asset": "BTC",
      "balance": "4.8151624",
      "updated_at": "2016-08-09T00:30:00.000Z",
      "active": false
    }
  ],
  "total_pages": 1,
  "page": 1,
  "per_page": 20
}

HTTP Request

GET https://api.libratax.com/v1/account/addresses

Query Parameters

Parameter Type Required Description
token string required Access token
page string Specify the page of results. Default: 1
per_page string Specify the number of results per page. Default: 20

Wallets

List Wallets

List wallets belonging to the current user. Wallets come from external, off-chain account providers.

Example request

curl https://api.libratax.com/v1/account/wallets?token=af86935b6847ca480daa5aa43421bac6

Example response

{
  "wallets": [
    {
      "id": 42,
      "name": "BTC Wallet",
      "provider": {
        "id": 1337,
        "name": "coinbase"
      },
      "asset": "BTC",
      "balance": "1.23",
      "updated_at": "2016-08-09T00:00:00.000Z"
    }...
  ],
  "total_pages": 1,
  "page": 1,
  "per_page": 20
}

HTTP Request

GET https://api.libratax.com/v1/account/wallets

Query Parameters

Parameter Type Required Description
token string required Access token
page string Specify the page of results. Default: 1
per_page string Specify the number of results per page. Default: 20

Show Wallet

Show a specified wallet.

Example request

curl https://api.libratax.com/v1/account/wallets/:id?token=af86935b6847ca480daa5aa43421bac6

Example response

{
  "id": 42,
  "name": "BTC Wallet",
  "provider": {
    "id": 1337,
    "name": "coinbase"
  },
  "asset": "BTC",
  "balance": "1.23",
  "updated_at": "2016-08-09T00:00:00.000Z"
}

HTTP Request

GET https://api.libratax.com/v1/account/wallets/:id

Query Parameters

Parameter Type Required Description
token string required Access token

Transactions

Add Transaction

Example request

curl https://api.libratax.com/v1/account/transactions/create \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
       "token": "af86935b6847ca480daa5aa43421bac6",
       "date": "2015-01-01T00:00:00",
       "amount": "3.14"
     }'

Example response

{
  "transaction": {
    "id": 32704,
    "asset": "BTC",
    "amount": "1.0",
    "fair_value": "316.9",
    "spot_value": null,
    "total_value": "316.9",
    "note": null,
    "destination": null,
    "date": "2015-01-01T00:00:00Z",
    "created_at": "2015-11-20T21:57:45Z",
    "address_id": null,
    "wallet_id": null,
    "tax_type": "purchase"
  }
}

HTTP Request

POST https://api.libratax.com/v1/account/transactions/create

Query Parameters

Parameter Type Required Description
token string required Access token
date datetime required Time of the transaction
amount string required Signed number
asset string BTC, XRP, ETC. Default: BTC
total_value string Value in your functional currency. Default: fair market value closest to the date/time specified
destination string A name or address
note string Any additional information including #hashtags
tax_type string Purchase, Sale, Income, Gift, Transfer, Donation

Bulk Create

Example request

curl https://api.libratax.com/v1/account/transactions/bulk_create \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
       "token": "af86935b6847ca480daa5aa43421bac6",
       "transactions": [
         {
           "date": "2013-06-25T20:11:12Z",
           "amount": "-0.01"
         },
         {
           "date": "2013-08-05T03:37:12Z",
           "amount": "0.01"
         }
       ]
     }'

Example response

{
  "transactions": [
    {
      "id": 38115,
      "asset": "BTC",
      "amount": "-0.01",
      "fair_value": "103.65",
      "spot_value": "103.65",
      "total_value": "-1.04",
      "note": "",
      "destination": "1D5oUFk834pK2fTqcQhxrw9XTqtx2CJ9tU",
      "date": "2013-06-25T20:11:12Z",
      "created_at": "2015-11-20T21:57:45Z",
      "address_id": null,
      "wallet_id": null,
      "tax_type": "sale"
    },
    {
      "id": 38114,
      "asset": "BTC",
      "amount": "0.01",
      "fair_value": "101.91",
      "spot_value": "101.91",
      "total_value": "1.02",
      "note": "",
      "destination": "Andrew",
      "date": "2013-08-05T03:37:12Z",
      "created_at": "2015-11-20T21:57:45Z",
      "address_id": null,
      "wallet_id": null,
      "tax_type": "purchase"
    }
  ]
}

HTTP Request

POST https://api.libratax.com/v1/account/transactions/bulk_create

Query Parameters

Parameter Type Required Description
token string required Access token
transactions array required An array including transaction parameters listed above

Delete Transaction

Example request

curl https://api.libratax.com/v1/account/transactions \
  -X DELETE \
  -H "Content-Type: application/json" \
  -d '{
       "token": "af86935b6847ca480daa5aa43421bac6",
       "id": 8675309
     }'

Example response

{
  "transaction": {
    "id": 8675309,
    "asset": "BTC",
    "amount": "1.0",
    "fair_value": "316.9",
    "spot_value": null,
    "total_value": "316.9",
    "note": null,
    "destination": null,
    "date": "2015-01-01T00:00:00Z",
    "created_at": "2015-11-20T21:57:45Z",
    "address_id": null,
    "wallet_id": null,
    "tax_type": "purchase"
  }
}

HTTP Request

DELETE https://api.libratax.com/v1/account/transactions

Query Parameters

Parameter Type Required Description
token string required Access token
id integer required The Transaction ID

List Transactions

List all transactions in your account.

Example request

curl https://api.libratax.com/v1/account/transactions?token=af86935b6847ca480daa5aa43421bac6

Example response

{
  "transactions": [
    {
      "id": 38115,
      "asset": "BTC",
      "amount": "-0.01",
      "fair_value": "103.65",
      "spot_value": "103.65",
      "total_value": "-1.04",
      "note": "",
      "destination": "1D5oUFk834pK2fTqcQhxrw9XTqtx2CJ9tU",
      "date": "2013-06-25T20:11:12Z",
      "created_at": "2015-11-20T21:57:45Z",
      "address_id": 1,
      "wallet_id": null,
      "tax_type": "sale"
    },
    {
      "id": 38114,
      "asset": "BTC",
      "amount": "0.01",
      "fair_value": "101.91",
      "spot_value": "101.91",
      "total_value": "1.02",
      "note": "",
      "destination": "Andrew",
      "date": "2013-08-05T03:37:12Z",
      "created_at": "2015-11-20T21:57:45Z",
      "address_id": 1,
      "wallet_id": null,
      "tax_type": "purchase"
    }...
  ],
  "total_pages": 6,
  "page": 1,
  "per_page": 20
}

HTTP Request

GET https://api.libratax.com/v1/account/transactions

Query Parameters

Parameter Type Required Description
token string required Access token
page string Specify the page of results. Default: 1
per_page string Specify the number of results per page. Default: 20

Trades

Add Trade

Example request

curl https://api.libratax.com/v1/account/trades/create \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
       "token": "af86935b6847ca480daa5aa43421bac6",
       "datetime": "2015-05-15T22:16:50Z",
       "amount1": "-0.2",
       "asset1": "BTC",
       "amount2": "62.33",
       "asset2": "SGD",
       "direction": "buy"
     }'

Example response

{
  "trade": {
    "id": 41,
    "asset1": "BTC",
    "amount1": "-0.2",
    "asset2": "SGD",
    "amount2": "62.33",
    "rate": "311.65",
    "direction": "buy",
    "total_value": "-47.7",
    "note": null,
    "datetime": "2015-05-15T22:16:50Z",
    "created_at": "2015-11-20T21:57:45Z",
    "provider": null,
    "provider_id": null
  }
}

HTTP Request

POST https://api.libratax.com/v1/account/trades/create

Query Parameters

Parameter Type Required Description
token string required Access token
datetime datetime required Time of the trade
amount1 string required Signed number
asset1 string required BTC, XRP, ETC
amount2 string required Signed number
asset2 string required BTC, XRP, ETC
direction string required “buy” or “sell”
note string Any additional information including #hashtags
provider string Exchange where trade occurred
provider_id string Exchange-issued ID

List Trades

List all trades in your account.

Example request

curl https://api.libratax.com/v1/account/trades?token=af86935b6847ca480daa5aa43421bac6

Example response

{
  "trades": [
    {
      "id": 40,
      "asset1": "BTC",
      "amount1": "0.15",
      "asset2": "USD",
      "amount2": "-35.58",
      "rate": "237.23",
      "total_value": "35.58",
      "note": null,
      "direction": "buy",
      "datetime": "2015-05-15T22:17:40Z",
      "created_at": "2015-11-20T21:57:45Z",
      "provider": "itbit",
      "provider_id": null
    },
    {
      "id": 41,
      "asset1": "BTC",
      "amount1": "-0.2",
      "asset2": "SGD",
      "amount2": "62.33",
      "rate": "311.65",
      "total_value": "-47.7",
      "note": null,
      "direction": "sell",
      "datetime": "2015-05-15T22:16:50Z",
      "created_at": "2015-11-20T21:57:45Z",
      "provider": "itbit",
      "provider_id": null
    },...

HTTP Request

GET https://api.libratax.com/v1/account/trades

Query Parameters

Parameter Type Required Description
token string required Access token
page string Specify the page of results. Default: 1
per_page string Specify the number of results per page. Default: 20

Lot Matching

List Matched Lots

List all lot matchings in your account.

Example request

curl https://api.libratax.com/v1/account/matched_lots?token=af86935b6847ca480daa5aa43421bac6

Example response

[
  {
    "id": 208,
    "calculation_method": "fifo",
    "asset": "XBT",
    "lots": [
      "{\"id\"=>198533, \"amount\"=>\"50.0\", \"date\"=>\"2014-09-29\", \"fair_value\"=>nil, \"fee\"=>nil, \"spot_value\"=>\"374.42\", \"tax_type\"=>\"purchase\", \"total_value\"=>\"18721.0\", \"asset\"=>\"BTC\", \"sale_id\"=>198527, \"date_sold\"=>\"2014-09-29\", \"net_gain\"=>\"0.22334269720000000000000000178732274\", \"amount_sold\"=>\"11.34650034\", \"amount_remaining\"=>nil, \"lot_remaining\"=>\"50.0\", \"gain_type\"=>\"Short\", \"sale_value_per_coin\"=>\"374.439683839995372529112355361\", \"cost_basis_per_coin\"=>\"374.42\", \"value_per_coin\"=>\"374.42\", \"total_sale_value\"=>\"4248.58000000000000000000000000178732274\", \"total_cost_basis\"=>\"4248.3566573028\"}"
    ],
    "user_id": 9,
    "created_at": "2016-03-08T21:43:52.183Z",
    "updated_at": "2016-03-08T21:43:52.183Z",
    "calculation_started_at": null,
    "unsold_lots": null,
    "invalidated_at": null
  },
  {
    "id": 209,
    "calculation_method": "selective",
    "asset": "XBT",
    "lots": [
      "{\"id\"=>198533, \"amount\"=>\"50.0\", \"date\"=>\"2014-09-29\", \"fair_value\"=>nil, \"fee\"=>nil, \"spot_value\"=>\"374.42\", \"tax_type\"=>\"purchase\", \"total_value\"=>\"18721.0\", \"asset\"=>\"BTC\", \"sale_id\"=>198527, \"date_sold\"=>\"2014-09-29\", \"net_gain\"=>\"0.22334269720000000000000000178732274\", \"amount_sold\"=>\"11.34650034\", \"amount_remaining\"=>nil, \"lot_remaining\"=>\"50.0\", \"gain_type\"=>\"Short\", \"sale_value_per_coin\"=>\"374.439683839995372529112355361\", \"cost_basis_per_coin\"=>\"374.42\", \"value_per_coin\"=>\"374.42\", \"total_sale_value\"=>\"4248.58000000000000000000000000178732274\", \"total_cost_basis\"=>\"4248.3566573028\"}"
    ],
    "user_id": 9,
    "created_at": "2016-03-08T21:53:57.637Z",
    "updated_at": "2016-03-08T21:53:57.637Z",
    "calculation_started_at": null,
    "unsold_lots": null,
    "invalidated_at": null
  }...

HTTP Request

GET https://api.libratax.com/v1/account/matched_lots

Show Matched Lot

Show a specified lot matching.

Example request

curl https://api.libratax.com/v1/account/matched_lots/:id?token=af86935b6847ca480daa5aa43421bac6

Example response

{
  "id": 208,
  "calculation_method": "fifo",
  "asset": "XBT",
  "lots": [
    "{\"id\"=>198533, \"amount\"=>\"50.0\", \"date\"=>\"2014-09-29\", \"fair_value\"=>nil, \"fee\"=>nil, \"spot_value\"=>\"374.42\", \"tax_type\"=>\"purchase\", \"total_value\"=>\"18721.0\", \"asset\"=>\"BTC\", \"sale_id\"=>198527, \"date_sold\"=>\"2014-09-29\", \"net_gain\"=>\"0.22334269720000000000000000178732274\", \"amount_sold\"=>\"11.34650034\", \"amount_remaining\"=>nil, \"lot_remaining\"=>\"50.0\", \"gain_type\"=>\"Short\", \"sale_value_per_coin\"=>\"374.439683839995372529112355361\", \"cost_basis_per_coin\"=>\"374.42\", \"value_per_coin\"=>\"374.42\", \"total_sale_value\"=>\"4248.58000000000000000000000000178732274\", \"total_cost_basis\"=>\"4248.3566573028\"}"
  ],
  "user_id": 9,
  "created_at": "2016-03-08T21:43:52.183Z",
  "updated_at": "2016-03-08T21:43:52.183Z",
  "calculation_started_at": null,
  "unsold_lots": null,
  "invalidated_at": null
}

HTTP Request

GET https://api.libratax.com/v1/account/matched_lots/:id

Create Matched Lot

Create your own lot matching.

Example request

curl -X POST -d 'calculation_method=selective&asset=XBT&lots=%5B%7B%22id%22%3A198533%2C+%22amount%22%3A%2250.0%22%2C+%22date%22%3A%222014-09-29%22%2C+%22fair_value%22%3Anull%2C+%22fee%22%3Anull%2C+%22spot_value%22%3A%22374.42%22%2C+%22tax_type%22%3A%22purchase%22%2C+%22total_value%22%3A%2218721.0%22%2C+%22asset%22%3A%22BTC%22%2C+%22sale_id%22%3A198527%2C+%22date_sold%22%3A%222014-09-29%22%2C+%22net_gain%22%3A%220.22334269720000000000000000178732274%22%2C+%22amount_sold%22%3A%2211.34650034%22%2C+%22amount_remaining%22%3Anull%2C+%22lot_remaining%22%3A%2250.0%22%2C+%22gain_type%22%3A%22Short%22%2C+%22sale_value_per_coin%22%3A%22374.439683839995372529112355361%22%2C+%22cost_basis_per_coin%22%3A%22374.42%22%2C+%22value_per_coin%22%3A%22374.42%22%2C+%22total_sale_value%22%3A%224248.58000000000000000000000000178732274%22%2C+%22total_cost_basis%22%3A%224248.3566573028%22%7D%5D' "http://api.lvh.me:3000/v1/account/matched_lots/create?token=af86935b6847ca480daa5aa43421bac6"

Example response

{
  "id": 209,
  "calculation_method": "selective",
  "asset": "XBT",
  "lots": [
    "{\"id\"=>198533, \"amount\"=>\"50.0\", \"date\"=>\"2014-09-29\", \"fair_value\"=>nil, \"fee\"=>nil, \"spot_value\"=>\"374.42\", \"tax_type\"=>\"purchase\", \"total_value\"=>\"18721.0\", \"asset\"=>\"BTC\", \"sale_id\"=>198527, \"date_sold\"=>\"2014-09-29\", \"net_gain\"=>\"0.22334269720000000000000000178732274\", \"amount_sold\"=>\"11.34650034\", \"amount_remaining\"=>nil, \"lot_remaining\"=>\"50.0\", \"gain_type\"=>\"Short\", \"sale_value_per_coin\"=>\"374.439683839995372529112355361\", \"cost_basis_per_coin\"=>\"374.42\", \"value_per_coin\"=>\"374.42\", \"total_sale_value\"=>\"4248.58000000000000000000000000178732274\", \"total_cost_basis\"=>\"4248.3566573028\"}"
  ],
  "user_id": 9,
  "created_at": "2016-03-08T21:43:52.183Z",
  "updated_at": "2016-03-08T21:43:52.183Z",
  "calculation_started_at": null,
  "unsold_lots": null,
  "invalidated_at": null
}

HTTP Request

POST https://api.libratax.com/v1/account/matched_lots/create

Query Parameters

Parameter Type Required Description
calculation_method string required fifo, lifo, selective
asset string required BTC
lots JSON string required Set of matched lots

Calculations

Get Calculation

Processes and returns gain/loss calculations.

Example request

curl https://api.libratax.com/v1/account/calculations?token=af86935b6847ca480daa5aa43421bac6&method=fifo&asset=BTC&year=2015

Example response

{
  "method": "fifo",
  "asset": "BTC",
  "period": "2015",
  "status": {
    "ready": true
  },
  "total_gains": {
    "long_term": "139.995791763",
    "total": "139.995791763",
    "unrealized": 0
  },
  "taggable_totals": {
    "drinks": "-23.19"
  },
  "categories_totals": {
    "accounts payable": "2342.00",
    "accounts receivable": "4815.16"
  }
}

HTTP Request

GET https://api.libratax.com/v1/account/calculations

Query Parameters

Parameter Type Required Description
token string required Access token
method string Default: FIFO
asset string Default: BTC
year string Default: All
month string Default: All