Coinbase API getBalance ignoring ETC currency

288 views Asked by At

The PHP uses the Coinbase API to get the current balance and list what currencies the account has money in. It has been used for a few weeks now, but since swapping one currency into ETC (Ethereum Classic), the balance ignores this currency. It works for all other currencies I have tried, so what is special about ETC that Coinbase is not returing anything via the API. The coinbase website portfolio does report the ETC balance correctly, so it's definitely a API issue.

<?php

include 'cfg.php'; // Contains API key
require_once ('vendor/autoload.php'); // Loads the API libraries

use Coinbase\Wallet\Client as Client;
use Coinbase\Wallet\Configuration as Configuration;
use Coinbase\Wallet\Enum\Param;
use Coinbase\Wallet\Resource\Transaction;

$configuration = Configuration::apiKey($cbase_API_Key, $cbase_API_Secret);
$client = Client::create($configuration);
$stime = $client->getTime();

echo '<h2> Server Time ' . $stime['iso'] . '</h2>';

$balance = 0.00;    
    
$accounts = $client->getAccounts(); // Get the account(s)

echo '<table>';

foreach ( $accounts as $acct )
{
   $amt =  $acct->getBalance()->getAmount() ;
   
   echo '<tr>';
   echo '<td>' . $acct->getCurrency() . '</td>';
   echo '<td>' . $acct->getName() . '</td>';
   echo '<td>' . $acct->getBalance()->getAmount() . '</td>';
   echo '<td>' . $acct->getNativeBalance()->getAmount() . '</td>';
   echo '</tr>';
   $balance = $balance + $acct->getNativeBalance()->getAmount();
}

echo '<table>';
echo '<h2> Total Balance: ' . $balance . '</h2>';

?>
1

There are 1 answers

0
TenG On BEST ANSWER

The issue came down to pagination:

The fix therefore was to set the pagination limit to 100 (max allowed).

The default is 24, hence why the returned list was incomplete.

$accounts = $client->getAccounts(['limit' => 100]);