Jay Rocco is the Founder and Editor of FullStack Alpha. He has tested 200+ AI stock tools since 2022 and run 15+ AI trading platforms on live accounts with his own money. He reviews the software. He does not tell you what stocks to buy.
Quick Answer
The Alpaca API for beginners comes down to five steps: sign up with an email, generate paper trading keys in the dashboard, install the alpaca-py library (Python 3.10 or newer), connect a TradingClient with paper=True, and submit a one-share test order. Paper trading is free, starts with a $100,000 simulated balance, and runs on its own host, paper-api.alpaca.markets, with separate keys from live trading on api.alpaca.markets. The free Basic data plan gives you real-time IEX quotes and 200 historical data calls a minute; full-market SIP data is $99 a month. The trap for beginners is trusting paper fills: Alpaca says its simulator ignores slippage, market impact and dividends.[4][11][12]
It connects your code to a real brokerage account for stocks, ETFs, options, and crypto, with no phone calls to a broker and no minimum balance to start testing. We use it as the default first broker in our bot builds on AI Stock Trading Bots. This article is education, not personalized investment advice, and nothing here promises returns.
On AI Stock Trading Bots: go deeper in our Broker APIs guide, and see How We Test for the method behind every score.
Key Takeaways
- The Alpaca API connects your code (Python or any language that can make HTTP calls) to a real brokerage account covering stocks, ETFs, options, and crypto.[8]
- Every private API call needs two headers:
APCA-API-KEY-IDandAPCA-API-SECRET-KEY. Paper and live keys are separate; live credentials don’t work on the paper API, or vice versa.[7][11] - Paper trading is free for every user, opens with $100,000 by default, and anyone globally can open a Paper Only Account with just an email address.[4]
- Moving from paper to live later means swapping the base URL and the keys. Alpaca says the API spec is the same, so the strategy code doesn’t need a rewrite.[4]
- Alpaca’s official Python library is alpaca-py (version 0.44.0 on PyPI as of October 2026, Python 3.10+), and the core object for sending orders is
TradingClient.[9][13] - Paper trade it first. Weeks of clean simulated fills beat one lucky real trade you can’t explain.
What Is the Alpaca API and How Does It Work?
It’s a set of programming tools that let your own code place stock, ETF, options, and crypto orders through a real brokerage, instead of you clicking buttons in an app. It works like a translator: you write a request in code (“buy 5 shares of X”), the API converts it into a brokerage order, and Alpaca’s Trading API routes it to the market.[8]
That’s the whole pitch. No trading desk, no minimum balance to start testing, no waiting on hold with a broker rep.
There are three hosts to know. Trading calls go to paper-api.alpaca.markets (paper) or api.alpaca.markets (live). Market data goes to data.alpaca.markets for both.[11]
Alpaca’s own onboarding path is blunt about the order of operations: create a free account, find your keys in the dashboard, install the official SDK (software development kit, a pre-built code library that does the heavy lifting), then submit your first order.[10] That’s four steps, not forty.
Practical takeaway: if you’ve never written a line of trading code, start with the free AI stock trading bots beginners keep flocking to to see what’s possible before you touch raw API calls.
How Do You Get Your Alpaca API Keys?

