A PHP library to get cryptocurrency price from various exchange APIs.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.coveralls.yml
.gitignore
.travis.yml
LICENSE
README.md
composer.json
composer.lock
phpunit.xml

README.md

Cyger

Build Status Coverage Status

Cyger is a PHP library to get cryptocurrency price from various exchange APIs.

  • It is possible to resolve different specifications for each api as soon as possible.
  • It can get last price, bid price, ask price and volume.
  • Supporting exchanges

Install

$ composer require kuromoka/cyger

Requirement

Usage

The first example code below shows getting last price of BTC_ETH from Poloniex.

require 'vendor/autoload.php';

use Cyger\Client;

$client = new Client();
$result = $client->setExchange('Poloniex')->setPair('BTC_ETH')->getLastPrice();
echo $result['Poloniex']['BTC_ETH'];    // 0.04549105

The secound example code below shows getting last price of BTC_ETH from all supporting exchanges. It is possible not to set exchange, but it is necessary to set pairs.
if exchanges don't support pairs, returning NULL.

$client = new Client();
$result = $client->setPair('BTC_ETH')->getLastPrice();
echo $result['Poloniex']['BTC_ETH'];     // 0.04549105
echo $result['Bittrex']['BTC_ETH'];      // 0.04577
echo $result['Coincheck']['BTC_ETH'];    // NULL (Coincheck doesn't support BTC_ETH pair.)

Also, you can use various style of exchange name and pair name. You don't have to think each api specifications basically.
The example below shows OK and NG name.

$client->setExchange('poloniex')    // OK
$client->setExchange('POLONIEX')    // OK
$client->setExchange('POLONIE')     // NG

$client->setPair('BTC_ETH');        // OK
$client->setPair('btc-eth');        // OK
$client->setPair('ETH/BTC');        // OK
$client->setPair('BTC:ETH');        // NG

Key name of results array is setting from your style.

$client = new Client();
$result = $client->setExchange('POLONIEX')->setPair('ETH/BTC')->getLastPrice();
echo $result['POLONIEX']['ETH/BTC'];    // 0.04549105

When you want to get other than last price, please replace getLastPrice() to methods below.

  • getBidPrice()
  • getAskPrice()
  • getVolume()

Supporting exchanges

I am going to add more exchanges in the future.

Author