Skip to main content

Bitkub API Setup (bitkub.com)

Connect KhunQuant to your Bitkub account for Thai baht crypto trading — Thailand's largest domestic crypto exchange.

← Back to Exchange Overview


Before You Start

Make sure you have:

  • A Bitkub account at bitkub.com
  • Identity verification (KYC) completed with your Thai national ID
  • Google Authenticator installed and linked to your Bitkub account
Google Authenticator Required

Bitkub requires a Google Authenticator code for every action in API Management — creating keys, editing permissions, and deleting keys. SMS-based 2FA is not supported for API management. If you haven't set up Google Authenticator yet, do that first before continuing.

Critical Safety Warning

When configuring API key permissions, never enable withdrawal permissions. KhunQuant only needs Read and Trade access. Enabling withdrawals creates a critical security risk — if someone obtains your key, they could drain your account immediately.


Step 1 — Open API Management

  1. Log in to bitkub.com
  2. Click your profile icon (top-right corner)
  3. Select [Account] from the dropdown
  4. Click [API] in the left sidebar
  5. Click [Create New API Key]

Step 2 — Enter Your Google Authenticator Code

Bitkub will immediately ask for your 6-digit Google Authenticator code before showing the API creation form. Enter it and click Confirm.


Step 3 — Name Your API Key

Enter a descriptive label:

  • KhunQuant
  • Portfolio-Tracker

Use only English letters, numbers, and hyphens.


Step 4 — Set Permissions

Configure permissions as follows:

PermissionSettingReason
View (Read)ONRequired to view balances and market data
TradeONRequired to place and cancel orders
WithdrawOFF — NEVER ENABLECritical security risk

Click Create after setting permissions.


Step 5 — Verify Again with Google Authenticator

Bitkub requires a second Google Authenticator verification after clicking Create. Enter your current 6-digit code and click Confirm.


After key creation, you can add an IP whitelist to lock the key to your device:

  1. Find your newly created key in the API list
  2. Click [Edit] next to the key
  3. Find the "IP Whitelist" field
  4. Enter your IPv4 address — you can add up to 50 IP addresses per key
  5. Enter your Google Authenticator code when prompted and click Save

To find your IPv4 address: Go to https://whatismyipaddress.com/ and look for the IPv4 value (format: 171.96.x.x).

Dynamic IP — Local Computer Users

If KhunQuant runs on your home computer or laptop, your public IP address can change without warning — this happens when your router restarts or your ISP assigns you a new address. When that happens, Bitkub will reject your API key with an "IP not allowed" error. You will need to update the whitelist with your new IP (and confirm with Google Authenticator again).

If KhunQuant runs on a cloud server or VPS, use the server's static public IP instead — it won't change. Make sure your cloud instance or VPS is secured with a firewall so only you can access it.

Stable IP via Outbound Proxy

Running on a home machine but still want a permanent IP whitelist (and skip repeated Google Authenticator confirmations)? Configure an Outbound Proxy — route Bitkub API traffic through a cheap VPS, then whitelist only the VPS IP on Bitkub. Go to http://localhost:18800/portfolios/bitkub, open your account card, and enter the proxy URL at the bottom. Bitkub supports http://, https://, socks5://, and socks5h:// schemes. See Outbound Proxy for IP Allowlisting for the full guide.

Read-only? Safe to Skip IP Whitelisting

If you configured the API key with View (Read) permission only (no Trade), it is safe to leave IP whitelisting off. A read-only key can only view your balance and market data — it cannot place or cancel orders. Your account remains secure enough without the IP lock, and you won't have to re-confirm with Google Authenticator every time your IP changes.

No Expiry Rule on Bitkub

Unlike OKX, Bitkub does not automatically expire API keys after inactivity. However, adding an IP whitelist is still recommended for Trade-enabled keys.


Step 7 — Save Your Keys

After creation, Bitkub shows:

  • API Key — your identifier (can be viewed later from the API list)
  • API Secret — ⚠️ Shown only once, then hidden forever

Copy both immediately and store in a password manager. If you lose the API Secret, you must delete this key and create a new one.


Step 8 — Add to KhunQuant

Recommended: Use the Web UI

Open KhunQuant's portfolio settings in your browser:

http://localhost:18800/portfolios/bitkub

Paste your API Key and API Secret into the form and click Save. KhunQuant automatically encrypts the values with enc:// prefix — you never need to touch any config files.

Why Not Edit the File Directly?

If your .security.yml already uses encrypted fields (enc:// prefix), pasting a plain API key directly into the file will cause an authentication error at startup. The web UI handles encryption automatically and avoids this problem.

Alternative: Manual file edit (advanced users only)

Open ~/.khunquant/.security.yml:

exchanges:
bitkub:
accounts:
- api_key: "paste_your_api_key_here"
secret: "paste_your_secret_key_here"

Open ~/.khunquant/config.json and enable Bitkub:

{
"exchanges": {
"bitkub": {
"enabled": true
}
}
}

Restart KhunQuant. Try:

  • "ดูยอดเงินใน Bitkub ของฉัน"
  • "What's my Bitkub balance?"
  • "Show BTC/THB price on Bitkub"

API Version Note

Bitkub uses V4 API. The old V1, V2, and V3 APIs were deprecated in March 2025. KhunQuant uses V4 by default — you don't need to configure anything special.


Troubleshooting

ProblemSolution
"Invalid API key"Check for extra spaces in your YAML file
"IP not whitelisted"Your home IP may have changed (common with ISP dynamic IP). Update the whitelist on Bitkub
Can't create API keyGoogle Authenticator must be set up and linked to your Bitkub account
"API Secret" lostNo recovery possible. Delete the key from Bitkub and create a new one