2017 © Pedro Peláez
 

library kuna-api

Kuna.io REST API php client

image

madmis/kuna-api

Kuna.io REST API php client

  • Monday, January 22, 2018
  • by madmis
  • Repository
  • 2 Watchers
  • 4 Stars
  • 83 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 15 % Grown

The README.md

Kuna.io REST API PHP Client

SensioLabsInsight ![Build Status][testing-image] [Coverage Status][coverage-link] Latest Stable Version Total Downloads License, (*1)

Kuna.io provides REST APIs that you can use to interact with platform programmatically., (*2)

This API client will help you interact with Kuna by REST API., (*3)

Table Of Contents

License

MIT License, (*4)

Kuna REST API Reference

https://kuna.io/documents/api, (*5)

Contributing

To create new endpoint - create issue or create pull request, (*6)

Install

composer require cryptopupua/kuna-api 1.1.*

Usage

require __DIR__.'/vendor/autoload.php';

use cryptopupua\KunaApi\Api;
use cryptopupua\KunaApi\Exception\IncorrectResponseException;
use cryptopupua\KunaApi\KunaApi;
use cryptopupua\KunaApi\Model\History;
use cryptopupua\KunaApi\Model\MyAccount;
use cryptopupua\KunaApi\Model\Order;
use cryptopupua\KunaApi\Model\Ticker;


$api = new KunaApi(
    'https://kuna.io',
    'public key',
    'secret key'
);
$timestamp = $api->shared()->timestamp();

Mapping

Each endpoint response (exclude: timestamp) can be received as array or as object., (*7)

To use mapping response to object set parameter $mapping to true., (*8)

$issue = $api->signed()->activeOrders(Http::PAIR_ETHUAH, true);

// Result
[
    {
    class madmis\KunaApi\Model\Order {
        protected $id => 10003
        protected $side => "sell"
        protected $ordType => "limit"
        protected $price => 10000
        protected $avgPrice => 0
        protected $state => "wait"
        protected $market => "ethuah"
        protected $createdAt => DateTime
        protected $volume => 0.01
        protected $volume => 0.01
        protected $remainingVolume => 0.01
        protected $executedVolume => 0
        protected $tradesCount => 0
      }

    },
    ...
] 

Error handling

Each client request errors wrapped to custom exception madmis\ExchangeApi\Exception\ClientException, (*9)

class madmis\ExchangeApi\Exception\ClientException {
  private $request => class GuzzleHttp\Psr7\Request
  private $response => NULL
  protected $message => "cURL error 7: Failed to connect to 127.0.0.1 port 8080: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)"
  ...
}

ClientException contains original request object and response object if response available, (*10)

class madmis\ExchangeApi\Exception\ClientException {
  private $request => class GuzzleHttp\Psr7\Request 
  private $response => class GuzzleHttp\Psr7\Response {
    private $reasonPhrase => "Unauthorized"
    private $statusCode => 401
    ...
  }
  protected $message => "Client error: 401"
  ...  
}

So, to handle errors use try/catch, (*11)

try {
    $api->signed()->activeOrders(Http::PAIR_ETHUAH, true);
} catch (madmis\ExchangeApi\Exception\ClientException $ex) {
    // any actions (log error, send email, ...) 
}

Running the tests

To run the tests, you'll need to install phpunit. Easiest way to do this is through composer., (*12)

composer install

Running Unit tests

php vendor/bin/phpunit -c phpunit.xml.dist

Library api

Shared resources (Public Kuna API)

Private resources (Private Kuna API)

The Versions

22/01 2018

dev-master

9999999-dev

Kuna.io REST API php client

  Sources   Download

MIT

The Requires

 

The Development Requires

api rest kuna.io kuna

22/01 2018

1.1.3

1.1.3.0

Kuna.io REST API php client

  Sources   Download

MIT

The Requires

 

The Development Requires

api rest kuna.io kuna

11/08 2017

1.1.2

1.1.2.0

Kuna.io REST API php client

  Sources   Download

MIT

The Requires

 

The Development Requires

api rest kuna.io kuna

10/08 2017

1.1.1

1.1.1.0

Kuna.io REST API php client

  Sources   Download

MIT

The Requires

 

The Development Requires

api rest kuna.io kuna

27/07 2017

1.1.0

1.1.0.0

Kuna.io REST API php client

  Sources   Download

MIT

The Requires

 

The Development Requires

api rest kuna.io kuna

26/07 2017
24/07 2017
21/07 2017
21/07 2017
21/07 2017
21/07 2017