Skip to main content

BinanceTH API Setup (binance.th)

Connect KhunQuant to your Binance Thailand account for Thai baht crypto trading.

note

Binance Thailand (binance.th) is a completely separate exchange from Binance global (binance.com) — accounts, funds, and API keys are not shared between them.

← Back to Exchange Overview


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
Critical Safety Warning

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

  1. Log in to binance.th
  2. Click your profile icon (top-right corner)
  3. Select [API Management] from the dropdown
  4. 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:

  • KhunQuant
  • Portfolio-Tracker

You can use Thai characters too, e.g. บอทดูพอร์ต. Click Next.


Step 4 — Verify Your Identity

Complete the 2FA verification:

  1. Enter the 6-digit code from your authenticator app
  2. Click the confirmation link sent to your registered email

Step 5 — Set Permissions

Configure permissions as follows:

PermissionSettingReason
Enable ReadingONRequired to view balances and market data
Enable Spot TradingONRequired to place and cancel orders
❌ Enable FuturesOFFNot needed
Enable WithdrawalsOFF — NEVER ENABLECritical security risk
❌ Enable MarginOFFNot needed unless you use margin

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

  1. In the API key creation page, find the IP whitelist section
  2. Enter your IPv4 address
  3. Click Confirm
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, 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.

Read-only? Safe to Skip IP Whitelisting

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.

30-Day Deletion Rule

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.

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:
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

FeatureBinance (binance.com)BinanceTH (binance.th)
CurrencyUSD / USDTThai Baht (THB)
PairsBTC/USDT, ETH/USDT, etc.BTC/THB, ETH/THB, etc.
KYCInternational passportThai ID card
RegulationGlobalThailand SEC
Config keybinancebinanceth

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 whitelist
Key was deletedNo IP whitelist + 30 days inactive. Create a new key with whitelist