Skip to content

HTX

HaasOnline connects to HTX (spot), HTX COIN Swaps and HTX USDT Swaps. HTX was called Huobi until 2023, and HaasScript still uses its old code in market names (for example HUOBI_BTC_USDT_). The key needs the Trade permission, and it should be linked to HaasOnline's IP addresses: HTX deactivates a trading key that isn't linked to an IP after 90 days without use.

If you don't have an HTX account yet, sign up at HTX.

Obtaining the API Key

Log in to HTX, open the account menu at the top right and click API Management.

HTX account menu with API Management.

Under My API Keys, click Create API Key.

HTX API Management page with the Create API Key button.

HTX asks which type of key to create. Choose System generated. HaasOnline signs its requests with HMAC, which is what this type uses; a Self-generated (Ed25519) key does not work with HaasOnline.

HTX Select API Key Type dialog with System generated and Self-generated.

Configure the key

Fill in the Create API Key form:

  • Notes: any name that identifies the key (for example HaasOnline API).
  • Permission settings: tick Trade. Read-only is always on. Leave Withdraw unticked.
  • Link IP address or IP segment: paste the IP addresses shown in HaasOnline (or your server's IP on a self-hosted license, see below), separated by commas.
  • Trading Pairs: leave it unset, so the key can trade every pair. If you add pairs here, HaasOnline can only trade those.

HTX Create API Key form with a note, Read-only and Trade ticked, Withdraw unticked, linked IP addresses and Trading Pairs left unset.

Danger

Do not tick Withdraw. HaasOnline never needs it to trade for you, and a trading-only key limits what a leaked key could do.

Info

For the IP link:

  • On HaasOnline TradeServer Cloud, paste the addresses shown under IP addresses to whitelist in the HaasOnline account setup form (use its copy icon).
  • On a self-hosted TradeServer license, use the public IP address of your machine or server.

Click Create HMAC API.

Confirm and verify

HTX shows a Risk Reminder. Tick the boxes and click I understand.

HTX Risk Reminder with the confirmation boxes and the I understand button.

In Security Verification, enter the code HTX emails you and the code from your 2FA app, then click Confirm.

HTX Security Verification dialog with the email code and the 2FA code.

Copy the keys

Successfully Create shows the new key:

HTX Successfully Create dialog with the Access Key, Secret Key, Read-only and Trade permissions, and the linked IP addresses.

  • Access Key: goes in the HaasOnline Access key field.
  • Secret Key: goes in the HaasOnline Secret key field.

Danger

Copy both now. HTX shows the key only once. If you lose the Secret Key, delete the key and create a new one.

Adding the API to HaasOnline TradeServer Cloud

Log in to HaasOnline TradeServer Cloud and open Exchange Accounts from the user menu in the top right. The Adding an API to the Platform guide shows these first steps with screenshots.

  1. Click the + button at the bottom of the accounts list (on an empty page it reads Add account)
  2. Select Exchange account
  3. In Connect an exchange account, click HTX
  4. Under What should this account trade?, choose HTX for spot trading, or HTX COIN Swaps or HTX USDT Swaps under Derivatives, then click Continue with .... Each market is its own HaasOnline account, so repeat these steps with the same key to add another market.

    What should this account trade, with HTX under Spot and HTX COIN Swaps and HTX USDT Swaps under Derivatives.

  5. Enter an Account name, then paste the values from HTX:

    • Access key → the HTX Access Key
    • Secret key → the HTX Secret Key

    HTX account setup form with the IP whitelist, account name, access key and secret key fields.

    Info

    Check for spaces at the start and end of each value after you paste it. Stray spaces are a common cause of a failed key test.

  6. Click Test keys. When the test passes, click Save account

If the test fails, check that Trade is ticked and that the linked IP addresses match the ones shown in HaasOnline. For the swap markets, also make sure futures trading is open on your HTX account. If it still fails, contact Support.