You get your keys from the dashboard after creating a free account: generate them under the Paper Trading environment first, and Alpaca gives you a Key ID and a Secret Key as a pair.[5][3]
The Key ID (APCA-API-KEY-ID) is your public account identifier, similar to a username. The Secret Key (APCA-API-SECRET-KEY) is the private password that proves the request actually came from you.[5][7]
Here’s the setup flow in order:
- Register a free Alpaca account. A Paper Only Account needs only an email address.[3][4]
- Confirm the dashboard is set to Paper Trading mode, not live. The paper dashboard lives at app.alpaca.markets/paper/dashboard/overview.
- Open the API Keys panel on the right sidebar and generate a new key pair.[1][12]
- Copy both values immediately. The secret key is shown once.
- Store them as environment variables, never as text pasted into your script.[5]
Common mistake: generating live keys by accident because the dashboard defaulted to the wrong environment. Check the toggle before you click generate. Our Alpaca API keys guide covers storage and rotation in more depth.
How Do You Set Up Alpaca API Authentication as a Beginner?
Authentication just means proving your code is allowed to talk to your account, and Alpaca does this with two HTTP headers on every private request: APCA-API-KEY-ID and APCA-API-SECRET-KEY. HTTP Basic auth (key ID as username, secret as password) also works.[7][11]
Every request that touches your orders, positions, or account balance has to carry the credentials. Market data needs them too; Alpaca’s docs say all market data endpoints require authentication except historical crypto data.[12]
In practice, most beginners never touch raw headers directly. The official SDK handles it: you pass your key and secret into a client object once, and the library attaches the headers to every call automatically.[9][2]
Install it first (alpaca-py requires Python 3.10 or newer):[13]
pip install alpaca-py
A typical Python pattern looks like this:
import os
from alpaca.trading.client import TradingClient
trading_client = TradingClient(
os.environ["APCA_API_KEY_ID"],
os.environ["APCA_API_SECRET_KEY"],
paper=True,
)
account = trading_client.get_account()
print(account.account_number, account.buying_power)
That paper=True flag is the single most important line in the whole setup. It’s the difference between a test and a real trade.[9]
Decision rule: if you’re not 100% sure which environment you’re pointed at, print the account number and compare it with the paper account number shown at the top left of your paper dashboard before submitting anything. Match means paper. No match means stop.
Alpaca API Paper Trading vs Live Trading: What Actually Changes?

