revisiting the api on mph:
is there an api endpoint for global balance data (like the page with all balances, but as api)?
also last time i asked there was no global api for all algos (workers etc), has this changed?
i would like to list all workers and their coin with balances in a table
In case anyone is interested, as there is no total balance for pool yet, here is the php code to get your absolute total balance in BTC:
<?php
$id = "[enter your user id here]";
$key = "[enter your api key here]";
$balance = 0;
foreach (json_decode(@file_get_contents("http://miningpoolhub.com/index.php?page=api&action=getminingandprofitsstatistics"))->{'return'} as $coin) {
$url = "http://" . $coin->{'coin_name'} . ".miningpoolhub.com/index.php?page=api&action=getdashboarddata&api_key=" . $key . "&id=" . $id;
$json = @file_get_contents($url);
$data = json_decode($json)->{'getdashboarddata'}->{'data'};
$balance += (((float)$data->{'balance'}->{'confirmed'} + (float)$data->{'balance'}->{'unconfirmed'} + (float)$data->{'balance_for_auto_exchange'}->{'confirmed'} + (float)$data->{'balance_for_auto_exchange'}->{'unconfirmed'} + (float)$data->{'balance_on_exchange'} + (float)$data->{'personal'}->{'estimates'}->{'payout'})) * (float)$coin->{'highest_buy_price'};
sleep(0.5);
}
header('content-type: application/json');
echo json_encode($balance);
?>
Here it is for PowerShell (you can run this on your PC by simply saving this text in a '.PS1' file i.e. 'balance.ps1'):
$id = "[enter your user id here]"
$key = "[enter your api key here]"
$balance = 0
foreach ($coin in (Invoke-WebRequest -Uri "http://miningpoolhub.com/index.php?page=api&action=getminingandprofitsstatistics" | ConvertFrom-Json).return) {
$url = "http://" + $coin.coin_name + ".miningpoolhub.com/index.php?page=api&action=getdashboarddata&api_key=" + $key + "&id=" + $id
$json = Invoke-WebRequest -Uri $url
$data = ($json | ConvertFrom-Json).getdashboarddata.data
$balance += (([float]$data.balance.confirmed + [float]$data.balance.unconfirmed + [float]$data.balance_for_auto_exchange.confirmed + [float]$data.balance_for_auto_exchange.unconfirmed + [float]$data.balance_on_exchange + [float]$data.personal.estimates.payout)) * [float]$coin.highest_buy_price
sleep(0.5);
}
echo ($balance | ConvertTo-Json)
thanks for this, but this does cycle through all coins and makes <coinAmount> +1 http calls, right? even (<coinAmount>*2) +1 if also querying workers (afaik they are not included in the dashboarddata, would need to check)
i have already thought about just implementing it that way, but i try to not spam the mph server(s) with that many requests every 10-30sec
edit: i have implemented it like that for now, worker stats are a separate call too, very ugly solution

some small notes on what can be added additionally:
- worker stats: time connected (12 for 12 min, 120 for 2h etc)
- dashboard stats: currency symbol (BTC,XMR etc)
Please don't use it frequently.
The reason why I didn't open this kind of api is database structure needs some changes for performance.
Pool didn't have hub, switching port stuffs and didn't need these optimizations at start. But I need to tweak some now.