Built into AlgoGPFree
BrokerMarket dataStocksETFsCrypto API key

Alpaca API guide

Alpaca is a US broker built API-first: there is no trading desk to call, every account is driven through REST and WebSocket endpoints, and every account comes with a free paper-trading twin. That makes it the most common first broker for people automating a stock or crypto strategy.

Last verified

Quick answer

Alpaca is an API-first US broker for stocks, ETFs, options and crypto. You authenticate with two headers (APCA-API-KEY-ID and APCA-API-SECRET-KEY), every account has a free paper-trading twin at paper-api.alpaca.markets, and the free Basic data plan includes real-time IEX quotes and history back to 2016. Paper and live accounts use separate keys.

Alpaca API at a glance

Pricing
Free account; free IEX market data plan
Availability
US and most international residents
Paper trading
Paper trading account with simulated fills
Integration type
REST + API key
In AlgoGP
Built in: broker and data adapter (Free)
Trading API
paper-api.alpaca.markets / api.alpaca.markets
Market data API
data.alpaca.markets (stocks, crypto, news)
Auth
Key id + secret in APCA-API-KEY-ID / APCA-API-SECRET-KEY headers
Order types
Market, limit, stop, stop-limit, trailing stop, brackets, OCO

What Alpaca is and who it suits

Alpaca Securities is a FINRA member broker-dealer (SIPC) offering commission-free trading in US-listed stocks and ETFs, fractional shares, and spot crypto through Alpaca Crypto. It has no desktop platform to speak of: the product is the API, which is why it is so popular with developers, quant hobbyists and fintech apps.

  • Good fit: daily or intraday strategies on US equities, ETFs and major crypto pairs; anyone who wants paper trading that behaves like the live account.
  • Less suited: forex, futures or non-US equities (not offered), and high-frequency strategies that need co-location.

Paper vs live: two accounts, two key pairs

Every Alpaca user gets a paper account with simulated cash that can be reset at any time. Paper and live accounts have separate API keys and separate base URLs: paper keys only work against https://paper-api.alpaca.markets and live keys only against https://api.alpaca.markets. Mixing them is the single most common cause of a 401 Unauthorized or 403 Forbidden response.

Alpaca market data plans

The same key pair also authenticates the Market Data API. The free Basic plan streams real-time IEX quotes for up to 30 WebSocket symbols, serves historical stock bars back to 2016 and allows about 200 historical calls per minute. Algo Trader Plus ($99/month) adds all US exchanges (SIP), unlimited WebSocket symbols and up to 10,000 historical calls per minute. Crypto data is free on every plan.

EndpointUse
GET /v2/stocks/barsHistorical stock and ETF bars (1Min to 1Month)
GET /v1beta3/crypto/us/barsHistorical crypto bars, e.g. BTC/USD
GET /v2/accountCash, equity and buying power
POST /v2/ordersSubmit an order
GET /v2/positionsOpen positions

Rate limits and practical limits

The trading API allows about 200 requests per minute per account, and returns 429 Too Many Requests beyond that. A bar-close strategy that checks once per bar is nowhere near the limit; a loop that polls every second for many symbols can be. Stocks trade only in US market hours (plus extended hours for limit orders); crypto trades around the clock.

  • Alpaca moved to FINRA’s new intraday-margin framework on June 4, 2026, replacing its old pattern-day-trader handling; older guides quoting the $25,000 PDT rule as an Alpaca limit are out of date.
  • Crypto orders support gtc and ioc time-in-force; stock market orders are usually day.
  • Fractional orders are market or limit orders during regular hours only.

Use Alpaca in AlgoGP

Open a project, go to the APIs & keys tab and, under Platforms, pick Alpaca as the market data source (market_data.py) and the broker (brokers.py). The choice is saved to config.json as a new strategy version:

{
  "platforms": {
    "data": "alpaca",
    "broker": "alpaca"
  }
}
In-app backtests always use AlgoGP’s normalized history so results stay comparable; this choice decides what backtest.py and live.py connect to when you run the exported code.
KeyWhat it is
ALPACA_API_KEY_IDAlpaca API key id (paper or live), from the Alpaca dashboard.
ALPACA_API_SECRET_KEYAlpaca API secret key; shown once when the key is generated.
ALPACA_BASE_URL (optional)Optional override. Sandbox mode uses https://paper-api.alpaca.markets, live mode https://api.alpaca.markets.
Names the generated code reads. Add values under Keys & secrets or in a local .env.
  • TRADING_MODE=paper (default): simulated fills on your machine; the broker is never contacted.
  • TRADING_MODE=sandbox: orders go to Alpaca’s paper trading account with simulated fills.
  • TRADING_MODE=live: real orders, and only once LIVE_TRADING_ACKNOWLEDGED=yes is set.

New to Alpaca? Follow the step-by-step Alpaca API key guide.

Alpaca API: frequently asked questions

Is the Alpaca API free?

Yes. Opening an account, paper trading and the basic market data plan are free, and US stock and ETF trades are commission-free. Paid market data and regulatory fees on sells are the main costs.

Can I paper trade with Alpaca without funding an account?

Yes. A paper account is created with every signup and never needs funding. Generate paper keys from the paper dashboard and point your code at https://paper-api.alpaca.markets.

Does Alpaca support crypto through the same API?

Yes. Crypto pairs such as BTC/USD use the same orders, positions and account endpoints, trade 24/7, and their market data is free.

Can I trade from outside the US?

Alpaca accepts residents of many countries for brokerage accounts; availability, especially for crypto, varies by jurisdiction. Check the signup flow for your country.

Build an Alpaca trading bot in minutes

Describe the strategy in plain English, backtest it on years of data, then export Python that already talks to Alpaca: paper, sandbox and live modes, keys handled for you.

  • Generated adapter for Alpaca orders and balances
  • Backtests with costs, slippage and walk-forward checks
  • Paper first; live trading only after you opt in

Free plan, no card required.

Alpaca alternatives

Independent guide. AlgoGP is not affiliated with Alpaca. Limits, prices and availability change; confirm them in the official documentation. Nothing here is investment advice.