Skip to main content

Creating an Alpaca API Key for Trading Stocks, ETFs, and Crypto

This guide walks you through setting up API access for Alpaca, a multi-asset broker supporting stocks, currencies, and crypto. You will learn how to generate API credentials and connect them to your trading bot, such as Gunbot, using its graphical user interface (GUI).

Info

Alpaca is a commission-free brokerage platform that provides API access for developers and traders to build applications and automated trading strategies for stocks, ETFs, and cryptocurrencies.


Generating Your Alpaca API Credentials​

  1. Log in to your Alpaca account at https://app.alpaca.markets.
  2. Scroll down to the API Keys section, typically found on the bottom right of your dashboard.
  3. Click Generate New Keys.

Your API Key ID and Secret Key will be shown only once upon generation. Save both securely in a password manager or other secure location before leaving or refreshing the page.

Alpaca API Key screen


Configuring Your Trading Bot​

Set up your bot directly in its GUI using your Alpaca credentials:

  1. Access Settings: Open your trading bot’s Exchange configuration section.
  2. Enter Credentials:
    • API Key: Enter your Alpaca API Key ID.
    • API Secret: Enter your Alpaca Secret Key.
  3. Save Exchange: Confirm your exchange setup in the bot and proceed to configure your trading settings.

Gunbot Alpaca API Form


Verification Steps for a Successful Connection​

Complete these final checks to ensure a working connection:

  1. Save Configuration:

    • Make sure your API Key ID and Secret Key were saved successfully in your trading bot.
  2. Test Connection:

    • Add a trading symbol relevant to Alpaca (e.g., USD-TSLA for Tesla stock, or a crypto pair like BTC/USD).
    • Start a trading session or test connection feature if available.
    • Monitor for successful price updates and correct balance display in your bot.

Important Notes​

  • You can trade stocks, ETFs, or crypto from the same Alpaca account using these API keys.
  • Always protect your Secret Key and avoid exposing it in public repositories or shared files.
  • Consider using Alpaca's Paper Trading mode for testing your bot and strategies before committing real funds to live accounts.

For more detailed information, visit the official Alpaca API Documentation.