Skip to main content

Creating a BitMEX API Key

This guide walks you through creating an API key on BitMEX for automated trading. Follow these steps to ensure secure and efficient bot operation on your account.

Info

BitMEX is a peer-to-peer cryptocurrency derivatives trading platform. API keys enable trading bots to programmatically access your account for automated trading strategies.

Step-by-Step Guide to API Key Creation​

  1. Log into BitMEX: Access your BitMEX account and verify that two-factor authentication (2FA) is properly configured for enhanced security.

  2. Navigate to API Keys: Find the 'API Keys' section, usually located under your account name or in the security settings. This is where you will manage all your API connections.

  3. Initiate API Key Creation: Select 'Create New API Key' or a similar option to begin the setup process. Your new key (consisting of an ID and a Secret) will serve as your bot's secure access point to BitMEX.

  4. Name Your API Key (CIDR):

    • Set a clear, descriptive name (CIDR on BitMEX) that helps identify the key's purpose, for example, "Gunbot_XBTUSD_Strategy".
    • Good naming helps manage multiple API keys effectively if you use different bots or strategies.
  5. Configure API Key Permissions: Enable only the essential permissions:

    • Order: Allows placing and canceling orders. This is typically required.
    • Position: Allows viewing of your current positions.
    • Optionally, 'Order Cancel' if you need a key that can only cancel orders but not create new ones (less common for full trading bots).
    • Crucially, do NOT select 'Withdraw' permission. This is a vital security measure. Keep permissions minimal for optimal security.
  6. IP Whitelisting (Highly Recommended):

    • For enhanced security, use the 'CIDR' field to restrict API key access to your bot's static IP address. Enter your bot's IP address here (e.g., 123.45.67.89/32). If you have a range, specify accordingly.
    • This step significantly helps prevent unauthorized access if your API key is compromised.
  7. Finalize API Key Setup:

    • Review all settings, especially permissions and IP restrictions (CIDR).
    • Verify permissions are appropriate for your bot's needs.
    • Complete any required 2FA steps to confirm the key creation.
    • Securely store your API Key ID and Secret. The Secret is shown only once.

BitMEX API key creation interface with trading permissions and security settings

You can usually access your API settings directly through BitMEX API Management.

A well-configured API key is essential for secure automated trading. Regular security audits of your API keys help maintain account safety. Remember to never share your API credentials and always use secure channels when setting up your trading bot.