Paper trading simulates real market fills using fake money on a separate server. Live trading sends real orders backed by real cash. Alpaca keeps these completely separate, with different endpoints and different keys, so a coding mistake in testing can’t accidentally cost you money.[4]
A dedicated Paper Only Account exists specifically for simulation, and it uses its own base URL, https://paper-api.alpaca.markets, usually set through an environment variable called APCA_API_BASE_URL.[4][7] Live trading uses https://api.alpaca.markets.[11]
Here’s the side-by-side:
| Paper Trading | Live Trading | |
|---|---|---|
| Endpoint | paper-api.alpaca.markets | api.alpaca.markets[11] |
| Cost | Free for every user[4] | Depends on account and any margin |
| Money at risk | None, simulated fills | Real capital |
| Data | Free real-time IEX data on the Basic plan[4] | Same Basic plan by default; $99/month Algo Trader Plus for all US exchanges[12] |
| Approval needed | None beyond signup[1] | Full brokerage account approval[3] |
| Reset capability | Create a new paper account or delete an old one from the dashboard; new keys required[4] | Cannot undo a filled order |
Practical takeaway: the code you write for paper trading is close to identical to live code. Change the base URL, swap in live keys, and you’re running for real. That’s by design.[4]
What Does Alpaca Paper Trading Not Simulate?
This is the section most Alpaca API for beginners tutorials skip, and it’s the one that decides whether your paper results mean anything. Alpaca lists what its simulator leaves out:[4]
- Market impact of your orders, and information leakage
- Price slippage due to latency
- Order queue position for non-marketable limit orders
- Price improvement, regulatory fees, and dividends
- Order fill emails (none are sent)
Two fill rules matter even more. Your order size is not checked against the quantity actually available at the NBBO, so a 10,000-share order can fill in paper where it never would live. And when an order is eligible to fill, it gets a random partial fill 10% of the time.[4]
What breaks in practice: a bot that trades thin small caps looks brilliant in paper because it never pays the spread it would pay live. We cover how big that gap gets in paper trading proves nothing until slippage shows up.
How Do You Place Your First Order With the Alpaca API?
Placing your first order means instantiating a TradingClient with your paper keys, then calling the order submission method with a symbol, quantity, and order type. Here’s the shape of it:
from alpaca.trading.client import TradingClient
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce
trading_client = TradingClient(api_key, secret_key, paper=True)
order_request = MarketOrderRequest(
symbol="SPY",
qty=1,
side=OrderSide.BUY,
time_in_force=TimeInForce.DAY
)
trading_client.submit_order(order_request)
With paper=True set, that order routes automatically to the paper endpoint. Nothing real gets touched.[2][9]
Then check it and clean up. The SDK can list open orders with get_orders, and close_all_positions(cancel_orders=True) closes every position and cancels every open order in one call, which makes a decent emergency stop for a test bot.[9]
A few things to nail down before you hit submit:
- Time in force tells the order how long it stays active (DAY orders expire at the close).
- Order type (market, limit) decides how the fill happens. A market order fills at whatever price is available. A limit order only fills at your price or better, and in paper it fills only once it becomes marketable against the NBBO.[4]
- Position sizing matters even in paper trading. Practice the habit now, because sloppy sizing in a sandbox becomes sloppy sizing with real money.
Worked example: the paper account opens at $100,000. If you plan to fund $5,000 live and risk 1% per trade, your bot should risk $50 per trade in paper, not $1,000. Hard-code the live account size into the sizing function, not the paper balance.
If you want the strategy logic behind the order to actually hold up before scaling it, run it through how to backtest a trading strategy without fooling yourself first, or start with our Backtesting guide. For the full path from data to live orders, see our Python algorithmic trading roadmap.
What Programming Languages Does Alpaca Support?
Alpaca’s official SDK is built for Python (alpaca-py), but the underlying API is a standard REST interface, meaning any language that can send HTTP requests, JavaScript, Go, C#, Java, can call it directly.[9][8]
Python has the most polished tooling and the most documentation, so it’s the default starting point for beginners. The TradingClient object handles authentication, order submission, and account queries with a handful of method calls.[9]
There’s also a Trading CLI (command line interface) for people who don’t want to write a full application at all. Alpaca labels it an alpha preview, so commands can change between releases. You install it with Homebrew (brew install alpacahq/tap/cli) or Go, then log in with alpaca profile login (browser OAuth, paper only) or alpaca profile login --api-key for key-based paper access. Paper is the default; live requires the --live flag.[14]
Choose Python if you want the most examples and community support. Choose the CLI if you just want to test keys and submit one order without writing a script. Choose another language if you already have infrastructure built there, since the REST endpoints work regardless of language.
Can You Use Alpaca From Claude or Another AI Assistant?
Yes. Alpaca publishes an official MCP server (alpacahq/alpaca-mcp-server) that lets an AI assistant call the API for you. Version 2.4.0 lists 72 tools, needs Python 3.10+ and uv, and runs with uvx alpaca-mcp-server plus your ALPACA_API_KEY and ALPACA_SECRET_KEY. The ALPACA_PAPER_TRADE setting defaults to true, so it starts in paper mode.
That default is the right one. Let the assistant read data and place paper orders for weeks before you even consider flipping it. Our Claude trading bot guide covers where that setup works and where it fails.
What Are the Alpaca API Rate Limits and Restrictions?
Alpaca enforces rate limits on API requests to keep the platform stable, and the clearest published numbers sit on the market data side. The free Basic plan allows 200 historical data API calls per minute and 30 websocket symbols; Algo Trader Plus ($99 a month) raises that to 10,000 calls per minute and unlimited symbols.[12] A fixed order-rate number for individual Trading API accounts was not published on the pages we checked (October 2026).
When you exceed a limit, Alpaca’s rate-limit guidance is to expect HTTP 429 Too Many Requests, stop, and retry with exponential backoff (1s, 2s, 4s, 8s, with a little random jitter).[15] That page is written for Broker API partners, but the backoff pattern is the right default for any bot.
Practical restrictions beginners run into most often:
- Polling too fast for account status or order updates instead of using a streaming connection. The SDK’s
TradingStreamwebsocket pushes order updates as they happen.[9] - Order rejections when submitting outside market hours without the correct order type or extended-hours flag.
- The 15-minute SIP wall. On the free plan, querying SIP trades or quotes from the last 15 minutes returns “subscription does not permit querying recent SIP data.”[16]
Day trading note: FINRA has approved replacing the old pattern day trader rule (the $25,000 minimum and the four-trades-in-five-days count) with an intraday margin system. Check Alpaca’s explainer for how and when it applies to your account before you build a strategy around frequent round trips.[17]
How Much Does the Alpaca API Cost?
Paper trading on Alpaca is free for every user, with no minimum account size and no subscription required to start testing.[4][8] Live trading costs depend on your account type, any margin used, and standard regulatory fees that apply across the industry.
Market data is the cost that changes your bot. The Basic plan is free and covers real-time IEX data; Algo Trader Plus costs $99 a month and covers all US stock exchanges.[12] Our Alpaca API pricing breakdown covers when that upgrade is worth paying for.
Can you use Alpaca without a brokerage account? For paper trading, yes. A Paper Only Account needs just an email, and it’s limited to IEX market data.[4] To trade live and hold real securities, you need a funded brokerage account, since Alpaca is acting as your broker of record, not just an API vendor.
Decision rule: if you’re only testing strategy logic, you never need to fund anything. Fund the account only when you’re ready to risk real capital.
How Do You Fix Alpaca API Connection Errors?
Most connection errors trace back to one of three things: wrong environment (paper keys hitting the live endpoint or vice versa), missing or malformed headers, or an old key that the code hasn’t replaced.[7][5]
Alpaca’s market data endpoints return HTTP 403 when the request wasn’t authenticated, the credentials were wrong, or the user lacks permission.[16] Quick checklist when a connection fails:
- Confirm the base URL matches your key type (paper key needs paper URL).[11]
- Print the key ID being loaded to confirm your environment variables actually populated.
- If you opened a new paper account, generate new keys. Old keys don’t carry over.[4]
- Check that both headers are present on the request, not just one, and that market data calls go to
data.alpaca.markets.[16] - Save the
X-Request-IDresponse header. Alpaca asks for it in support requests and it can’t be looked up later.[10]
Edge case: if the connection works for account data but fails specifically on order submission, that’s usually a permissions or market-hours issue, not a key problem.
How Should Beginners Store Alpaca API Keys Securely?

