How to Create a Binance API Key
What Is an API Key
An API (Application Programming Interface) key is a pair of keys generated by Binance, consisting of an API Key and a Secret Key. Through API keys, third-party applications or your own programs can securely connect to your Binance account to perform actions like viewing account information and placing trades, without needing to log into the Binance website directly.
API keys are widely used in the following scenarios:
- Quantitative trading: Executing strategies automatically through trading bots
- Portfolio management: Connecting third-party asset tracking tools
- Data analysis: Accessing market data and trading history
- Tax reporting: Connecting cryptocurrency tax calculation tools
Prerequisites for Creating an API Key
Before creating an API key, make sure you have:
- Completed identity verification (KYC)
- Enabled two-factor authentication (2FA)
- A clear understanding of why you need the API and what permissions are required
Steps to Create an API Key
Creating on the Binance APP
- Open the Binance APP
- Tap the profile icon in the top left > "Security"
- Find the "API Management" option
- Tap "Create API"
- Choose the API type:
- System-generated API key: Standard key pair
- Self-generated API key (Ed25519 or RSA): For advanced users
- Enter a label/name for the API (e.g., "Quant Trading Bot")
- Complete security verification (Google Authenticator + email code + SMS code)
- The system generates the API Key and Secret Key
Creating on the Binance Website
- Log into the Binance website
- Click the profile icon in the top right > "API Management"
- Enter an API label name
- Click "Create API"
- Complete security verification
- Obtain the API Key and Secret Key
Saving the Keys (Extremely Important)
The Secret Key is only displayed once! After creation, you must immediately save the Secret Key in a secure location:
- Use an encrypted password manager
- Write it down and store in a secure location
- Don't store it in plaintext within code
- Don't send it via email or chat tools
If the Secret Key is lost, you can only delete the current API and create a new one.
Configuring API Permissions
After creating the API, you need to configure permissions based on your usage needs. Permission settings should follow the principle of least privilege — only enable the permissions you actually need.
Available Permission Descriptions
| Permission | Function | Risk Level | Recommendation |
|---|---|---|---|
| Read Info | View account balance, trading records | Low | Enable as needed |
| Spot Trading | Place orders on the spot market | Medium | Required for quantitative trading |
| Futures Trading | Place orders on the futures market | High | Required for futures bots |
| Withdrawal | Allow cryptocurrency withdrawal via API | Very High | Strongly discouraged |
| Margin Trading | Use leverage features | High | Enable as needed |
Permission Configuration Recommendations
Read-only (Safest):
- Enable: Read Info
- Suitable for: Asset tracking tools, tax reporting
Trading Use:
- Enable: Read Info + Spot Trading
- Suitable for: Quantitative trading bots
Absolutely Avoid:
- Don't enable withdrawal permissions unless you fully understand the risks and genuinely need it
- Enabling withdrawal permissions means that if the API is leaked, funds could be transferred out
Setting Up IP Whitelist (Strongly Recommended)
An IP whitelist is a critical security measure for API protection. Once set, only requests from specified IP addresses will be accepted.
Setup Method
- On the API Management page, find the created API
- Click "Edit Restrictions"
- Select "Restrict access to trusted IPs only"
- Enter the public IP address of your server or computer
- Save the settings
IP Whitelist Notes
- If you use residential broadband, your IP may change and need periodic updates
- Cloud servers (like AWS, Alibaba Cloud) for running trading bots have relatively stable IPs
- You can add multiple IP addresses
- Without an IP whitelist, the API may be restricted to read-only permissions
API Key Security Management
1. Don't Expose API Keys
- Don't publish code containing API keys on platforms like GitHub
- Use environment variables or configuration files to store keys
- Don't share keys on public forums or social media
2. Use Environment Variables
Reference API keys via environment variables in code, rather than writing them directly:
# Good practice
API_KEY = os.environ.get('BINANCE_API_KEY')
# Bad practice
API_KEY = 'your_actual_api_key_here'
3. Rotate Keys Regularly
It's recommended to replace API keys every 3-6 months:
- Create a new API key
- Update all applications using the old key
- Confirm the new key works properly
- Delete the old API key
4. Monitor API Activity
Regularly check the API Management page for:
- Whether API call frequency is normal
- Whether there are unusual trading operations
- Whether there's access from unknown IPs
5. Set Trading Limits
If the API is used for trading, you can set the following in third-party tools:
- Maximum amount per trade
- Daily trade count limits
- Stop-loss protection
Deleting an API Key
If you no longer need an API key, or suspect it has been leaked, delete it immediately:
- Go to the API Management page
- Find the API to delete
- Click "Delete"
- Complete security verification
- The API is immediately invalidated
FAQs
Q: Is there a limit on the number of API keys? A: Yes, Binance typically limits each account to a maximum of 30 API keys. It's recommended to create different API keys for different purposes.
Q: Do API keys expire? A: API keys don't automatically expire unless you manually delete them or Binance disables them for security reasons. However, periodic replacement is recommended.
Q: Are there fee discounts for API trading? A: API trading fees are the same as regular trading, depending on your VIP level and whether you use BNB for fee deduction.
Q: What if I forgot my Secret Key? A: The Secret Key cannot be recovered. You'll need to delete the current API and create a new one.
Register on Binance now and get 20% fee discount forever
Sign up through BinanceHelper's exclusive link to automatically enjoy fee discounts