elliotchance/independentreserve

API for independentreserve.com.

v1.1.9 2022-04-08 12:06 UTC

This package is not auto-updated.

Last update: 2024-04-09 14:22:28 UTC


README

Build Status Scrutinizer Code Quality Coverage Status Latest Stable Version Total Downloads License

PHP API for independentreserve.com

Installation

Using composer:

composer require elliotchance/independentreserve

Public APIs

All public APIs are supported, and do not need authentication:

use IndependentReserve\PublicClient;
use IndependentReserve\Currency;

$client = new PublicClient();
$marketSummary = $client->getMarketSummary(Currency::XBT, Currency::USD);
printf('%s: %s USD',
    $marketSummary->getCreatedTimestamp()->format('r'),
    $marketSummary->getDayAveragePrice()
);

// Fri, 26 Dec 2014 05:03:34 +0000: 323.21 USD

View all of the public APIs at https://www.independentreserve.com/API#public

Private APIs

All private APIs are available. You must use your API key and secret to access them:

use IndependentReserve\PrivateClient;
use IndependentReserve\Currency;

$client = new PrivateClient('api_key', 'api_secret');
$address = $client->getBitcoinDepositAddress();
echo $address->getBitcoinAddress();

// 12a7FbBzSGvJd36wNesAxAksLXMWm4oLUJ

View all of the private APIs at https://www.independentreserve.com/API#private

All of the public API methods are accessible through the PrivateClient as well:

$client = new PrivateClient('api_key', 'api_secret');
$marketSummary = $client->getMarketSummary(Currency::XBT, Currency::USD);

Paging Results

Some of the APIs return their results as paged calls (25 items at a time), you do not need to worry about this because these APIs use elliotchance/iterator which will handle all the paged requests for you on demand, you may use all results as an active array:

$client = new PrivateClient('api_key', 'api_secret');
$openOrders = $client->getOpenOrders();

echo count($openOrders);
// 452

var_dump($openOrders[135]); // 136th order

foreach ($openOrders as $order) {
    // ...
}