2017 © Pedro Peláez
 

library kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

image

reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  • Wednesday, February 14, 2018
  • by Reilag
  • Repository
  • 3 Watchers
  • 3 Stars
  • 158 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 10 Versions
  • 1 % Grown

The README.md

<< Kuna API, (*1)

Kuna Exchange PHP API

GitHub issues GitHub stars, (*2)

PHP Version Guzzle Version Packagist, (*3)

WARNING! This is not a stable version!

PHP 5.6+ is required., (*4)

If you do not want to use Composer or use version less than PHP 5.6 , you can use Simple API PHP Library, (*5)

1. Install

You can add Kuna PHP API as a dependency using the composer.phar CLI:, (*6)

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add dependency
php composer.phar require reilag/kuna-api-php:^1.0.1

Alternatively, you can specify Kuna PHP API as a dependency in your project's existing composer.json file:, (*7)

{
   "require": {
      "reilag/kuna-api-php": "^1.0.1"
   }
}

After installing, you need to require Composer's autoloader:, (*8)

require 'vendor/autoload.php';

You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at getcomposer.org., (*9)

2. Public methods

2.1. Timestamp

use Kuna\Client;

$kuna = new Client();
$timestamp = $kuna->publicMethod()->timestamp(); //1466486485

2.2. Tickers

use Kuna\Client;
use Kuna\Constant;

$kuna = new Client();
$tickers = $kuna->publicMethod()->tickers(Constant::MARKET_BTCUAH);

print_r($tickers);

Result:, (*10)

{
    "at":1466486520,
    "ticker":{
        "buy": 18001.0,
        "sell": 18939.0,
        "low": 18000.0,
        "high": 18999.0,
        "last": 18000.0,
        "vol": 1.6011
    }
}

2.3. Order book

use Kuna\Client;
use Kuna\Constant;

$kuna = new Client();
$orderBook = $kuna->publicMethod()->orderBook(Constant::MARKET_BTCUAH);

print_r($orderBook);

Result:, (*11)

{
    "asks": [
        {
            "id": 1182,
            "side": "sell",
            "ord_type": "limit",
            "price": 18939.0,
            "avg_price": 0.0,
            "state": "wait",
            "market": "btcuah",
            "created_at": "2016-06-21T05:09:02Z",
            "volume": 0.0326,
            "remaining_volume": 0.0326,
            "executed_volume": 0.0,
            "trades_count":0
        }
    ],

    "bids": [
        {
            "id": 1183,
            "side": "buy",
            "ord_type": "limit",
            "price": 18001.0,
            "avg_price": 0.0,
            "state": "wait",
            "market": "btcuah",
            "created_at": "2016-06-21T05:09:03Z",
            "volume": 0.0005,
            "remaining_volume": 0.0005,
            "executed_volume": 0.0,
            "trades_count": 0
        }
    ]
}

2.4. Trades

use Kuna\Client;
use Kuna\Constant;

$kuna = new Client();
$trades = $kuna->publicMethod()->trades(Constant::MARKET_BTCUAH);

print_r($trades);

Result:, (*12)

[
    {
        "id": 338,
        "price": 18000.0,
        "volume": 0.369,
        "funds": 6642.0,
        "market": "btcuah",
        "created_at": "2016-06-21T04:44:58Z",
        "side": null
    }
]

3. Private methods

use Kuna\Client;

$kuna = new Client([
    "publicKey" => "Your public key",
    "secretKey" => "Your secret key",
]);

$privateMethod = $kuna->privateMethod();

3.1. My profile

$me = $privateMethod->me();
print_r($me);

Result:, (*13)

{
    "email": "your_email@email.com",
    "activated": true,
    "accounts": [
        {
            "currency": "btc",
            "balance": 12.4123,
            "locked": 0.42
        },
        {
            "currency": "uah",
            "balance": 233519.52,
            "locked": 4981.315
        }
    ]
}

3.2. Create new Order

$orderMethod = $privateMethod->order();

/**
 * $price
 * $volume
 * $side
 * $market
 */
$newOrder = $orderMethod->create(18000, 0.1, Constant::SIDE_BUY, Constant::MARKET_BTCUAH);

print_r($newOrder);

Result:, (*14)

{
    "id": 3091,
    "side": "buy",
    "ord_type": "market",
    "price": 18000,
    "avg_price": 0,
    "state": "wait",
    "market": "btcuah",
    "created_at": "2016-06-21T05:09:02Z",
    "volume": 0.1,
    "remaining_volume": 0.1,
    "executed_volume": 0,
    "trades_count": 0
}

3.3. Delete order

$orderMethod = $privateMethod->order();

/**
 * @property int $orderId
 */
$deletedOrder = $orderMethod->delete(3091);

print_r($deletedOrder);

Result:, (*15)

{
    "id": 3091,
    "side": "buy",
    "ord_type": "market",
    "price": 18000,
    "avg_price": 18000,
    "state": "wait",
    "market": "btcuah",
    "created_at": "2016-06-21T05:09:02Z",
    "volume": 0.1,
    "remaining_volume": 0.05,
    "executed_volume": 0.05,
    "trades_count": 3
}

3.4. Active order list

$orderMethod = $privateMethod->order();

$orderList = $orderMethod->orderList(Constant::MARKET_BTCUAH);

print_r($orderList);

Result:, (*16)

[
    {
        "id": 3994,
        "side": "buy",
        "ord_type": "market",
        "price": 29000,
        "avg_price": 40000,
        "state": "wait",
        "market": "btcuah",
        "created_at": "2016-06-21T05:09:02Z",
        "volume": 0.8,
        "remaining_volume": 0.109,
        "executed_volume": 0.691,
        "trades_count": 8
    }, {
        "id": 40,
        "side": "sell",
        "ord_type": "market",
        "price": 28000,
        "avg_price": 29910,
        "state": "wait",
        "market": "btcuah",
        "created_at": "2016-06-21T05:09:02Z",
        "volume": 0.5,
        "remaining_volume": 0.3,
        "executed_volume": 0.2,
        "trades_count": 10
    }
]

The Versions

14/02 2018

dev-master

9999999-dev https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

by Tymchyk Maksym

14/02 2018

2.1.0

2.1.0.0 https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

24/09 2017

2.0.2

2.0.2.0 https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

24/09 2017

2.0.1

2.0.1.0 https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

24/09 2017

2.0.0

2.0.0.0 https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

01/07 2016

v1.0.1

1.0.1.0 https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

by Tymchyk Maksym

28/06 2016

dev-simple-library

dev-simple-library https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

by Tymchyk Maksym

25/06 2016

v1.0.0

1.0.0.0 https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

by Tymchyk Maksym

24/06 2016

v0.3.6-rc.2

0.3.6.0-RC2 https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

by Tymchyk Maksym

22/06 2016

v0.3.5-rc.1

0.3.5.0-RC1 https://github.com/reilag/kuna-api-php

Kuna Exchange PHP API - https://kuna.io/documents/api

  Sources   Download

MIT

The Requires

 

by Tymchyk Maksym