A Python library backward compatibility for Bitkub API v2 and latest Bitkub official API
Project description
Bitkub Python
A Python library for bitkub.com API
Releases
2025-12-28version3.2.1- update to api v3/v4
- backword compatible to api v2 results
2023-12-14version3.1.4- change sym from quote_base to base_quote
2023-12-11version3.1.3- revise tradingview history
2023-12-01version3.1.1- switch to api v3
2023-03-29version2.1.0- switch to api v2 in Create buy order, Create sell order and Cancel order
- remove Create sell order by fiat, Deprecated at 2023-03-27
Table of Contents
- Installation
- Usage
- Creating a Bitkub
- Set API key & API secret
- Viewing status
- Viewing servertime
- Viewing symbols
- Viewing ticker
- Viewing trades
- Viewing bids
- Viewing asks
- Viewing books
- Viewing depth
- Viewing tradingview history
- Viewing wallet
- Viewing balances
- Create buy order
- Create buy order test
- Create sell order
- Create sell order test
- Create sell order by fiat
- Cancel order
- My open orders
- My order history
- Order info
- Crypto addresses
- Crypto withdraw
- Crypto internal withdraw
- Crypto deposit history
- Crypto withdraw history
- Crypto generate address
- Fiat accounts
- Fiat withdraw
- Fiat deposit history
- Fiat withdraw history
- Market wstoken
- User limits
- User trading credits
Installation
pip install bitkub-v2
Usage
from bitkub import Bitkub
Creating a Bitkub Object
API_KEY = 'YOUR API KEY'
API_SECRET = 'YOUR API SECRET'
# initial obj only non-secure
bitkub = Bitkub()
# initial obj non-secure and secure
bitkub = Bitkub(api_key=API_KEY, api_secret=API_SECRET)
You can find API KEY and API SECRET from here.
Set API key and API secret
If you initial obj with only non-secure. You can set up API key and API secret on below.
API_KEY = 'YOUR API KEY'
API_SECRET = 'YOUR API SECRET'
bitkub = Bitkub()
bitkub.set_api_key(API_KEY)
bitkub.set_api_secret(API_SECRET)
# use latest offical api
bitkub.latest_bitkub_official_api()
Viewing status
Get endpoint status.
Function:
bitkub.status()
Response:
[
{
'name': 'Non-secure endpoints',
'status': 'ok',
'message': ''
},
{
'name': 'Secure endpoints',
'status': 'ok',
'message': ''
}
]
Viewing servertime
Get server timestamp.
Function:
bitkub.servertime()
Response:
1701251212273
Viewing symbols
List all available symbols.
Function:
bitkub.symbols()
Response:
{
'error': 0,
'result': [
{
'id': 1,
'info': 'Thai Baht to Bitcoin',
'symbol': 'THB_BTC'
},
{
'id': 2,
'info': 'Thai Baht to Ethereum',
'symbol': 'THB_ETH'
}
]
}
Viewing ticker
Get ticker information.
Function:
bitkub.ticker(sym='THB_BTC')
Parameter:
symstring The symbol (optional)default""
Response:
{
'THB_BTC': {
'id': 1,
'last': 278000,
'lowestAsk': 278869.41,
'highestBid': 278000,
'percentChange': -1.44,
'baseVolume': 206.01549914,
'quoteVolume': 57883319.04,
'isFrozen': 0,
'high24hr': 284000,
'low24hr': 277579.62,
'change': -4075.81,
'prevClose': 281800,
'prevOpen': 281800
}
}
Viewing trades
List recent trades.
Function:
bitkub.trades(sym="THB_BTC", lmt=2)
Parameter:
symstring The symbollmtint No. of limit to Parameter recent tradesdefault1
Response:
{
'error': 0,
'result': [
[
1583246192, // timestamp
278798.34, // rate
0.00375672, // amount
'BUY' // side
],
[
1583246159,
278000,
0.0001042,
'SELL'
]
]
}
Viewing bids
List open buy orders.
Function:
bitkub.bids(sym="THB_BTC", lmt=2)
Parameter:
symstring The symbollmtint No. of limit to Parameter open buy ordersdefault1
Response:
{
'error': 0,
'result': [
[
4632978, // order id
1583245687, // timestamp
73110.59, // volume
278000, // rate
0.26298773 // amount
],
[
4632732,
1583245871,
1312.68,
278000,
0.00472187
]
]
}
Viewing asks
List open sell orders.
Function:
bitkub.asks(sym="THB_BTC", lmt=2)
Parameter:
symstring The symbollmtint No. of limit to Parameter open sell ordersdefault1
Response:
{
'error': 0,
'result': [
[
4761288, // order id
1583246870, // timestamp
163813.12, // volume
278499.03, // rate
0.5882 // amount
],
[
4761287,
1583246870,
379232.12,
278499.03,
1.3617
]
]
}
Viewing books
⚠️ This API is deprecated. (2025-12-09)
List all open orders.
Function:
bitkub.books(sym="THB_BTC", lmt=1)
Parameter:
symstring The symbollmtint No. of imit to Parameter open ordersdefault1
Response:
{
'error': 0,
'result': {
'asks': [
[
4761425, // order id
1583247105, // timestamp
360885.74, // volume
278300.17, // rate
1.29675 // amount
]
],
'bids': [
[
4633099, // order id
1583247090, // timestamp
622146.15, // volume
277946.2, // rate
2.23836897 // amount
]
]
}
}
Viewing depth
Get depth information.
Function:
bitkub.depth(sym='THB_BTC', lmt=1)
Parameter:
symstring The symbollmtint Depth sizedefault1
Response:
{
'asks': [
[
277946.16,
1.29675
]
],
'bids': [
[
277936.27,
0.94071896
]
]
}
Viewing tradingview history
Get historical data for TradingView chart.
Function:
bitkub.tradingview(sym='THB_BTC', int=1, frm='', to='')
Parameter:
symstring The symbolintint Chart resolution (1, 5, 15, 60, 240, 1D)default1frmint Timestamp of the starting timetoint Timestamp of the ending time
Response:
{
'c': [
1685000,
1680699.95,
1688998.99,
1692222.22
],
'h': [
1685000,
1685000,
1689000,
1692222.22
],
'l': [
1680053.22,
1671000,
1680000,
1684995.07
],
'o': [
1682500,
1685000,
1680100,
1684995.07
],
's': "ok",
't': [
1633424400,
1633425300,
1633426200,
1633427100
],
'v': [
4.604352630000001,
8.530631670000005,
4.836581560000002,
2.8510189200000022
]
}
Viewing wallet
Get user available balances. Required initial secure obj
Function:
bitkub.wallet()
Response:
{
'error': 0,
'result': {
'THB': 0,
'BTC': 0,
'ETH': 0
}
}
Viewing balances
Get balances info: this includes both available and reserved balances. Required initial secure obj
Function:
bitkub.balances()
Response:
{
'error': 0,
'result': {
'THB': {
'available': 0,
'reserved': 0
},
'BTC': {
'available': 0,
'reserved': 0
}
}
}
Create buy order
Create a buy order. Required initial secure obj
Function:
bitkub.place_bid(sym='THB_BTC', amt=1, rat=1, typ='limit', client_id='')
Parameter:
symstring The symbolamtfloat Amount you want to spend with no trailing zero (e.g 1000.00 is invalid, 1000 is ok)default1ratfloat Rate you want for the order with no trailing zero (e.g 1000.00 is invalid, 1000 is ok)default1typstring Order type: limit or market (for market order, please specify rat as 0)defaultlimitclient_idstring your id for reference ( not required )
Response:
{
"error": 0,
"result": {
"id": 1, // order id
"hash": "fwQ6dnQWQPs4cbatF5Am2xCDP1J", // order hash
"typ": "limit", // order type
"amt": 1000, // spending amount
"rat": 15000, // rate
"fee": 2.5, // fee
"cre": 2.5, // fee credit used
"rec": 0.06666666, // amount to receive
"ts": 1533834547 // timestamp
"ci": "input_client_id" // input id for reference
}
}
Create buy order test
⚠️ This API is deprecated. (2023-11-29)
Create a buy order test. Required initial secure obj
Function:
bitkub.place_bid_test(sym='THB_BTC', amt=1, rat=1, typ='limit', client_id='')
Parameter:
symstring The symbolamtfloat Amount you want to spend with no trailing zero (e.g 1000.00 is invalid, 1000 is ok)default1ratfloat Rate you want for the order with no trailing zero (e.g 1000.00 is invalid, 1000 is ok)default1typstring Order type: limit or marketdefaultlimitclient_idstring Your id for reference ( no required )
Response:
{
'error': 0,
'result': {
'id': 1,
'hash': 'fwQ6dnQWQPs4cbatF5Am2xCDP1J',
'typ': 'limit',
'amt': 1,
'rat': 1,
'fee': 2.5,
'cre': 2.5,
'rec': 0.06666666,
'ts': 1533834547
}
}
Create sell order
Create a sell order. Required initial secure obj
Function:
bitkub.place_ask(sym='THB_BTC', amt=1, rat=1, typ='limit', client_id='')
Parameter:
symstring The symbolamtfloat Amount you want to sell with no trailing zero (e.g 0.10000000 is invalid, 0.1 is ok)default1ratfloat Rate you want for the order with no trailing zero (e.g 1000.00 is invalid, 1000 is ok)default1typstring Order type: limit or market (for market order, please specify rat as 0)defaultlimitclient_idstring your id for reference ( not required )
Response:
{
"error": 0,
"result": {
"id": 1, // order id
"hash": "fwQ6dnQWQPs4cbatFGc9LPnpqyu", // order hash
"typ": "limit", // order type
"amt": 1.00000000, // selling amount
"rat": 15000, // rate
"fee": 37.5, // fee
"cre": 37.5, // fee credit used
"rec": 15000, // amount to receive
"ts": 1533834844 // timestamp
"ci": "input_client_id" // input id for reference
}
}
Create sell order test
⚠️ This API is deprecated. (2023-11-29)
Create a sell order test. Required initial secure obj
Function:
bitkub.place_ask_test(sym='THB_BTC', amt=1, rat=1, typ='limit', client_id='')
Parameter:
symstring The symbolamtfloat Amount you want to spend with no trailing zero (e.g 1000.00 is invalid, 1000 is ok)default1ratfloat Rate you want for the order with no trailing zero (e.g 1000.00 is invalid, 1000 is ok)default1typstring Order type: limit or marketdefaultlimitclient_idstring Your id for reference ( no required )
Response:
{
'error': 0,
'result': {
'id': 1,
'hash': 'fwQ6dnQWQPs4cbatF5Am2xCDP1J',
'typ': 'limit',
'amt': 1,
'rat': 1,
'fee': 2.5,
'cre': 2.5,
'rec': 0.06666666,
'ts': 1533834547
}
}
Create sell order by fiat
⚠️ This API is deprecated. (2023-03-27)
Create a sell order by specifying the fiat amount you want to receive (selling amount of cryptocurrency is automatically calculated). Required initial secure obj
Function:
bitkub.place_ask_by_fiat(sym='THB_BTC', amt=1, rat=1, typ='limit')
Parameter:
symstring The symbolamtfloat Amount you want to spend with no trailing zero (e.g 1000.00 is invalid, 1000 is ok)default1ratfloat Rate you want for the order with no trailing zero (e.g 1000.00 is invalid, 1000 is ok)default1typstring Order type: limit or marketdefaultlimit
Response:
{
'error': 0,
'result': {
'id': 1,
'hash': 'fwQ6dnQWQPs4cbatF5Am2xCDP1J',
'typ': 'limit',
'amt': 1,
'rat': 1,
'fee': 2.5,
'cre': 2.5,
'rec': 0.06666666,
'ts': 1533834547
}
}
Cancel orrder
Cancel an open order. Required initial secure obj
Function:
bitkub.cancel_order(sym='THB_BTC', id=1, sd=1, hash='XXXXXX')
Parameter:
symstring The symbolidint Order id you wish to cancelsdstring Order side: buy or selldefaultbuyhashstring Cancel an order with order hash (optional). You don't need to specify sym, id, and sd when you specify order hash.
Response:
{
'error': 0
}
My open orders
List all open orders of the given symbol. Required initial secure obj
Function:
bitkub.my_open_orders(sym='THB_BTC')
Parameter:
symstring The symbol
Response:
{
'error': 0,
'result': [
{
'id': 2,
'hash': 'fwQ6dnQWQPs4cbatFSJpMCcKTFR',
'side': 'SELL',
'type': 'limit',
'rate': 15000,
'fee': 35.01,
'credit': 35.01,
'amount': 0.93333334,
'receive': 14000,
'parent_id': 1,
'super_id': 1,
'ts': 1533834844
}
]
}
My order history
List all orders that have already matched. Required initial secure obj
Function:
bitkub.my_open_history(sym='THB_BTC', p=1, lmt=10)
Parameter:
symstring The symbolpstring Page (optional)lmtstring Limit (optional)startstring Start timestamp (optional)endstring End timestamp (optional)
Response:
{
'error': 0,
'result': [
{
'txn_id': 'ETHBUY0000000197',
'order_id': 240,
'hash': 'fwQ6dnQWQPs4cbaujNyejinS43a',
'parent_order_id': 0,
'super_order_id': 0,
'taken_by_me': true,
'is_maker': true,
'side': 'buy',
'type': 'limit',
'rate': 13335.57,
'fee': 0.34,
'credit': 0.34,
'amount': 0.00999987,
'ts': 1531513395
}
{
'error': 0,
'result': {
'id': 289,
],
'pagination': {
'page': 2,
'last': 3,
'next': 3,
'prev': 1
}
}
Order info
Get information regarding the specified order. Required initial secure obj
Function:
bitkub.order_info(sym='THB_BTC', id=1, sd='buy', hash='XXXXXX')
Parameter:
symstring The symbolidint Order idsdstring Order side: buy or selldefaultbuyhashstring Lookup an order with order hash (optional). You don't need to specify sym, id, and sd when you specify order hash.
Response:
{
'error': 0,
'result': {
'id': 289,
'first': 289,
'parent': 0,
'last': 316,
'amount': 4000,
'rate': 291000,
'fee': 10,
'credit': 10,
'filled': 3999.97,
'total': 4000,
'status': 'filled',
'partial_filled': False,
'remaining': 0,
'history': [
{
'amount': 98.14848,
'credit': 0.25,
'fee': 0.25,
'id': 289,
'rate': 291000,
'timestamp': 1525944169
}
]
}
}
Crypto addresses
List all crypto addresses. Required initial secure obj
Function:
bitkub.crypto_address(p=1, lmt=1)
Parameter:
pint Page (optional)default1lmtint Limit (optional)default10
Response:
{
'error': 0,
'result': [
{
'currency': 'BTC',
'address': '3BtxdKw6XSbneNvmJTLVHS9XfNYM7VAe8k',
'tag': 0,
'time': 1570893867
}
],
'pagination': {
'page': 1,
'last": 1
}
}
Crypto withdraw
Make a withdrawal to a trusted address. Required initial secure obj
Function:
bitkub.crypto_withdraw(cur='BTC', amt=0.1, adr='4asyjKw6XScneNvhJTLVHS9XfNYM7VBf8x', mem='')
Parameter:
curstring Currency for withdrawal (e.g. BTC, ETH)amtfloat Amount you want to withdrawadrstring Address to which you want to withdrawmemstring (Optional) Memo or destination tag to which you want to withdraw
Response:
{
'error': 0,
'result': {
'txn': 'BTCWD0000012345',
'adr': '4asyjKw6XScneNvhJTLVHS9XfNYM7VBf8x'
'mem': '',
'cur': 'BTC',
'amt': 0.1,
'fee': 0.0002,
'ts': 1569999999
}
}
Crypto internal withdraw
⚠️ This API is deprecated. (2025-12-09)
Make a withdrawal to a trusted address. Required initial secure obj
The destination address is not required to be a trusted address. This API is not enabled by default, Only KYB users can request this feature by contacting us via support@bitkub.com
Function:
bitkub.crypto_internal_withdraw(cur='BTC', amt=0.1, adr='4asyjKw6XScneNvhJTLVHS9XfNYM7VBf8x', mem='')
Parameter:
curstring Currency for withdrawal (e.g. BTC, ETH)amtfloat Amount you want to withdrawadrstring Address to which you want to withdrawmemstring (Optional) Memo or destination tag to which you want to withdraw
Response:
{
'error': 0,
'result': {
'txn': 'BTCWD0000012345',
'adr': '4asyjKw6XScneNvhJTLVHS9XfNYM7VBf8x'
'mem': '',
'cur': 'BTC',
'amt': 0.1,
'fee': 0.0002,
'ts': 1569999999
}
}
Crypto deposit history
List crypto deposit history. Required initial secure obj
Function:
bitkub.crypto_deposit_history(p=1, lmt=1)
Parameter:
pint Page (optional)default1lmtint Limit (optional)default10
Response:
{
'error': 0,
'result': [
{
'hash': 'XRPWD0000100276',
'currency': 'XRP',
'amount': 5.75111474,
'from_address': 'sender address',
'to_address': 'receipent address',
'confirmations': 1,
'status': 'complete',
'time': 1570893867
}
],
'pagination': {
'page': 1,
'last': 1
}
}
Crypto withdraw history
:
List crypto withdrawal history. Required initial secure obj
Function:
bitkub.crypto_withdraw_history(p=1, lmt=1)
Parameter:
pint Page (optional)default1lmtint Limit (optional)default10
Response:
{
'error': 0,
'result': [
{
'txn_id': 'XRPWD0000100276',
'hash': 'send_internal',
'currency': 'XRP',
'amount': '5.75111474',
'fee': 0.01,
'address': 'rpXTzCuXtjiPDFysxq8uNmtZBe9Xo97JbW',
'status': 'complete',
'time': 1570893493
}
],
'pagination': {
'page': 1,
'last': 1
}
}
Crypto generate address
Generate a new crypto address (will replace existing address; previous address can still be used to received funds)
List all approved bank accounts. Required initial secure obj
Function:
bitkub.crypto_generate_address(sym='THB_BTC')
Parameter:
symstring The symbol
Response:
{
'error': 0,
'result': [
{
'currency': 'BTC',
'address': '0x520165471daa570ab632dd504c6af257bd36edfb',
'memo': ''
}
]
}
Fiat accounts
List all approved bank accounts. Required initial secure obj
Function:
bitkub.fiat_accounts(p=1, lmt=1)
Parameter:
pint Page (optional)default1lmtint Limit (optional)default10
Response:
{
'error': 0,
'result': [
{
'id': '7262109099',
'bank': 'Kasikorn Bank',
'name': 'Somsak',
'time': 1570893867
}
],
'pagination': {
'page': 1,
'last': 1
}
}
Fiat withdraw
Make a withdrawal to an approved bank account. Required initial secure obj
Function:
bitkub.fiat_withdraw(id=1, amt=1)
Parameter:
idstring Bank account idamtfloat Amount you want to withdraw
Response:
{
'error': 0,
'result': {
'txn': 'THBWD0000012345',
'acc': '7262109099',
'cur': 'THB',
'amt': 21,
'fee': 20,
'rec': 1,
'ts': 1569999999
}
}
Fiat deposit history
List fiat deposit history. Required initial secure obj
Function:
bitkub.fiat_deposit_history(p=1, lmt=1)
Parameter:
pint Page (optional)default1lmtint Limit (optional)default10
Response:
{
'error':0,
'result':[
{
'txn_id': 'THBDP0000012345',
'currency': 'THB',
'amount': 5000.55,
'status': 'complete',
'time': 1570893867
}
],
'pagination':{
'page': 1,
'last': 1
}
}
Fiat withdraw history
List fiat withdrawal history. Required initial secure obj
Function:
bitkub.fiat_withdraw_history(p=1, lmt=1)
Parameter:
pint Page (optional)default1lmtint Limit (optional)default10
Response:
{
'error': 0,
'result': [
{
'txn_id': 'THBDP0000012345',
'currency': 'THB',
'amount': 5000.55,
'fee': 20,
'status': 'complete',
'time': 1570893867
}
],
'pagination':{
'page': 1,
'last': 1
}
}
Market wstoken
Get the token for websocket authentication. Required initial secure obj
Function:
bitkub.market_wstoken()
Response:
{
'error': 0,
'result': 'sdCBCTwaS2Z1IBB6uTCefIbVN6dQVz9dkDeU96IoFJp14GGhlw9hoUDNe1KSYC23dXBPIqyX2QjVEOFHITxgPMvo8kdVaTkiZBA8KgvVTSMsq6JjjlyERDVZn3tt4PEp'
}
User limits
Check deposit/withdraw limitations and usage. Required initial secure obj
Function:
bitkub.user_limits()
Response:
{
'error': 0,
'result': {
'limits': {
'crypto': {
'deposit': 0,
'withdraw': 0
},
'fiat': {
'deposit': 0,
'withdraw': 0
}
},
'usage': {
'crypto': {
'deposit': 0,
'withdraw': 0,
'deposit_percentage': 0,
'withdraw_percentage': 0,
'deposit_thb_equivalent': 0,
'withdraw_thb_equivalent': 0
},
'fiat': {
'deposit': 0,
'withdraw': 0,
'deposit_percentage': 0,
'withdraw_percentage': 0
}
},
'rate': 177100.32
}
}
User trading-credit
Check trading credit balance. Required initial secure obj
Function:
bitkub.user_trading_credits()
Response:
{
'error': 0,
'result': 0
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file bitkub_v2-3.2.1.tar.gz.
File metadata
- Download URL: bitkub_v2-3.2.1.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9512c308ee1075799a830f0713352bd6a573da132e8cebb529a5a482159207d0
|
|
| MD5 |
ba0830776679766aa8a6519c3a4aadb8
|
|
| BLAKE2b-256 |
69f17c3c39540a277dd772730c1359ee27eb0a842b3986c1e64b2378589239a2
|