How to connect a Binance API key to a bot

Updated:

In short, here is how to connect a Binance API key to a bot: create an API key on the exchange with permission to trade futures and without the withdrawal permission, then paste it into the service's settings. Without a key the bots do nothing, because they have nothing to trade with. The whole thing takes a few minutes.

What an API key is and why it is safe if done right

An API key is a pair of strings: the "API Key" (the public part) and the "Secret" (the private part). They let a program place orders in your name without knowing your account password. You choose the key's permissions yourself. The service checks them on Binance when you connect and refuses the key if it can withdraw funds. So even if the key ever falls into the wrong hands, it cannot be used to withdraw money.

The key is stored encrypted. The service decrypts it only inside the process that places orders.

Step 1. Prepare your futures account

Make sure you have a USDT-M futures account open on Binance and that it holds the USDT you are ready to use. Without a futures account the key will not pass the check.

Use a separate account or sub-account

The best key to connect belongs to an account where only the bot trades: a separate Binance account or a sub-account of your main one. Transfer there only the amount you are ready to entrust to the bot, and let nothing else reach it: no manual trading, no other bots. Here is why:

  • Shared margin. On cross margin every position on the account shares one balance. A manual trade or another bot can eat into the bot's margin, and a loss by the bot reduces the cushion under your own trades. Liquidation can then come before the stop fires.
  • The bot cannot tell what is not its own. After a restart the service checks itself against the exchange. A position that is not on its list it treats as abandoned, and it may put an emergency stop on it that closes it if the price moves against it.
  • Per-coin settings. The bot sets leverage and margin mode itself on the coins it trades. On the exchange that applies to the whole account for that coin, including your manual positions.
  • Clear bookkeeping. All trades and the whole balance on such an account belong to the bot, so the Trades page is easy to compare with your Binance statement.

How to create a sub-account depends on your account type on the exchange: look for the sub-account management section on Binance, and remember to enable futures for it.

Step 2. Create the key on Binance

  1. In your Binance account, open API key management (the API Management section).
  2. Create a new key and give it a recognizable name.
  3. Confirm the creation with the exchange's requirements (a code from the app, email and so on).
  4. Save the Secret right away: Binance shows it only once.

Button and section names on the exchange can change, so go by the meaning.

Step 3. Set the permissions

In the key's settings (on Binance, "Edit restrictions"):

  • "Enable Futures": turn on. Without this permission the service will say the key is not allowed to trade futures.
  • "Enable Withdrawals": turn off. If it is on, the service rejects the key and tells you it can withdraw funds.
  • Permission to trade on spot is not needed for the bot to work.
  • IP restriction: on Binance this is "Restrict access to trusted IPs only". The service interface itself recommends adding the server IP to the allowlist so a stolen key would not work from another machine. It is not required to connect, but it adds security. You must add the address of the machine the service uses to reach Binance. If you do not know it, it is better to leave the restriction off than to enter a wrong address: then the key will not work at all.

Step 4. Paste the key in the service

  1. In the menu, open "Settings".
  2. Find the "Binance key" block.
  3. In the "API Key" field, paste the public part of the key.
  4. In the "Secret" field, paste the secret.
  5. Press "Verify and connect".

If everything is fine, the block shows "Key connected", the key's name and the time of the check.

What the check does

The service makes several requests to Binance. The first proves that the key works and futures are available, and checks that trading is not blocked on the account. The second reads the key's own permissions. If a response cannot be obtained, the key is not saved: without a response the service cannot promise the key has no withdrawal permission.

If the key is not accepted

Message (in meaning) What to do
The exchange did not accept the key Check that you copied the key and secret in full, without spaces, and that the key has not been revoked. If an IP restriction is on, check that the server's address is in the list.
The exchange has forbidden trading on this account Check the account status on Binance.
The key can withdraw funds Turn off "Enable Withdrawals" in the key and try again.
The key is not allowed to trade futures Turn on "Enable Futures" in the key.
Could not check the key's permissions This is a failed request to the exchange: try again in a few minutes. The key was not saved.

Test exchange

If the service is running in test mode, the form has the checkbox "this is a testnet key". For the test exchange you take a key separately at testnet.binancefuture.com; the permissions there are fixed and cannot be changed, and there is nothing to withdraw, so the three points above (futures, withdrawals, IP) are not needed for it. The checkbox must match the service's mode: otherwise the key is saved but every order will be rejected. The Bots page shows a warning if the key is not from the exchange the service is running on.

Replacing and disconnecting

  • Replace the key. Connect a new one in the same block. The previous one is revoked automatically.
  • "Disconnect". The button next to the key entry. It switches off all your bots, because without a key they cannot trade. Positions that are already open on the exchange do not go anywhere: watch them on Binance.
  • If you suspect a leak, the most reliable thing is to delete the key on Binance itself: it stops working immediately.

What next

The next steps are usually to connect Telegram to receive messages about trades and to create your first bot. Remember that trading futures with leverage is risky and that the key gives the bot the right to open trades on your account; for a sober way to think about that, read do crypto trading bots work.

Frequently asked questions

What permissions does a Binance API key need for a bot?

It needs permission to trade futures ("Enable Futures"). The withdrawal permission ("Enable Withdrawals") must be off: the service does not accept a key that has it.

Why does the service reject a key with withdrawal permission?

So that even if the key leaks, it cannot be used to withdraw your money. In the worst case someone could trade, but not take your funds out.

Where do I get an API key on Binance?

In your Binance account, open API Management, create a new key, enable futures and keep withdrawals off. The secret is shown only once, so save it right away.

How do I replace my key with a new one?

Just connect the new key in the same block: the service revokes the previous one itself. The Disconnect button, on the other hand, switches off all your bots.

Can I connect an account where I also trade by hand?

Technically yes, but it is better not to. Manual trades and other bots share one margin with the bot, and a position the bot did not open may be taken for an abandoned one and get an emergency stop. It is safer to use a separate account or sub-account for the bot alone.

Read also