Go SDK for Bitkub Cryptocurrency Exchange API - Complete implementation with full V3 & V4 API support + Command Line Interface
# Install via go install
go install github.com/dvgamerr-app/go-bitkub/cmd/bitkub@latest
# Get market ticker
bitkub market ticker
# Get BTC price
bitkub market ticker btc_thb
# Get historical data
bitkub market history btc_thb --resolution 1
# Output in different formats
bitkub market ticker --format json # JSON output
bitkub market ticker --format jsonl # JSONL output (one JSON per line)
bitkub market ticker --format text # Text output (default)
# Get your balance (requires API keys)
bitkub -k YOUR_KEY -s YOUR_SECRET market balancesThis SDK implements the latest Bitkub API V3 specification (November 2025) with:
- β All deprecated endpoints removed
- β Using V3 endpoints exclusively
- β Keyset-based pagination (page-based removed)
- β Simplified function names (removed V3 suffix)
- π CLI Tool with Cobra & Zerolog
A powerful CLI tool for interacting with Bitkub API from the terminal:
- β All API endpoints accessible via commands
- β Beautiful logging output with zerolog
- β Multiple output formats (JSON, JSONL, Text)
- β Support for .env configuration
- β Market commands including historical data (31+ total)
- β Crypto commands (7 total)
- β Fiat commands (4 total)
- β User commands (3 total)
Documentation:
- π Installation Guide - Detailed installation instructions
- π CLI Documentation - Complete CLI reference with examples
- β Market trade stream
- β Market ticker stream
- β Live order book stream
- β Multiple streams subscription
- β Auto-reconnect with configurable retry
- β Graceful shutdown & error handling
# Trade stream (5 messages default)
bitkub stream trade thb_btc
# Ticker stream continuous
bitkub stream ticker thb_btc -t
# JSONL output
bitkub --format jsonl stream trade thb_btc -n 2
# JSON array output
bitkub --format json stream ticker thb_btc -n 5- β Non-secure endpoints (Market data, server status)
- β Secure endpoints (Trading, user info, fiat operations)
- β Historical data for TradingView charts
- β WebSocket token support
- β Full order management (place, cancel, history)
- β Wallet & balance operations
- β Real-time ticker and trade data
- π List crypto addresses with pagination
- β Generate new crypto addresses
- π° View deposit history
- πΈ View withdrawal history
- π Create withdrawals to trusted addresses
- πͺ Get available coins and networks
- π View compensations history
- β Type-safe API responses
- β Proper error handling
- β Connection pooling & optimization
- β HMAC SHA256 signature authentication
- β Rate limit awareness
go get github.com/dvgamerr-app/go-bitkubpackage main
import (
"log"
"github.com/dvgamerr-app/go-bitkub/bitkub"
"github.com/dvgamerr-app/go-bitkub/market"
)
func main() {
// Initialize with API credentials
bitkub.Initlizer("YOUR_API_KEY", "YOUR_SECRET_KEY")
// Or use environment variables BTK_APIKEY and BTK_SECRET
bitkub.Initlizer()
// Get wallet balance
wallet, err := market.GetWallet()
if err != nil {
log.Fatal(err)
}
log.Printf("Wallet: %+v", wallet)
// Get detailed balances
balances, err := market.GetBalances()
if err != nil {
log.Fatal(err)
}
log.Printf("Balances: %+v", balances)
}import (
"github.com/dvgamerr-app/go-bitkub/bitkub"
"github.com/dvgamerr-app/go-bitkub/market"
)
// Get system status
status, err := bitkub.GetStatus()
// Get server time
timestamp, err := bitkub.GetServerTime()
// Get all symbols
symbols, err := market.GetSymbols()
// Get ticker data
tickers, err := market.GetTicker("btc_thb")
// Get market depth
depth, err := market.GetDepth("btc_thb", 10)
// Get recent trades
trades, err := market.GetTrades("btc_thb", 10)
// Get historical data for TradingView
history, err := market.GetHistory(market.HistoryRequest{
Symbol: "btc_thb",
Resolution: "60", // 1, 5, 15, 60, 240, 1D
From: 1234567890,
To: 1234567890,
})
// Get buy orders (bids)
bids, err := market.GetBids("btc_thb", 10)
// Get sell orders (asks)
asks, err := market.GetAsks("btc_thb", 10)import "github.com/dvgamerr-app/go-bitkub/market"
// Get wallet balances
wallet, err := market.GetWallet()
// Get detailed balances
balances, err := market.GetBalances()
// Place buy order
bidReq := market.PlaceBidRequest{
Symbol: "btc_thb",
Amount: 1000,
Rate: 2500000,
Type: "limit",
ClientID: "order-1",
}
bidResult, err := market.PlaceBid(bidReq)
// Place sell order
askReq := market.PlaceAskRequest{
Symbol: "btc_thb",
Amount: 0.001,
Rate: 2600000,
Type: "limit",
}
askResult, err := market.PlaceAsk(askReq)
// Cancel order
cancelReq := market.CancelOrderRequest{
Symbol: "btc_thb",
ID: "12345",
Side: "buy",
}
err = market.CancelOrder(cancelReq)
// Get open orders
orders, err := market.GetOpenOrders("btc_thb")
// Get order history (with keyset pagination)
historyParams := market.OrderHistoryParams{
Symbol: "BTC_THB",
Limit: "10",
}
orderHistory, err := market.GetOrderHistory(historyParams)
// Get order info
orderInfo, err := market.GetOrderInfo("btc_thb", "12345", "buy")
// Get WebSocket token
token, err := market.GetWSToken()import "github.com/dvgamerr-app/go-bitkub/user"
// Get trading credits
credits, err := user.GetTradingCredits()
// Get user limits
limits, err := user.GetUserLimits()
// Get coin convert history
convertParams := user.CoinHistoryParams{
Page: 1,
Limit: 100,
Status: "success",
}
convertHistory, err := user.GetCoinConvertHistory(convertParams)import "github.com/dvgamerr-app/go-bitkub/fiat"
// Get bank accounts
accountsParams := fiat.AccountsParams{
Page: 1,
Limit: 10,
}
accounts, err := fiat.GetAccounts(accountsParams)
// Withdraw fiat
withdrawReq := fiat.WithdrawRequest{
ID: "bank-account-id",
Amount: 1000.0,
}
withdrawResult, err := fiat.Withdraw(withdrawReq)
// Get deposit history
depositParams := fiat.DepositHistoryParams{
Page: 1,
Limit: 10,
}
deposits, err := fiat.GetDepositHistory(depositParams)
// Get withdrawal history
withdrawParams := fiat.WithdrawHistoryParams{
Page: 1,
Limit: 10,
}
withdrawals, err := fiat.GetWithdrawHistory(withdrawParams)import "github.com/dvgamerr-app/go-bitkub/crypto"
// List crypto addresses with pagination
addresses, err := crypto.GetAddresses(crypto.Addresses{
Page: 1,
Limit: 10,
Symbol: "ATOM",
Network: "ATOM",
})
// Create new crypto address
newAddresses, err := crypto.CreateAddress(crypto.CreateAddressRequest{
Symbol: "BTC",
Network: "BTC",
})
// Get deposit history with filters
deposits, err := crypto.GetDeposits(crypto.Deposits{
Page: 1,
Limit: 10,
Symbol: "BTC",
Status: "complete",
})
// Get withdrawal history
withdrawals, err := crypto.GetWithdraws(crypto.Withdraws{
Page: 1,
Limit: 10,
Symbol: "BTC",
})
// Get available coins
coins, err := crypto.GetCoins(crypto.Coins{
Symbol: "BTC",
})
// Withdraw crypto
withdrawReq := crypto.CreateWithdrawRequest{
Symbol: "BTC",
Network: "BTC",
Address: "bc1q...",
Amount: 0.001,
Memo: "",
}
txn, err := crypto.CreateWithdraw(withdrawReq)
// Get compensations history
compensations, err := crypto.GetCompensations(crypto.Compensations{
Page: 1,
Limit: 10,
})- Never commit API keys to version control
- Use environment variables for credentials:
export BTK_APIKEY="your_api_key" export BTK_SECRET="your_secret_key"
- Use IP whitelist in Bitkub API settings
- Implement rate limiting in your application
- Monitor API usage regularly
| Endpoint Type | Rate Limit |
|---|---|
| Market Data V3 (ticker, trades, etc.) | 100 req/sec |
| Trading Operations | 150-200 req/sec |
| Fiat/User Operations | 20 req/sec |
| Crypto V4 Operations | 250 req/10sec |
See official documentation for complete information.
# Set your credentials
export BTK_APIKEY="your_api_key"
export BTK_SECRET="your_secret_key"
# Run tests
go test ./... -vgo-bitkub/
βββ bitkub/ # Core API client and authentication
β βββ bitkub.go # Initialization and configuration
β βββ fetch.go # HTTP client with v3 & v4 support
β βββ error.go # Error code mappings
β βββ status.go # System status endpoints
β βββ types.go # Common type definitions
βββ market/ # Market API (V3) endpoints
β βββ symbols.go
β βββ ticker.go
β βββ depth.go
β βββ trades.go
β βββ bids.go
β βββ asks.go
β βββ place-bid.go
β βββ place-ask.go
β βββ cancel-order.go
β βββ order-history.go
β βββ order-info.go
β βββ balances.go
β βββ wallet.go
β βββ wstoken.go
βββ user/ # User API (V3) endpoints
β βββ trading-credits.go
β βββ limits.go
β βββ coin-convert-history.go
βββ fiat/ # Fiat API (V3) endpoints
β βββ accounts.go
β βββ withdraw.go
β βββ deposit-history.go
β βββ withdraw-history.go
βββ crypto/ # Crypto API (V4) endpoints
β βββ addresses.go
β βββ deposits.go
β βββ withdraws.go
β βββ coins.go
β βββ compensations.go
β βββ types.go
βββ stream/ # WebSocket streaming (Real-time)
β βββ stream.go # Main stream client
β βββ types.go # Message types
β βββ stream_test.go # Tests
β βββ README.md # Stream documentation
β βββ examples/ # Usage examples
β βββ market/ # Market stream example
β βββ orderbook/ # Order book example
β βββ timeout/ # Timeout example
βββ utils/ # Utility functions
β βββ error.go
β βββ helper.go
βββ balances.go # Balance aggregation helper
βββ wallet.go # Wallet helper functions
βββ docs/ # Documentation
Real-time market data streaming with auto-reconnect support.
import "github.com/dvgamerr-app/go-bitkub/stream"
// Create stream with default config
s := stream.New(nil)
// Connect to market streams
if err := s.ConnectMarket("market.trade.thb_btc", "market.ticker.thb_btc"); err != nil {
panic(err)
}
defer s.Close()
// Read messages in loop
for msg := range s.Messages() {
if msg.Error != nil {
fmt.Printf("Error: %v\n", msg.Error)
continue
}
fmt.Printf("[%s] %+v\n", msg.Type, msg.Data)
}config := &stream.StreamConfig{
ReconnectInterval: 5 * time.Second, // Wait before reconnect
MaxReconnect: 10, // Max reconnect attempts
PingInterval: 30 * time.Second, // Ping interval
ReadTimeout: 60 * time.Second, // Read timeout
}
s := stream.New(config)Market Streams:
market.trade.<symbol>- Real-time tradesmarket.ticker.<symbol>- Real-time ticker
Order Book:
// Connect to order book (symbol ID: 1 = THB_BTC)
s.ConnectOrderBook(1)See stream/README.md for complete documentation and examples.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License
- Bitkub Official Website
- Bitkub V3 API Documentation
- Bitkub V4 API Documentation
- Bitkub WebSocket API Documentation
- Bitkub Support
This is an unofficial SDK. Use at your own risk. Always test thoroughly before using in production.
Note: This SDK implements the Bitkub API specification as of November 2025. API specifications are subject to change by Bitkub.
