PHPackages                             farzai/bitkub - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. farzai/bitkub

ActiveLibrary[API Development](/categories/api)

farzai/bitkub
=============

The bitkub api wrapper

1.1.0(2y ago)118[4 PRs](https://github.com/farzai/bitkub-php/pulls)MITPHPPHP ^8.1CI passing

Since Dec 11Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/farzai/bitkub-php)[ Packagist](https://packagist.org/packages/farzai/bitkub)[ Docs](https://github.com/farzai/bitkub-php)[ GitHub Sponsors](https://github.com/parsilver)[ RSS](/packages/farzai-bitkub/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (13)Used By (0)

Bitkub Wrapper - PHP (Unofficial)
=================================

[](#bitkub-wrapper---php-unofficial)

[![Latest Version on Packagist](https://camo.githubusercontent.com/74773285495254ababa2b3e09597d613eb0671e6e511db1145864e317a9dfcee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6661727a61692f6269746b75622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/farzai/bitkub)[![Tests](https://camo.githubusercontent.com/a67738cf65cfb90a158da120db01d5a875d5c2bcdda3d0d686c6dc3e5f339a76/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6661727a61692f6269746b75622d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/farzai/bitkub-php/actions/workflows/run-tests.yml)[![codecov](https://camo.githubusercontent.com/3627838eb5dd820726266771d04f219fbb3cc224e61cbceb20c9d6e713694c51/68747470733a2f2f636f6465636f762e696f2f67682f6661727a61692f6269746b75622d7068702f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/farzai/bitkub-php)[![Total Downloads](https://camo.githubusercontent.com/cd55f1dbab9ad35d31b63f6deb6460f4e53df4bb5adf9a7343d94b8c7eb43e23/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6661727a61692f6269746b75622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/farzai/bitkub)

Simplify the integration of the Bitkub API into your PHP application. [Bitkub API Documentation](https://github.com/bitkub/bitkub-official-api-docs/blob/master/restful-api.md)

**Requirements:** PHP 8.2+

**Notes**We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with Bitkub, or any of its subsidiaries or its affiliates.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require farzai/bitkub
```

Basic Usage
-----------

[](#basic-usage)

Restful API

```
$bitkub = \Farzai\Bitkub\ClientBuilder::create()
    ->setCredentials('YOUR_API_KEY', 'YOUR_SECRET_KEY')
    ->build();

// Basic usage
$market = $bitkub->market(); // Just call the market endpoint

// Get balances
$response = $market->balances();

// (Optional) You may call the `throw()` method to ensure that the response is successful
$response->throw();

// Get response data
$myBTC = $response->json('result.BTC.available');

echo "My BTC balance: {$myBTC}";
```

WebSocket API

```
$client = \Farzai\Bitkub\ClientBuilder::create()
    ->setCredentials('YOUR_API_KEY', 'YOUR_SECRET_KEY')
    ->build();

$websocket = \Farzai\Bitkub\WebSocketClientBuilder::create()
    ->setClient($client)
    ->build();

$websocket->market()->listen('trade.thb_ada', function (\Farzai\Bitkub\WebSocket\Message $message) {
    // Do something
    echo $message->sym . PHP_EOL;
});

// Or you can use multiple symbols like this
$websocket->market()->listen(['trade.thb_ada', 'trade.thb_btc'], function (\Farzai\Bitkub\WebSocket\Message $message) {
    // Do something
    echo $message->sym . PHP_EOL;
});

$websocket->run();
```

Documentation
-------------

[](#documentation)

- [Bitkub Wrapper - PHP (Unofficial)](#bitkub-wrapper---php-unofficial)
    - [Installation](#installation)
    - [Basic Usage](#basic-usage)
    - [Documentation](#documentation)
        - [Market](#market)
            - [List all available symbols.](#list-all-available-symbols)
            - [Get the ticker for a specific symbol.](#get-the-ticker-for-a-specific-symbol)
            - [List recent trades.](#list-recent-trades)
            - [List open buy orders.](#list-open-buy-orders)
            - [List open sell orders.](#list-open-sell-orders)
            - [List all open orders.](#list-all-open-orders)
            - [Get user available balances](#get-user-available-balances)
            - [Create a buy order.](#create-a-buy-order)
            - [Create a sell order.](#create-a-sell-order)
            - [Cancel an open order.](#cancel-an-open-order)
            - [Get balances info: this includes both available and reserved balances.](#get-balances-info-this-includes-both-available-and-reserved-balances)
            - [List all open orders of the given symbol.](#list-all-open-orders-of-the-given-symbol)
            - [List all orders that have already matched.](#list-all-orders-that-have-already-matched)
            - [Get information regarding the specified order.](#get-information-regarding-the-specified-order)
        - [Crypto](#crypto)
            - [List all crypto addresses.](#list-all-crypto-addresses)
            - [Make a withdrawal to a trusted address.](#make-a-withdrawal-to-a-trusted-address)
            - [Make a withdraw to an internal address.](#make-a-withdraw-to-an-internal-address)
            - [List crypto deposit history.](#list-crypto-deposit-history)
            - [List crypto withdrawal history.](#list-crypto-withdrawal-history)
            - [Generate a new crypto address](#generate-a-new-crypto-address)
        - [System](#system)
            - [Get server status.](#get-server-status)
            - [Get server timestamp.](#get-server-timestamp)
        - [User](#user)
            - [Check trading credit balance.](#check-trading-credit-balance)
            - [Check deposit/withdraw limitations and usage.](#check-depositwithdraw-limitations-and-usage)
        - [WebSocket](#websocket)
            - [Market streams](#market-streams)
            - [Live order book](#live-order-book)
    - [Testing](#testing)
    - [Changelog](#changelog)
    - [Contributing](#contributing)
    - [Security Vulnerabilities](#security-vulnerabilities)
    - [Credits](#credits)
    - [License](#license)

### Market

[](#market)

Call the market endpoint. This will return an instance of `Farzai\Bitkub\Endpoints\MarketEndpoint` class.

```
$market = $bitkub->market();

# Next, We will use this instance for the following examples below.
# ...
```

#### List all available symbols.

[](#list-all-available-symbols)

- GET `/api/market/symbols`

```
$market->symbols();
```

#### Get the ticker for a specific symbol.

[](#get-the-ticker-for-a-specific-symbol)

- GET `/api/market/ticker`

```
$market->ticker(
    // string: The symbol.
    'THB_BTC'
);
```

#### List recent trades.

[](#list-recent-trades)

- GET `/api/market/trades`

```
$market->trades([
    // string: The symbol.
    'sym' => 'THB_BTC',

    // integer: Limit the number of results.
    'lmt' => 10,
]);
```

#### List open buy orders.

[](#list-open-buy-orders)

- GET `/api/market/bids`

```
$market->bids([
    // string: The symbol.
    'sym' => 'THB_BTC',

    // integer: Limit the number of results.
    'lmt' => 10,
]);
```

#### List open sell orders.

[](#list-open-sell-orders)

- GET `/api/market/asks`

```
$market->asks([
    // string: The symbol.
    'sym' => 'THB_BTC',

    // integer: Limit the number of results.
    'lmt' => 10,
]);
```

#### List all open orders.

[](#list-all-open-orders)

- GET `/api/market/books`

```
$market->books([
    // string: The symbol.
    'sym' => 'THB_BTC',

    // integer: Limit the number of results.
    'lmt' => 10,
]);
```

#### Get user available balances

[](#get-user-available-balances)

- POST `/api/v3/market/wallet`

```
$market->wallet();
```

#### Create a buy order.

[](#create-a-buy-order)

- POST `/api/v3/market/place-bid`

```
$market->placeBid([
    // string: The symbol.
    'sym' => 'THB_BTC',

    // float: Amount you want to spend with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok)
    'amt' => 1000,

    // float: Rate you want for the order with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok)
    'rat' => 1000000,

    // string: Order type: limit or market (for market order, please specify rat as 0)
    'typ' => 'limit',

    // string: (Optional) your id for reference
    'client_id' => 'your_id',
]);
```

#### Create a sell order.

[](#create-a-sell-order)

- POST `/api/v3/market/place-ask`

```
$market->placeAsk([
    // string: The symbol.
    'sym' => 'THB_BTC',

    // float: Amount you want to spend with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok)
    'amt' => 1000,

    // float: Rate you want for the order with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok)
    'rat' => 1000000,

    // string: Order type: limit or market (for market order, please specify rat as 0)
    'typ' => 'limit',

    // string: (Optional) your id for reference
    'client_id' => 'your_id',
]);
```

#### Cancel an open order.

[](#cancel-an-open-order)

- POST `/api/v3/market/cancel-order`

```
$market->cancelOrder([
    // string: The symbol.
    'sym' => 'THB_BTC',

    // integer: The order ID.
    'id' => 123456,

    // string: The side of the order.
    'sd' => 'buy',

    // string: The hash of the order.
    'hash' => 'your_hash',
]);
```

#### Get balances info: this includes both available and reserved balances.

[](#get-balances-info-this-includes-both-available-and-reserved-balances)

- POST `/api/v3/market/balances`

```
$market->balances();
```

#### List all open orders of the given symbol.

[](#list-all-open-orders-of-the-given-symbol)

- GET `/api/v3/market/my-open-orders`

```
$market->openOrders(
    // string: The symbol.
    'THB_BTC'
);
```

#### List all orders that have already matched.

[](#list-all-orders-that-have-already-matched)

- GET `/api/v3/market/my-order-history`

```
$market->myOrderHistory([
    // string: The symbol.
    'sym' => 'THB_BTC',

    // integer: The page number.
    'p' => 1,

    // integer: Limit the number of results.
    'lmt' => 10,

    // integer: The start timestamp.
    'start' => 1614556800,

    // integer: The end timestamp.
    'end' => 1614643199,
]);
```

#### Get information regarding the specified order.

[](#get-information-regarding-the-specified-order)

- GET `/api/v3/market/order-info`

```
$market->myOrderInfo([
    // string: The symbol.
    'sym' => 'THB_BTC',

    // integer: The order ID.
    'id' => 123456,

    // string: The side of the order.
    'sd' => 'buy',

    // string: The hash of the order.
    'hash' => 'your_hash',
]);
```

### Crypto

[](#crypto)

Call the crypto endpoint. This will return an instance of `Farzai\Bitkub\Endpoints\CryptoEndpoint` class.

```
$crypto = $bitkub->crypto();

# Next, We will use this instance for the following examples below.
# ...
```

#### List all crypto addresses.

[](#list-all-crypto-addresses)

- GET `/api/v3/crypto/addresses`

```
$crypto->addresses([
    // integer: The page number.
    'p' => 1,

    // integer: Limit the number of results.
    'lmt' => 10,
]);
```

#### Make a withdrawal to a trusted address.

[](#make-a-withdrawal-to-a-trusted-address)

- POST `/api/v3/crypto/withdraw`

```
$crypto->withdrawal([
    // string: Currency for withdrawal (e.g. BTC, ETH)
    'cur' => 'BTC',

    // float: Amount you want to withdraw
    'amt' => 0.001,

    // string: Address to which you want to withdraw
    'adr' => 'your_address',

    // string: (Optional) Memo or destination tag to which you want to withdraw
    'mem' => 'your_memo',

    // string: Cryptocurrency network to withdraw
    'net' => 'BTC',
]);
```

#### Make a withdraw to an internal address.

[](#make-a-withdraw-to-an-internal-address)

- POST `/api/v3/crypto/internal-withdraw`

```
$crypto->internalWithdrawal([
    // string: Currency for withdrawal (e.g. BTC, ETH)
    'cur' => 'BTC',

    // float: Amount you want to withdraw
    'amt' => 0.001,

    // string: Address to which you want to withdraw
    'adr' => 'your_address',

    // string: (Optional) Memo or destination tag to which you want to withdraw
    'mem' => 'your_memo',
]);
```

#### List crypto deposit history.

[](#list-crypto-deposit-history)

- POST `/api/v3/crypto/deposit-history`

```
$crypto->depositHistory([
    // integer: The page number.
    'p' => 1,

    // integer: Limit the number of results.
    'lmt' => 10,
]);
```

#### List crypto withdrawal history.

[](#list-crypto-withdrawal-history)

- POST `/api/v3/crypto/withdrawal-history`

```
$crypto->withdrawalHistory([
    // integer: The page number.
    'p' => 1,

    // integer: Limit the number of results.
    'lmt' => 10,
]);
```

#### Generate a new crypto address

[](#generate-a-new-crypto-address)

- POST `/api/v3/crypto/generate-address`

```
$crypto->generateAddress(
    // string Symbol (e.g. THB_BTC, THB_ETH, etc.)
    'THB_BTC'
);
```

### System

[](#system)

Call the system endpoint. This will return an instance of `Farzai\Bitkub\Endpoints\SystemEndpoint` class.

```
$system = $bitkub->system();

# Next, We will use this instance for the following examples below.
# ...
```

#### Get server status.

[](#get-server-status)

- GET `/api/status`

```
$system->status();
```

#### Get server timestamp.

[](#get-server-timestamp)

- GET `/api/v3/servertime`

```
$system->serverTimestamp();
```

### User

[](#user)

Call the user endpoint. This will return an instance of `Farzai\Bitkub\Endpoints\UserEndpoint` class.

```
$user = $bitkub->user();

# Next, We will use this instance for the following examples below.
# ...
```

#### Check trading credit balance.

[](#check-trading-credit-balance)

- POST `/api/v3/user/trading-credits`

```
$user->tradingCredits();
```

#### Check deposit/withdraw limitations and usage.

[](#check-depositwithdraw-limitations-and-usage)

- POST `/api/v3/user/limits`

```
$user->limits();
```

### WebSocket

[](#websocket)

Create a WebSocket client using the `WebSocketClientBuilder`.

```
$client = \Farzai\Bitkub\ClientBuilder::create()
    ->setCredentials('YOUR_API_KEY', 'YOUR_SECRET_KEY')
    ->build();

$websocket = \Farzai\Bitkub\WebSocketClientBuilder::create()
    ->setClient($client)
    ->build();
```

#### Market streams

[](#market-streams)

Subscribe to market data streams (trades, tickers, etc.).

```
$websocket->market()->listen('trade.thb_btc', function (\Farzai\Bitkub\WebSocket\Message $message) {
    echo $message->sym . PHP_EOL;
});

// Or subscribe to multiple streams at once
$websocket->market()->listen(['trade.thb_btc', 'trade.thb_eth'], function (\Farzai\Bitkub\WebSocket\Message $message) {
    echo $message->sym . PHP_EOL;
});

$websocket->run();
```

#### Live order book

[](#live-order-book)

Subscribe to live order book updates. Requires a REST client to resolve symbol names.

```
$websocket->liveOrderBook()->listen('THB_BTC', function (\Farzai\Bitkub\WebSocket\Message $message) {
    echo $message . PHP_EOL;
});

// Or use a numeric symbol ID directly
$websocket->liveOrderBook()->listen(1, function (\Farzai\Bitkub\WebSocket\Message $message) {
    echo $message . PHP_EOL;
});

$websocket->run();
```

---

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/farzai/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [parsilver](https://github.com/parsilver)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance59

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

3

Last Release

876d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4928451?v=4)[parsilver](/maintainers/parsilver)[@parsilver](https://github.com/parsilver)

---

Top Contributors

[![parsilver](https://avatars.githubusercontent.com/u/4928451?v=4)](https://github.com/parsilver "parsilver (47 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")

---

Tags

apibitkubphpfarzaibitkub

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/farzai-bitkub/health.svg)

```
[![Health](https://phpackages.com/badges/farzai-bitkub/health.svg)](https://phpackages.com/packages/farzai-bitkub)
```

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23914.2M16](/packages/hubspot-api-client)[lstrojny/fxmlrpc

Fast and tiny XML/RPC client with bridges for various HTTP clients

1425.4M30](/packages/lstrojny-fxmlrpc)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
