API Key

To let a bot, tax tool or portfolio app talk to your exchange account, you create an API key — a credential that works without your password. Grant the narrowest rights the tool needs, never withdrawal rights, and lock the key to specific IP addresses.

An API key is how software logs in to your exchange account on your behalf. Trading bots, portfolio trackers and tax tools all use one, and none of them needs your password. That convenience is also the risk: a key is a set of permissions that works for whoever holds it. This entry explains how API keys work, which permissions to grant, how IP restrictions and expiry dates protect you, and what to do if a key leaks.

Category
Cryptocurrency and Blockchain
Reading time
6 min
Also called
API keys, API secret, Exchange API key
Updated

API keys in plain words

An API key usually comes as a pair: a public key that identifies you and a private or secret part that signs each request. Exchanges advise treating both like your username and password and storing them in a password manager rather than in plain text.1

Each key carries its own permissions. On one large exchange, for example, rights are split into funds (query, deposit, withdraw), orders and trades (query, place, cancel) and data (ledger and exports), and a key for a third-party trading tool does not need withdrawal rights.1

Keys can also be limited to certain IP addresses and given an expiry date, so a stolen copy is useless from another computer or after a set time.1 Another exchange warns that a secret with transfer permission could let someone move funds out of your account.2

How to set up an API key safely, step by step

  1. Decide what the tool must do

    Read-only data, trading, or (rarely) transfers.

  2. Create the key in your account

    Usually under settings, in an API section.1

  3. Tick only the needed rights

    Give only the access a credential needs.3

  4. Leave withdrawals off

    A trading bot can trade without moving funds out.1

  5. Restrict to IP addresses

    Lock the key to the server the tool runs on.1

  6. Set an expiry date

    A key that ends on its own limits forgotten access.1

  7. Store the secret safely

    Use a password or secrets manager, never your code.2

Worked examples

Example 1 — A key for a tax tool

Read-only

Hypothetical: a tax app needs your trade history to prepare a report.

Example 1 — A key for a tax tool — calculation
Query balances and tradesOn
Export dataOn
Place ordersOff
Withdraw fundsOff

A read-only key gives the tool the data it needs and nothing it could misuse.

Example 2 — A key for a trading bot

Limited exposure

Hypothetical: you run a bot in a separate sub-account holding $2,000 of your $10,000 on the exchange.

Example 2 — A key for a trading bot — calculation
RightsQuery + trade, no withdraw
IP restrictionThe bot’s server only
Funds the key can trade$2,000
Share of total$2,000 ÷ $10,000 = 20%

Isolating the bot means a bug or a leaked key can touch at most 20% of the balance. See Trading Bots.

Example 3 — A leaked key

Damage depends on rights

Hypothetical: a secret is pushed to a public code repository. The account holds $8,000.

Example 3 — A leaked key — calculation
Key with withdraw rightsUp to $8,000 at risk
Read-only keyData exposed, funds safe
First step either wayDelete the key, make a new one

If a credential leaks, create a new one, replace the old one wherever it is used, and delete the compromised one.3

Password vs. API key

AspectAccount passwordAPI key
Used byYou, in the app or websiteSoftware acting for you
AccessEverything in the accountOnly the rights you tick
Location limitsRarelyCan be locked to IP addresses
If leakedChange it, secure the accountDelete it and create a new key

Why API keys matter

  • Trading bots

    Bots place orders through a key, not a login. See Trading Bots.

  • Portfolio and tax tools

    Read-only keys pull balances and trade history.

  • Separating strategies

    A key per sub-account keeps mistakes contained. See Sub-Account.

  • Scam awareness

    Anyone who asks for a key with withdrawal rights should be treated as a thief.

Advantages and disadvantages

Advantages

  • Tools can work without your account password.
  • Permissions can be limited to exactly what a tool needs.
  • IP restrictions and expiry dates shrink the damage from a leak.
  • A key can be deleted at once without touching your login.

Disadvantages

  • A key works for whoever holds it.
  • Keys with withdrawal rights can empty an account.
  • Secrets are easy to leak in code, chats or screenshots.
  • Every connected tool is another party you must trust.

Going deeper

Read as far as you need. Each level builds on the one before it.

Never share a secret

Beginner

Do not paste a secret into email or chat, and never commit it to a code repository, even a private one.3 Anyone asking for your secret in a support chat is not support. See Social Engineering.

IP restrictions as a gatekeeper

Intermediate

Some exchanges build restrictions into the key itself. On Binance, a system-generated key without IP restrictions can only read data, and adding an IP restriction is mandatory before withdrawal permission can be switched on.4

Kraken lets you restrict a key to client IP addresses and set an expiry, and it supports adding a second factor to an existing key if your software can handle it.1

Key types and secret storage

Advanced

Exchanges differ in how keys sign requests. Binance offers system-generated HMAC keys and self-generated Ed25519 or RSA key pairs, where you keep the private key and give the exchange only the public one.4 Coinbase requires ECDSA keys for its app API.2

Keep secrets out of source code: Coinbase recommends environment variables, and GitHub recommends a secrets manager plus scanning repositories to block pushes that contain secrets.23

Common mistakes

  1. Ticking every permission

    Grant only the access a credential needs.3

  2. Enabling withdrawals for a bot

    A third-party trading tool does not need them.1

  3. Keys without IP limits or expiry

    A copied key then works from anywhere, forever.

  4. Secrets in code or screenshots

    Keep them out of repositories and chats.3

Check your understanding

Test yourself before moving on. Each answer comes with an explanation.

Q1Which permission should a key for a portfolio tracker have?
Q2Your bot runs in a sub-account holding $3,000 of a $12,000 balance. What share can the bot’s key trade?

Key points to remember

  1. An API key lets software use your exchange account without your password.
  2. Each key has its own permissions; grant the minimum the tool needs.
  3. Leave withdrawal rights off for bots and data tools.
  4. Lock keys to IP addresses and give them an expiry date.
  5. If a key leaks, delete it and create a new one at once.

Frequently asked questions

Is an API key the same as my password?

No. It is a separate credential with its own limited rights, but it should be protected like a password.1

Does a trading bot need withdrawal permission?

No. A key for a third-party trading tool does not need withdrawal rights.1

What should I do if I think a key leaked?

Delete it, create a new one, update the tools that used it and check the account for activity you did not make.3

Further learning

Sources

This article is written in our own words. The sources below support the specific facts, rules and figures marked with a number in the text. Links open the original publisher’s page.

  1. Kraken. How to create an API key on Kraken Pro (opens in a new tab) Checked .
  2. Coinbase. Coinbase App API Key Authentication (opens in a new tab) Checked .
  3. GitHub Docs. Keeping your API credentials secure (opens in a new tab) Checked .
  4. Binance. How to Create API Keys on Binance? (opens in a new tab) Checked .

Educational content, not financial advice. Examples use hypothetical prices and simplified costs; actual fees, margin rules and regulations vary by broker, market and country. We are not affiliated with any publisher linked above. Last reviewed . Report an error or request a source credit.