Bitkub API Setup (bitkub.com)
Connect KhunQuant to your Bitkub account for Thai baht crypto trading — Thailand's largest domestic crypto exchange.
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
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.
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
- Log in to bitkub.com
- Click your profile icon (top-right corner)
- Select [Account] from the dropdown
- Click [API] in the left sidebar
- 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:
KhunQuantPortfolio-Tracker
Use only English letters, numbers, and hyphens.
Step 4 — Set Permissions
Configure permissions as follows:
| Permission | Setting | Reason |
|---|---|---|
| ✅ View (Read) | ON | Required to view balances and market data |
| ✅ Trade | ON | Required to place and cancel orders |
| ❌ Withdraw | OFF — NEVER ENABLE | Critical 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.
Step 6 — Set Up IP Whitelist (Recommended)
After key creation, you can add an IP whitelist to lock the key to your device:
- Find your newly created key in the API list
- Click [Edit] next to the key
- Find the "IP Whitelist" field
- Enter your IPv4 address — you can add up to 50 IP addresses per key
- 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).
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.
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.
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.
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.
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
| Problem | Solution |
|---|---|
| "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 key | Google Authenticator must be set up and linked to your Bitkub account |
| "API Secret" lost | No recovery possible. Delete the key from Bitkub and create a new one |
Related
- Exchange Overview — hub page and security.yml reference
- BinanceTH API Setup — another Thai baht crypto exchange
- Credential Encryption — encrypt your keys at rest