BinanceTH API Setup (binance.th)
Connect KhunQuant to your Binance Thailand account for Thai baht crypto trading.
Binance Thailand (binance.th) is a completely separate exchange from Binance global (binance.com) — accounts, funds, and API keys are not shared between them.
Before You Start
Make sure you have:
- A Binance Thailand account at binance.th
- Identity verification (KYC) completed with your Thai national ID
- Two-Factor Authentication (2FA) enabled — use an authenticator app
When creating your API key, never enable withdrawal permissions. KhunQuant only needs Read and Spot Trading access. Enabling withdrawals creates a critical security risk — anyone who obtains your key could drain your account.
Step 1 — Open API Management
- Log in to binance.th
- Click your profile icon (top-right corner)
- Select [API Management] from the dropdown
- Click [Create API]
Direct URL: binance.th/en/my/api-management
Step 2 — Choose Key Type
Select System-generated (the default option, simplest for most users). Click Next.
Step 3 — Name Your API Key
Enter a descriptive name. Examples:
KhunQuantPortfolio-Tracker
You can use Thai characters too, e.g. บอทดูพอร์ต. Click Next.
Step 4 — Verify Your Identity
Complete the 2FA verification:
- Enter the 6-digit code from your authenticator app
- Click the confirmation link sent to your registered email
Step 5 — Set Permissions
Configure permissions as follows:
| Permission | Setting | Reason |
|---|---|---|
| ✅ Enable Reading | ON | Required to view balances and market data |
| ✅ Enable Spot Trading | ON | Required to place and cancel orders |
| ❌ Enable Futures | OFF | Not needed |
| ❌ Enable Withdrawals | OFF — NEVER ENABLE | Critical security risk |
| ❌ Enable Margin | OFF | Not needed unless you use margin |
Step 6 — Set Up IP Whitelist (Recommended)
To find your IPv4 address: Go to https://whatismyipaddress.com/ and look for the IPv4 value (format: 171.96.x.x).
- In the API key creation page, find the IP whitelist section
- Enter your IPv4 address
- Click Confirm
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, Binance TH will reject your API key with an "IP not allowed" error. You will need to update the whitelist with your new IP.
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? Configure an Outbound Proxy — route BinanceTH API traffic through a cheap VPS, then whitelist only the VPS IP on BinanceTH. Go to http://localhost:18800/portfolios/binanceth, open your account card, and enter the proxy URL at the bottom. BinanceTH supports http://, https://, socks5://, and socks5h:// schemes. See Outbound Proxy for IP Allowlisting for the full guide.
If you configured the API key with Read permission only (no Spot Trading), 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 worry about updating it when your IP changes.
Without an IP whitelist, your API key will be automatically deleted if unused for 30 days. Adding a whitelist keeps the key active permanently.
Step 7 — Save Your Keys
After saving, you will see:
- API Key — your identifier (can be viewed later from API Management)
- Secret Key — ⚠️ Shown only once, then hidden forever
Copy both keys immediately and store in a password manager. If you lose the Secret Key, 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/binanceth
Paste your API Key and Secret Key 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:
binanceth:
accounts:
- api_key: "paste_your_api_key_here"
secret: "paste_your_secret_key_here"
Open ~/.khunquant/config.json and enable BinanceTH:
{
"exchanges": {
"binanceth": {
"enabled": true
}
}
}
Restart KhunQuant. Try:
- "ดูยอดเงินใน Binance TH ของฉัน"
- "What's my BinanceTH balance?"
- "Show BTC/THB price"
Difference Between Binance and BinanceTH
| Feature | Binance (binance.com) | BinanceTH (binance.th) |
|---|---|---|
| Currency | USD / USDT | Thai Baht (THB) |
| Pairs | BTC/USDT, ETH/USDT, etc. | BTC/THB, ETH/THB, etc. |
| KYC | International passport | Thai ID card |
| Regulation | Global | Thailand SEC |
| Config key | binance | binanceth |
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 whitelist |
| Key was deleted | No IP whitelist + 30 days inactive. Create a new key with whitelist |
Related
- Exchange Overview — hub page and security.yml reference
- Binance API Setup — for global Binance (different exchange)
- Credential Encryption — encrypt your keys at rest