Simplify the integration of the Bitkub API into your PHP application. Bitkub API Documentation
**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.
You can install the package via composer:
composer require farzai/bitkub
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
$websocket = new \Farzai\Bitkub\WebSocket\Endpoints\MarketEndpoint(
new \Farzai\Bitkub\WebSocketClient(
\Farzai\Bitkub\ClientBuilder::create()
->setCredentials('YOUR_API_KEY', 'YOUR_SECRET_KEY')
->build(),
),
);
$websocket->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->listen(['trade.thb_ada', 'trade.thb_btc', function (\Farzai\Bitkub\WebSocket\Message $message) {
// Do something
echo $message->sym.PHP_EOL;
});
$websocket->run();
- Bitkub Wrapper - PHP (Unofficial)
- Installation
- Basic Usage
- Documentation
- Market
- List all available symbols.
- Get the ticker for a specific symbol.
- List recent trades.
- List open buy orders.
- List open sell orders.
- List all open orders.
- Get user available balances
- Create a buy order.
- Create a sell order.
- Cancel an open order.
- Get balances info: this includes both available and reserved balances.
- List all open orders of the given symbol.
- List all orders that have already matched.
- Get information regarding the specified order.
- Crypto
- System
- User
- Market
- Testing
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
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.
# ...
- GET
/api/market/symbols
$market->symbols();
- GET
/api/market/ticker
$market->ticker(
// string: The symbol.
'THB_BTC'
);
- GET
/api/market/trades
$market->trades([
// string: The symbol.
'sym' => 'THB_BTC',
// integer: Limit the number of results.
'lmt' => 10,
]);
- GET
/api/market/bids
$market->bids([
// string: The symbol.
'sym' => 'THB_BTC',
// integer: Limit the number of results.
'lmt' => 10,
]);
- GET
/api/market/asks
$market->asks([
// string: The symbol.
'sym' => 'THB_BTC',
// integer: Limit the number of results.
'lmt' => 10,
]);
- GET
/api/market/books
$market->books([
// string: The symbol.
'sym' => 'THB_BTC',
// integer: Limit the number of results.
'lmt' => 10,
]);
- GET
/api/market/wallet
$market->wallet();
- 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',
]);
- 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',
]);
- 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',
]);
- POST
/api/v3/market/balances
$market->balances();
- GET
/api/v3/market/my-open-orders
$market->openOrders(
// string: The symbol.
'THB_BTC'
);
- 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
/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',
]);
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.
# ...
- GET
/api/v3/crypto/addresses
$crypto->addresses([
// integer: The page number.
'p' => 1,
// integer: Limit the number of results.
'lmt' => 10,
]);
- 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',
]);
- 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',
]);
- POST
/api/v3/crypto/deposit-history
$crypto->depositHistory([
// integer: The page number.
'p' => 1,
// integer: Limit the number of results.
'lmt' => 10,
]);
- POST
/api/v3/crypto/withdrawal-history
$crypto->withdrawalHistory([
// integer: The page number.
'p' => 1,
// integer: Limit the number of results.
'lmt' => 10,
]);
- POST
/api/v3/crypto/generate-address
$crypto->generateAddress(
// string Symbol (e.g. THB_BTC, THB_ETH, etc.)
'THB_BTC'
);
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
/api/status
$system->status();
- GET
/api/v3/servertime
$system->serverTimestamp();
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.
# ...
- POST
/api/v3/user/trading-credits
$user->tradingCredits();
- POST
/api/v3/user/limits
$user->limits();
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.