Store your keys as environment variables or in a secrets manager, never hard-coded in a script or committed to a public repository. The secret key is shown once at generation, and Alpaca cannot retrieve it for you afterward.[5]
Basic rules that actually get followed:
- Never paste keys into a shared Slack channel, a public GitHub repo, an AI chat, or a screenshot.
- Use separate key pairs for paper and live environments. Alpaca issues them separately anyway.[11]
- Rotate (regenerate) keys immediately if you suspect exposure.
- Keep the secret key out of version control entirely, using a
.envfile that’s explicitly excluded from commits.
Common mistake: leaving old, unused live keys active for months. If you’re not using a key, revoke it.
What Are the Best Alpaca API Alternatives for Stock Trading?
Alpaca isn’t the only broker offering an API sandbox, and the right pick depends on whether you want a coding-first workflow or a no-code builder. Interactive Brokers, Schwab, and Tradier all offer APIs, and no-code platforms in the best AI trading bot category serve a different need. Our Trading Bots by Broker guide compares them, and our Interactive Brokers paper trading guide shows what the deeper (and harder) IBKR sandbox looks like.
Choose Alpaca if you want to write your own code and control every part of order logic. Choose a no-code builder like Composer Trade if you want algorithmic exposure without touching Python. Choose a full charting platform like TradingView if your priority is visual strategy building over raw API access.
Browse the full trading bots directory to compare more options side by side before committing to one workflow, or read our sister site’s hands-on Alpaca review.
How Long Does Alpaca Account Approval Take?
Paper trading access is available immediately after account registration, with no approval wait since no real money is involved.[1][3] Live, funded brokerage accounts go through standard identity verification and regulatory checks, similar to opening any brokerage account, and timing depends on how quickly your documentation clears.
Practical takeaway: don’t wait on live approval to start learning. Register, flip to paper mode, and start building your process while the live account (if you choose to open one) works through its own timeline in the background.
What Mistakes Do Beginners Make With Alpaca?
The most common mistake is treating paper trading like a formality instead of a real test, then going live the same week without any track record to check against. Systems over hacks: a strategy that hasn’t run clean for weeks in simulation has no business running with real capital.
Other patterns worth naming:
- Mixing up environments. Paper keys on the live URL, or vice versa, cause authentication failures; a live key pasted into a “test” script causes real trades.[11]
- No stop loss logic in the code, meaning a runaway loop can compound a bad position before a human notices.
- Overtrading the paper account to feel productive, then wondering why the fake win rate doesn’t survive contact with real slippage and real emotion.
- Sizing to liquidity that isn’t there. Paper doesn’t check your size against NBBO quantity, so big orders fill that never would live.[4]
- Skipping the read on rate limits, then getting blocked mid-test and blaming the API instead of the loop that hit it too hard.
Run your logic through an expectancy calculator before scaling size, paper or live. Numbers over vibes, every time.
Our Take
The Alpaca API for beginners removes the two excuses people use most: “I don’t have enough money” and “I don’t know if my strategy works.” Paper trading kills both. It’s free, it uses real-time IEX data, and it lets you break things without losing a dollar.[4][8]
Here’s what to actually do next. Register a free account, generate paper keys, and place one small market order using the TradingClient pattern above. Run it daily for a few weeks before you even think about live keys. Track the fills, not just the wins. That’s the process. Everything else is noise.
Cut the noise, keep the alpha.
FullStack Alpha tests the AI trading tools, scanners, and brokers so you don’t burn months figuring out which ones are real. See the Alpaca profile and 200+ more in the FullStack Alpha directory, filterable by category, price, and what they actually do.
Browse the FullStack Alpha directory of 200+ AI stock tools
This article is for education only and is not personalized investment advice. Some links on this page are affiliate links.
Keep Going
More from AI Stock Trading Bots: Broker APIs · Build a Trading Bot · Paper Trading.
Written and edited by Jay Rocco, Founder and Editor of FullStack Alpha. 200+ AI stock tools tested since 2022. Educational content only, not financial advice. See our Financial Disclaimer and How We Make Money.
Free weekly email
Join the FullStack Alpha newsletter
One email a week. The AI trading tools we tested, what broke, and what is worth your money. NO BS, no stock picks. Stay alpha.
Unsubscribe anytime. We never sell your email.
Stay alpha.
References
[1] Alpaca Learn: Start Paper Trading
[2] Alpaca Learn: Connect to the Alpaca API
[3] Alpaca Learn: Register on Alpaca
[4] Alpaca Docs: Paper Trading
[5] Alpaca Learn: API Key Security Best Practices
[6] Alpaca Learn: Algorithmic Trading Bot in 7 Steps
[7] Alpaca Docs: Authentication (v1.1)
[8] Alpaca Docs: Trading API
[9] alpaca-py SDK: Trading
[10] Alpaca Docs: Getting Started With the Trading API
[11] Alpaca Docs: Authentication (hosts and credentials)
[12] Alpaca Docs: About Market Data API (plans and limits)
[13] PyPI: alpaca-py
[14] Alpaca Docs: Trading CLI
[15] Alpaca Docs: Rate Limits
[16] Alpaca Docs: Market Data FAQ
[17] Alpaca Docs: FINRA’s New Intraday Margin Rule and the End of PDT
Frequently Asked Questions
Do I need money to start with the Alpaca API?
No. Paper trading is free for every user and includes real-time market data, so you can test full strategies with zero funding.
What's the difference between the Key ID and the Secret Key?
The Key ID is your public account identifier. The Secret Key is the private credential that authenticates the request, and it's only shown once at generation.
Can I use the Alpaca API without opening a brokerage account?
For paper trading, functionally yes, signup gives you what you need. For live trading real securities, you need a funded, approved brokerage account since Alpaca is your broker of record.
What happens if I mix up my paper and live keys?
The request will either fail authentication or, in worse cases, route to the wrong environment. Always confirm the base URL matches the key type before submitting orders.
Which language should a beginner use with Alpaca?
Python, through the official alpaca-py SDK, has the most documentation and the simplest TradingClient pattern for beginners.
How do I move from paper trading to live trading?
Swap the base URL from the paper endpoint to the live domain and swap in your live credentials. The strategy code itself doesn't need a rewrite.
Jay Rocco is the Founder and Editor of FullStack Alpha. He has tested 200+ AI stock tools since 2022 and run 15+ AI trading platforms on live accounts with his own money. He reviews the software. He does not tell you what stocks to buy.