abe27 / bitkub-service
A Laravel package for integrating with the Bitkub Cryptocurrency Exchange API
v0.0.1.0
2025-05-07 08:28 UTC
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.9
- illuminate/support: ^12.12
Requires (Dev)
- orchestra/testbench: ^10.2
- phpunit/phpunit: ^12.1
This package is auto-updated.
Last update: 2025-05-07 08:36:00 UTC
README
A Laravel package for integrating with the Bitkub Cryptocurrency Exchange API.
Installation
You can install the package via composer:
composer require abe27/bitkub-service
Publish Configuration
After installing the package, publish the configuration file:
php artisan vendor:publish --tag=bitkub-config
This will create a config/bitkub.php
configuration file in your project.
Configuration
Add your Bitkub API credentials to your .env
file:
BITKUB_API_KEY=your-api-key
BITKUB_API_SECRET=your-api-secret
BITKUB_ENDPOINT=https://api.bitkub.com
Usage
Basic Usage
// Get market status $status = Bitkub::status(); // Get server time $serverTime = Bitkub::serverTime(); // Get market symbols $symbols = Bitkub::symbols(); // Get ticker information for all symbols $ticker = Bitkub::ticker(); // Get ticker information for a specific symbol $btcTicker = Bitkub::ticker('BTC');
Authentication Required API
For endpoints that require authentication, you need to set up your API key and secret in the configuration file.
// Get user balances $balances = Bitkub::balances(); // Create a buy order $buyOrder = Bitkub::createBuyOrder('BTC', 0.001, 500000, 'limit'); // Create a sell order $sellOrder = Bitkub::createSellOrder('BTC', 0.001, 550000, 'limit'); // Cancel an order $cancelOrder = Bitkub::cancelOrder('BTC', 12345, 'buy');
Available Methods
Public API Endpoints
status()
- Get server statusserverTime()
- Get server timesymbols()
- Get market symbolsticker($symbol = null)
- Get ticker information
Private API Endpoints
balances()
- Get user balancescreateBuyOrder($symbol, $amount, $rate, $type = 'limit')
- Create a buy ordercreateSellOrder($symbol, $amount, $rate, $type = 'limit')
- Create a sell ordercancelOrder($symbol, $id, $side)
- Cancel an order
Error Handling
All API errors will throw a BitkubException
which can be caught and handled appropriately:
use Abe27\Bitkub\Exceptions\BitkubException; try { $balances = Bitkub::balances(); } catch (BitkubException $e) { // Handle Bitkub API error $message = $e->getMessage(); $errorCode = $e->getErrorCode(); // Log or handle the error }
License
This package is open-sourced software licensed under the MIT license.