Wallet Journal walking

05 Jul 2011

An often raised issue is the journal walking, like here in the Eve forums, when fetching journal entries from the API. Since the count of entries per page is limited, you have to fetch the second, third page, ..., to get all your wallet movements.

Here is a simple PHP example that uses Pheal to do the job:


// Load Pheal
require_once 'pheal/Pheal.php';
spl_autoload_register('Pheal::classload');
$pheal = new Pheal($userId, $apiKey, 'char');

// Parameters for the request
$parameters = array(
    'characterID'   => $characterId,
    'rowCount'  => 200
);

// Load the first page
$firstPage =
    $pheal
        ->WalletJournal($parameters)
        ->transactions->toArray();

// Eve uses 64-bit integers now, so let us start
// with the highest possible number
$lowestId = 9223372036854775807;
foreach ($firstPage as $entry) {

    // DO NOT use (int) or intval() if you are not
    // on an 64-bit machine with a 64-bit PHP!!
    $lowestId = min($lowestId, $entry['refID']);
}

// Now set the lowest ID we found as
// fromID parameter
$parameters['fromID'] = $lowestId;

// Now we can fetch the second page
$secondPage =
    $pheal
        ->WalletJournal($parameters)
        ->transactions->toArray();