CoinTracking Data API
The CoinTracking API allows you to access your account data. You need an API key and secret to use the API.Please find all relevant information in the documentation below.
Please login into your account to create API keys
CoinTracking API Documentation
Information
All API requests must be send to the following URL via POST: https://cointracking.info/api/v1/
API responses are in JSON.
All requests needs an authentication.
Authentication
Send your key and sign as http header.
The sign is a HMAC-SHA512 message of the method, the nonce and the POST data, signed with your API secret.
The nonce must be increasing for each call. We recommend to use UNIX time or microtime.
Request limits
In most situations one call per hour is enough.
Maximum API requests:
- FREE users: No API access yet
- PRO & EXPERT users: 20 calls per hour
- UNLIMITED users: 60 calls per hour
Please don't exeed these limits or you will be blocked.
Successful calls
Array ( [success] => 1 [method] => getTrades )
Errors
Array ( [success] => 0 [method] => getTrades [error] => NO_METHOD [error_msg] => ERROR: Method not set )
CoinTracking API code examples
function cointracking($method, array $par = array()) {
// API data
$key = '123456789'; // YOUR API KEY
$secret = 'abcdefghij'; // YOUR API SECRET
$par['method'] = $method;
$par['nonce'] = time();
$post_data = http_build_query($par, '', '&');
$sign = hash_hmac('sha512', $post_data, $secret);
$headers = array(
'Key: '.$key,
'Sign: '.$sign
);
// curl
static $ch = null;
if (is_null($ch)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; CoinTracking PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
}
curl_setopt($ch, CURLOPT_URL, 'https://cointracking.info/api/v1/');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$res = curl_exec($ch);
if ($res === false) throw new Exception('API ERROR - No reply: '.curl_error($ch));
$json = json_decode($res, true);
if (!$json) throw new Exception('API ERROR - Invalid data received, please check connection and API data');
return $json;
}
// Test request
$result = cointracking('getTrades', array('limit' => '200', 'order' => 'DESC', 'start' => 1300000000, 'end' => 1450000000));
print_r($result);
using System;
using System.Text;
using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Collections;
using System.Collections.Generic;
using System.Net.Http;
using System.Linq;
namespace ct_api
{
class CoinTrackingAPI
{
readonly string url = "https://cointracking.info/api/v1/";
private readonly string apiKey;
private readonly string apiSecret;
static readonly HttpClient client = new HttpClient();
public CoinTrackingAPI(string key, string secret)
{
apiKey = key;
apiSecret = secret;
}
private FormUrlEncodedContent prepareRequestData(string method, IEnumerable<KeyValuePair<string, string>> data)
{
return new FormUrlEncodedContent(
Enumerable.Concat(
data,
new[] {
new KeyValuePair<string, string>("method", method),
new KeyValuePair<string, string>("nonce", new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds().ToString())
}
)
);
}
private async Task signMessage(FormUrlEncodedContent formData)
{
HMACSHA512 hmac = new HMACSHA512(Encoding.ASCII.GetBytes(apiSecret));
byte[] sign = hmac.ComputeHash(await formData.ReadAsByteArrayAsync());
formData.Headers.Add("Key", apiKey);
formData.Headers.Add("Sign", BitConverter.ToString(sign).Replace("-", string.Empty).ToLower());
}
public async Task<string> getTrades(int limit = 0, string order = "ASC", int start = 0, int end = 0, bool tradePrices = false)
{
List<KeyValuePair<string, string>> optionalParams = new List<KeyValuePair<string, string>>();
if (limit > 0) {
optionalParams.Add(new KeyValuePair<string, string>("limit", limit.ToString()));
}
optionalParams.Add(new KeyValuePair<string, string>("order", order));
if (start > 0) {
optionalParams.Add(new KeyValuePair<string, string>("start", start.ToString()));
}
if (end > 0) {
optionalParams.Add(new KeyValuePair<string, string>("end", end.ToString()));
}
if (tradePrices) {
optionalParams.Add(new KeyValuePair<string, string>("trade_prices", "1"));
}
FormUrlEncodedContent formData = prepareRequestData("getTrades", optionalParams);
await signMessage(formData);
HttpResponseMessage response = await client.PostAsync(url, formData);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
public async Task<string> getBalance()
{
FormUrlEncodedContent formData = prepareRequestData("getBalance", new List<KeyValuePair<string, string>>());
await signMessage(formData);
HttpResponseMessage response = await client.PostAsync(url, formData);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
public async Task<string> getHistoricalSummary(bool btc = false, int start = 0, int end = 0)
{
List<KeyValuePair<string, string>> optionalParams = new List<KeyValuePair<string, string>>();
if (btc) {
optionalParams.Add(new KeyValuePair<string, string>("btc", "1"));
}
if (start > 0) {
optionalParams.Add(new KeyValuePair<string, string>("start", start.ToString()));
}
if (end > 0) {
optionalParams.Add(new KeyValuePair<string, string>("end", end.ToString()));
}
FormUrlEncodedContent formData = prepareRequestData("getHistoricalSummary", optionalParams);
await signMessage(formData);
HttpResponseMessage response = await client.PostAsync(url, formData);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
public async Task<string> getHistoricalCurrency(string currency = null, int start = 0, int end = 0)
{
List<KeyValuePair<string, string>> optionalParams = new List<KeyValuePair<string, string>>();
if (!string.IsNullOrEmpty(currency)) {
optionalParams.Add(new KeyValuePair<string, string>("currency", currency));
}
if (start > 0) {
optionalParams.Add(new KeyValuePair<string, string>("start", start.ToString()));
}
if (end > 0) {
optionalParams.Add(new KeyValuePair<string, string>("end", end.ToString()));
}
FormUrlEncodedContent formData = prepareRequestData("getHistoricalCurrency", optionalParams);
await signMessage(formData);
HttpResponseMessage response = await client.PostAsync(url, formData);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
public async Task<string> getGroupedBalance(string group = "exchange", bool excludeDepWith = false, string type = null)
{
List<KeyValuePair<string, string>> optionalParams = new List<KeyValuePair<string, string>>();
if (!string.IsNullOrEmpty(group)) {
optionalParams.Add(new KeyValuePair<string, string>("group", group));
}
if (!string.IsNullOrEmpty(type)) {
optionalParams.Add(new KeyValuePair<string, string>("type", type));
}
if (excludeDepWith) {
optionalParams.Add(new KeyValuePair<string, string>("exclude_dep_with", "1"));
}
FormUrlEncodedContent formData = prepareRequestData("getGroupedBalance", optionalParams);
await signMessage(formData);
HttpResponseMessage response = await client.PostAsync(url, formData);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
public async Task<string> getGains(string price = null, bool btc = false)
{
List<KeyValuePair<string, string>> optionalParams = new List<KeyValuePair<string, string>>();
if (!string.IsNullOrEmpty(price)) {
optionalParams.Add(new KeyValuePair<string, string>("price", price));
}
if (btc) {
optionalParams.Add(new KeyValuePair<string, string>("btc", "1"));
}
FormUrlEncodedContent formData = prepareRequestData("getGains", optionalParams);
await signMessage(formData);
HttpResponseMessage response = await client.PostAsync(url, formData);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
}
}
Example to call your data:
using System;
using System.Threading.Tasks;
namespace ct_api
{
class Program
{
static async Task Main(string[] args)
{
CoinTrackingAPI api = new CoinTrackingAPI("key", "secret");
Console.WriteLine(await api.getTrades());
Console.WriteLine(await api.getBalance());
Console.WriteLine(await api.getHistoricalSummary());
Console.WriteLine(await api.getHistoricalCurrency("BTC"));
Console.WriteLine(await api.getGroupedBalance("type"));
Console.WriteLine(await api.getGains("best"));
}
}
}
Postman Collection (v2.1)
NodeJs example by bpirson (GitHub)
Python example by tbl42 (GitHub)
Integration for non-developers
Cryptosheets provides add-ins with which your CoinTracking data can be imported into Excel and Google Sheets and gets automatically updated.
This is the ideal solution to create your own reports and charts with your CoinTracking data.
No coding knowledge required.
- Instruction: How to connect your CoinTracking account with Cryptosheets
- Examples: Cointracking.info data in Excel & Google Sheets using Cryptosheets
- More details: Manage Your Crypto Portfolio with Cryptosheets & Cointracking.info
1) Visit cryptosheets.com and download the Excel or the Google Sheets add-in
2) Open the add-in in Excel or Google Sheets and navigate to "Settings"
3) Click on "All Integrations" and activate "CoinTracking"
4) Select "Your Integrations" -> "CoinTracking" and click on the "edit" icon
5) Enter your CoinTracking API key and secret (can be generated at the top of this page)
You are now ready to push your CoinTracking data into your spreadsheet
- Select the home icon within your add-in window and click on "Browse Data"
- Select "Providers" and search for "CoinTracking"
- Select any of the endpoints to load your data into your spreadsheet (here are some examples)
You can use Cryptosheets for free without restrictions for up to 1000 API requests per month (paid plans are available for users who need more than 1000 calls per month).
Methods
Please find all methods below.
getTrades
Returns all your CoinTracking trades and transactions. Similar to the Trade List.Example:
$result = cointracking('getTrades', array('limit' => '100', 'order' => 'ASC', 'start' => 1200000000, 'end' => 1450000000));
Parameter:
| Call | Required | Default | Description |
|---|---|---|---|
| limit | optional | all | Number of trades |
| order | optional | ASC | ASC or DESC order by trade time |
| start | optional | no start date | UNIX timestamp as trade start date |
| end | optional | no end date | UNIX timestamp as trade end date |
| trade_prices | optional | 0 (disabled) | Set to "1" to show the value of every buy and sell in BTC and in your account currency |
Response:
Array ( [success] => 1 [method] => getTrades [574025] => Array ( [buy_amount] => 0.50000000 [buy_currency] => BTC [sell_amount] => 900.20000000 [sell_currency] => USD [fee_amount] => 4.50000000 [fee_currency] => USD [type] => Trade [exchange] => Kraken [group] => [comment] => This is a Kraken Trade [imported_from] => kraken [time] => 1320442867 [imported_time] => 1391037169 [trade_id] => 43250 ) [574024] => Array ( [buy_amount] => 1 [buy_currency] => BTC [sell_amount] => [sell_currency] => [fee_amount] => [fee_currency] => [type] => Deposit [exchange] => Bittrex [group] => My Bittrex Deposits [comment] => This is a Bittrex Deposit [imported_from] => job_bittrex [time] => 1320506675 [imported_time] => 1391037169 [trade_id] => fe9ois82msma91d821a ) ... )
Field Description:
| Field | Description |
|---|---|
| key | The unique CoinTracking transaction id |
| buy_amount | The bought or received amount |
| buy_currency | The bought or received currency |
| sell_amount | The sold or withdrawn amount |
| sell_currency | The sold or withdrawn currency |
| fee_amount | The fee amount |
| fee_currency | The fee currency |
| type | Possible types: Trade | Deposit | Withdrawal | Income | Mining | Gift/Tip(In) | Spend | Donation | Gift(Out) | Stolen | Lost | Airdrop | Staking | Masternode | Minting | Dividends Income | Lending Income | Interest Income | Reward / Bonus | Mining (commercial) | Margin Profit | Derivatives / Futures Profit | LP Rewards | Other Income | Income (non taxable) | Other Income (non taxable) | Airdrop (non taxable) | Receive Loan | Receive Collateral | Remove Liquidity | Receive LP Token | Margin Loss | Margin Fee | Borrowing Fee | Settlement Fee | Derivatives / Futures Loss | Other Fee | Provide Liquidity | Return LP Token | Other Expense | Expense (non taxable) | Send Collateral | Repay Loan | Liquidation | Margin Trade | Derivatives / Futures Trade | Swap (non taxable) | |
| exchange | The exchange set on CoinTracking |
| group | The trade group set on CoinTracking |
| comment | The comment set on CoinTracking |
| imported_from | The name of the exchange, this transaction was imported from. (e.g. kraken). API imports start with 'job' (e.g. job_kraken). Only for imported transactions. |
| time | The UNIX timestamp of the transaction |
| imported_time | The UNIX timestamp this transaction was added to CoinTracking |
| trade_id | The trade id of the exchange. Only for imported transactions. |
getTradesByUser
Returns your CoinTracking trades and transactions for a specific user. Similar to the Trade List.Example:
$result = cointracking('getTradesByUser', array('user' => 'user@email.com', 'limit' => '100', 'order' => 'ASC', 'start' => 1200000000, 'end' => 1450000000, 'trade_prices' => 0));
Parameter:
| Call | Required | Default | Description |
|---|---|---|---|
| user | required | User identification | |
| limit | optional | all | Number of trades |
| order | optional | ASC | ASC or DESC order by trade time |
| start | optional | no start date | UNIX timestamp as trade start date |
| end | optional | no end date | UNIX timestamp as trade end date |
| trade_prices | optional | 0 (disabled) | Set to "1" to show the value of every buy and sell in BTC and in your account currency |
Response:
Array
(
[success] => 1
[method] => getTradesByUser
[user] => user@email.com
[trades] => Array
(
Array (
[buy_amount] => 0.50000000
[buy_currency] => BTC
[sell_amount] => 900.20000000
[sell_currency] => USD
[fee_amount] => 4.50000000
[fee_currency] => USD
[type] => Trade
[exchange] => Kraken
[comment] => This is a Kraken Trade
[imported_from] => kraken
[time] => 1320442867
[imported_time] => 1391037169
[trade_id] => 43250
),
Array (
[buy_amount] => 1
[buy_currency] => BTC
[sell_amount] =>
[sell_currency] =>
[fee_amount] =>
[fee_currency] =>
[type] => Deposit
[exchange] => Bittrex
[comment] => This is a Bittrex Deposit
[imported_from] => job_bittrex
[time] => 1320506675
[imported_time] => 1391037169
[trade_id] => fe9ois82msma91d821a
)
...
)
)
Field Description:
| Field | Description |
|---|---|
| key | The unique CoinTracking transaction id |
| buy_amount | The bought or received amount |
| buy_currency | The bought or received currency |
| sell_amount | The sold or withdrawn amount |
| sell_currency | The sold or withdrawn currency |
| fee_amount | The fee amount |
| fee_currency | The fee currency |
| type | Possible types: Trade | Deposit | Withdrawal | Income | Mining | Gift/Tip(In) | Spend | Donation | Gift(Out) | Stolen | Lost | Airdrop | Staking | Masternode | Minting | Dividends Income | Lending Income | Interest Income | Reward / Bonus | Mining (commercial) | Margin Profit | Derivatives / Futures Profit | LP Rewards | Other Income | Income (non taxable) | Other Income (non taxable) | Airdrop (non taxable) | Receive Loan | Receive Collateral | Remove Liquidity | Receive LP Token | Margin Loss | Margin Fee | Borrowing Fee | Settlement Fee | Derivatives / Futures Loss | Other Fee | Provide Liquidity | Return LP Token | Other Expense | Expense (non taxable) | Send Collateral | Repay Loan | Liquidation | Margin Trade | Derivatives / Futures Trade | Swap (non taxable) | |
| exchange | The exchange set on CoinTracking |
| comment | The comment set on CoinTracking |
| imported_from | The name of the exchange, this transaction was imported from. (e.g. kraken). API imports start with 'job' (e.g. job_kraken). Only for imported transactions. |
| time | The UNIX timestamp of the transaction |
| imported_time | The UNIX timestamp this transaction was added to CoinTracking |
| trade_id | The trade id of the exchange. Only for imported transactions. |
getBalance
Returns your current CoinTracking account and coin balance. Similar to the Current Balance.Example:
$result = cointracking('getBalance');
Parameter:
There are no parameter for getBalance calls.
Response:
Array ( [success] => 1 [method] => getBalance [account_currency] => EUR [details] => Array ( [BTC] => Array ( [amount] => 1.18522859 [coin] => BTC [value_fiat] => 3625.69722281 [value_btc] => 1.18522859 [price_fiat] => 3059.07000000 [price_btc] => 1.00000000 [change1h] => 0.29 [change24h] => -0.61 [change7d] => -0.34 [change30d] => -14.60 ) [ETC] => Array ( [amount] => 36.74842241 [coin] => ETC [value_fiat] => 317.62015663 [value_btc] => 0.10382899 [price_fiat] => 8.64309638 [price_btc] => 0.00282540 [change1h] => 0.59 [change24h] => 0.64 [change7d] => -1.81 [change30d] => -33.14 ) ... ) [summary] => Array ( [value_fiat] => 120114.45 [value_btc] => 39.65021254 [profit_fiat] => 107132.08 [profit_btc] => 35.21109847 ) )
Field Description:
| Field | Description |
|---|---|
| account_currency | Your account currency |
| details | |
| amount | The coin or currency amount |
| coin | The coin or currency |
| value_fiat | The current value in your account currency (amount * price_fiat) |
| value_btc | The current value in BTC (amount * price_btc) |
| price_fiat | The current price in your account currency |
| price_btc | The current price in BTC |
| change 1h - 30d | The price trend for 1h, 24h, 7d and 30d |
| summary | |
| value_fiat | Your total account value in your account currency |
| value_btc | Your total account value in BTC |
| profit_fiat | Your account profit (value - spendings) in your account currency |
| profit_btc | Your account profit (value - spendings) in BTC |
getHistoricalSummary
Returns all historical values for all your coins, currencies, commodities, and the total account value. Similar to the Daily Balance or the Trade Statistics.Example:
$result = cointracking('getHistoricalSummary', array('btc' => '0', 'start' => 1200000000, 'end' => 1900000000));
Parameter:
| Call | Required | Default | Description |
|---|---|---|---|
| btc | optional | 0 | Set to '0' or leave blank to show all values in your fiat currency. Set to '1' to show them in BTC. |
| start | optional | no start date | UNIX timestamp as trade start date |
| end | optional | no end date | UNIX timestamp as trade end date |
Response:
Array
(
[success] => 1
[method] => getHistoricalSummary
[display_currency] => USD
[historical] => Array
(
[Coins] => Array
(
[1506211200] => 300.15
[1506269572] => 305.95
...
)
[Currencies] => Array
(
[1506211200] => 109.50
[1506269572] => 107.25
...
)
[Commodities] => Array
(
[1506211200] => 0.00
[1506269572] => 0.00
...
)
[Total] => Array
(
[1506211200] => 409.65
[1506269572] => 413.20
...
)
)
)
Field Description:
| Field | Description |
|---|---|
| display_currency | Results either in BTC or your account currency (default) |
| Coins | The sum of all your digital currencies (BTC, LTC, ETH...) |
| Currencies | The sum of all your FIAT currencies (USD, EUR, JPY...) |
| Commodities | The sum of all your commodities (XAU, XAG, XPD...) |
| Total | The sum of all 3 groups (Coins + Currencies + Commodites) for this timestamp (key) |
| key | The key is the UNIX timestamp |
getHistoricalCurrency
Returns all historical amounts and values for a specific currency/coin or for all currencies/coins. Similar to the Daily Balance or the Trade Statistics.Example:
$result = cointracking('getHistoricalCurrency', array('currency' => 'ETH', 'start' => 1200000000, 'end' => 1900000000));
Parameter:
| Call | Required | Default | Description |
|---|---|---|---|
| currency | optional | all currencies | Leave blank to load historical values for all currencies/coins. Enter a currency/coin (e.g. ETH) to load only the values for this currency |
| start | optional | no start date | UNIX timestamp as trade start date |
| end | optional | no end date | UNIX timestamp as trade end date |
Response:
Array
(
[success] => 1
[method] => getHistoricalCurrency
[account_currency] => USD
[historical] => Array
(
[BTC] => Array
(
[1497650400] => Array
(
[amount] => 0.50000000
[fiat] => 1500.00
[btc] => 0.50000000
)
[1497736800] => Array
(
[amount] => 0.50000000
[fiat] => 1520.12
[btc] => 0.50000000
)
...
)
[ETH] => Array
(
[1497650400] => Array
(
[amount] => 10.00000000
[fiat] => 3200.12
[btc] => 0.98000000
)
[1497736800] => Array
(
[amount] => 12.00000000
[fiat] => 3812.34
[btc] => 1.12345678
)
...
)
...
)
)
Field Description:
| Field | Description |
|---|---|
| account_currency | The fiat currency of your account |
| key | The key is the UNIX timestamp |
| amount | The amount of this currency at the given timestamp (key) |
| fiat | The fiat value (account_currency) of this currency at the given timestamp (key) |
| btc | The BTC value of this currency at the given timestamp (key) |
getGroupedBalance
Returns the current balance grouped by exchange, trade-group or transaction type. Similar to the Balance by Exchange.Example:
$result = cointracking('getGroupedBalance', array('group' => 'exchange', 'exclude_dep_with' => '1', 'type' => 'Trade'));
Parameter:
| Call | Required | Default | Description |
|---|---|---|---|
| group | optional | exchange | Group current balanace by 'exchange', 'group' or 'type' |
| exclude_dep_with | optional | 0 (deposits and withdrawals included) | Set to '1' to exclude all deposits and withdrawals (recommended in most cases) |
| values_at_tx | optional | 0 (values at transaction are disabled) | Set to '1' to show the values at the time of the transaction in the account currency and in BTC |
| type | optional | all types | Leave blank to calculate all transaction types. Set a type to calculate the balance for a specific type.
Possible types: Trade | Deposit | Withdrawal | Income | Mining | Gift/Tip(In) | Spend | Donation | Gift(Out) | Stolen | Lost | Airdrop | Staking | Masternode | Minting | Dividends Income | Lending Income | Interest Income | Reward / Bonus | Mining (commercial) | Margin Profit | Derivatives / Futures Profit | LP Rewards | Other Income | Income (non taxable) | Other Income (non taxable) | Airdrop (non taxable) | Receive Loan | Receive Collateral | Remove Liquidity | Receive LP Token | Margin Loss | Margin Fee | Borrowing Fee | Settlement Fee | Derivatives / Futures Loss | Other Fee | Provide Liquidity | Return LP Token | Other Expense | Expense (non taxable) | Send Collateral | Repay Loan | Liquidation | Margin Trade | Derivatives / Futures Trade | Swap (non taxable) | |
Response:
Array
(
[success] => 1
[method] => getGroupedBalance
[account_currency] => USD
[details] => Array
(
[Kraken Balance] => Array
(
[BTC] => Array
(
[amount] => 24.63757943
[fiat] => 82725.01
[btc] => 24.63757943
)
[LTC] => Array
(
[amount] => 499.95900000
[fiat] => 22152.36
[btc] => 6.65803900
)
[USD] => Array
(
[amount] => 40994.00000000
[fiat] => 40994.00
[btc] => 10.31441404
)
...
[TOTAL_SUMMARY] => Array
(
[fiat] => 141288.18
[btc] => 42.51419671
)
)
[Bittrex Balance] => Array
(
...
)
[Coinbase Balance] => Array
(
...
)
)
)
Field Description:
| Field | Description |
|---|---|
| account_currency | The fiat currency of your account |
| amount | The total amount of this currency |
| fiat | The fiat value (account_currency) of this currency |
| btc | The BTC value of this currency |
| value_at_tx_in_fiat | The fiat sum of this currency at the time of the transaction (optional - disabled by default) |
| value_at_tx_in_btc | The BTC sum of this currency at the time of the transaction (optional - disabled by default) |
| TOTAL_SUMMARY | The total fiat and btc value for this exchange, group or transaction type |
getGains
Returns your current realized and unrealized gains data. Similar to the Realized and Unrealized Gains.Example:
$result = cointracking('getGains', array('tax_method' => 'FIFO', 'price' => 'best', 'btc' => '0'));
Parameter:
| Call | Required | Default | Description |
|---|---|---|---|
| tax_method | optional | your account setting | Possible methods: FIFO, LIFO, HIFO, LOFO, HPFO, LPFO, HAFO, LAFO, OPTI |
| price | optional | your account setting | Possible values: best, transaction, counterpart |
| btc | optional | 0 | Set to '0' or leave blank to show all values in your fiat currency. Set to '1' to show them in BTC. |
Response:
Array
(
[success] => 1
[method] => getGains
[display_currency] => EUR
[gains] => Array
(
[BTC] => Array
(
[coin] => BTC
[amount] => 1.78089028
[cost_per_unit] => 2291.86172749
[current_price] => 3308.66
[change_percent] => 44.37
[cost] => 4081.55
[current_value] => 5892.36
[unrealized] => 1810.81
[realized] => 173072.97
)
[ETH] => Array
(
[coin] => ETH
[amount] => 215.44959198
[cost_per_unit] => 97.38549511
[current_price] => 3308.66
[change_percent] => 3297.49
[cost] => 20981.67
[current_value] => 712849.45
[unrealized] => 691867.78
[realized] => 178638.97
)
...
)
)
Field Description:
| Field | Description |
|---|---|
| display_currency | Results either in BTC or your account currency (default) |
| coin | The coin or currency |
| amount | The total amount of this currency |
| cost_per_unit | The calculated cost per unit |
| current_price | The current market price |
| change_percent | The difference between the cost and the current value |
| cost | The total cost (cost_per_unit * amount) |
| current_value | The current value (current_price * amount) |
| unrealized | The unrealized gain |
| realized | The realized gain |
getLedger
Returns all your CoinTracking transactions as Ledger incl. balances and values before and after the transaction as well as the price & tx growth . Similar to the Double-Entry / Ledger List.Examples:
Example without optional parameters:$result = cointracking('getLedger');
Example with all optional parameters:
$result = cointracking('getLedger', array('show_advanced' => '1', 'limit' => '100', 'start' => 1200000000, 'end' => 1450000000));
Parameter:
| Call | Required | Default | Description |
|---|---|---|---|
| limit | optional | all | Number of trades |
| start | optional | no start date | UNIX timestamp as trade start date |
| end | optional | no end date | UNIX timestamp as trade end date |
| show_advanced | optional | 0 (disabled) | Set to "1" to calculate balances and values before and after each transaction as well as price and tx growth in percent |
Response:
Array
(
[success] => 1
[method] => getLedger
[account_currency] => USD
[62560] => Array
(
[ledger_count] => 1
[id] => 62560
[sub_id] => 0
[type] => Airdrop
[amount] => 0.20000000
[currency] => LTC
[value_at_transaction] => 5.00
[price] => 25.00000000
[exchange] => Electrum
[trade_group] => Personal Wallet
[trade_id] => 84b41cc21abf12234589012443de098
[comment] =>
[imported_from] => electrum
[balance_before] => 0.00000000
[value_before] => 0.00
[balance_after] => 0.20000000
[value_after] => 5.00
[price_growth] =>
[transaction_growth] =>
[imported_time] => 1611415059
[time] => 1496513959
)
[62561] => Array
(
[ledger_count] => 2
[id] => 62561
[sub_id] => 0
[type] => Gift(Out)
[amount] => 0.18000000
[currency] => LTC
[value_at_transaction] => 4.18
[price] => 24.50912442
[exchange] => Electrum
[trade_group] =>
[trade_id] => 95a658c2431b2c31a2ff44756412f121ac21
[comment] =>
[imported_from] => electrum
[balance_before] => 0.20000000
[value_before] => 5.25
[balance_after] => 0.02000000
[value_after] => 0.22
[price_growth] => 5.00
[transaction_growth] => -90.00
[imported_time] => 1611415059
[time] => 1496514179
)
[62561F] => Array
(
[ledger_count] => 2
[id] => 62561
[sub_id] => 3
[type] => Fee
[amount] => 0.00100000
[currency] => LTC
[value_at_transaction] =>
[price] =>
[exchange] => Electrum
[trade_group] =>
[trade_id] => 95a658c2431b2c31a2ff44756412f121ac21_fee
[comment] =>
[imported_from] => electrum
[balance_before] =>
[value_before] =>
[balance_after] =>
[value_after] =>
[price_growth] =>
[transaction_growth] =>
[imported_time] => 1611415059
[time] => 1496514179
)
...
)
Field Description:
| Field | Description |
|---|---|
| ledger_count | A sequential number of the transaction |
| id | The unique CoinTracking transaction id |
| sub_id | Used only for trades that are displayed in 2 rows (or if a fee is included, in 3 rows) |
| type | Possible types: Trade | Deposit | Withdrawal | Income | Mining | Gift/Tip(In) | Spend | Donation | Gift(Out) | Stolen | Lost | Airdrop | Staking | Masternode | Minting | Dividends Income | Lending Income | Interest Income | Reward / Bonus | Mining (commercial) | Margin Profit | Derivatives / Futures Profit | LP Rewards | Other Income | Income (non taxable) | Other Income (non taxable) | Airdrop (non taxable) | Receive Loan | Receive Collateral | Remove Liquidity | Receive LP Token | Margin Loss | Margin Fee | Borrowing Fee | Settlement Fee | Derivatives / Futures Loss | Other Fee | Provide Liquidity | Return LP Token | Other Expense | Expense (non taxable) | Send Collateral | Repay Loan | Liquidation | Margin Trade | Derivatives / Futures Trade | Swap (non taxable) | |
| amount | The amount of the transaction |
| currency | The currency of the transaction |
| value_at_transaction | The value of the transaction at the time of the transaction in the account currency |
| price | The price for 1 unit of the currency |
| exchange | The exchange set on CoinTracking |
| trade_group | The trade group set on CoinTracking |
| trade_id | The tx-id of the transaction provided by the exchange. Only for imported transactions. |
| comment | The comment set on CoinTracking |
| imported_from | The name of the exchange, this transaction was imported from. (e.g. kraken). API imports start with 'job' (e.g. job_kraken). Only for imported transactions. |
| balance_before | The 'Balance before' represents the amount of a currency before the transaction. |
| value_before | The 'Value before' will convert the amounts into your account currency at the time of the transaction. |
| balance_after | The 'Balance after' represents the amount of a currency after the transaction. |
| value_after | The 'Value after' will convert the amounts into your account currency at the time of the transaction. |
| price_growth | The 'Price growth' is defined as the percentage change since the last transaction, or in other words, 'Value before' of the current transaction in relation to 'Value after' of the previous transaction. |
| transaction_growth | The 'Transaction growth' is defined as the percentage change in the current transaction, or in other words, the ratio between 'Value after' and 'Value before'. If the 'Value before' is 0, no value will be calculated. |
| imported_time | The UNIX timestamp this transaction was added to CoinTracking |
| time | The UNIX timestamp of the transaction |
Made with ❤ in Munich · Copyright © 2012-2025, CoinTracking