alpaca-py
The Official Python SDK for Alpaca APIs
What it is and what it does
Alpaca-py is the official Python SDK that wraps Alpaca's REST, WebSocket, and SSE APIs into a unified, object-oriented interface. It lets you build trading applications, stream live market data, and manage brokerage accounts programmatically. The library uses pydantic for runtime data validation and provides separate client classes for different asset classes and API products—TradingClient for orders, StockHistoricalDataClient for historical data, BrokerClient for account management, and specialized data stream clients for real-time feeds.
The package depends on msgpack, pandas, pydantic, pytz, requests, sseclient-py, and websockets to handle serialization, data frames, validation, time zones, HTTP requests, server-sent events, and WebSocket connections. It's designed for developers building algorithmic trading strategies, robo-advisors, or full brokerage experiences. Request models (e.g., MarketOrderRequest, CryptoBarsRequest) enforce schema validation before sending to Alpaca's servers, reducing runtime errors.
Use it for:
- Build algorithmic trading strategies that automatically submit orders and stream live market data for stocks, crypto, or options.
- Create a robo-advisor or investment app that manages multiple brokerage accounts under your control via the Broker API.
- Backtest trading strategies using historical bar data from Alpaca's market data API for multiple asset classes.
- Stream real-time market data (quotes, bars, trades) via WebSocket or SSE for live dashboards or monitoring systems.
- Validate and parse trading order data from JSON payloads using pydantic-backed request models before execution.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Alpaca-py is the official Python SDK for interacting with Alpaca's trading, market data, and broker APIs, supporting REST, WebSocket, and SSE endpoints for stock, crypto, and options trading and data access.
Yes. Alpaca-py is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. It is the official SDK for Alpaca's APIs and is well-suited for anyone building trading or investment applications that need to interact with Alpaca's services. The OOP design and pydantic validation reduce errors compared to raw HTTP calls.
Install
alpaca-py on PyPI
pip
pip install alpaca-pyuv
uv add alpaca-pypoetry
poetry add alpaca-pyInstalling alpaca-py
Before you install
Low install friction with a pure-Python wheel distribution. Actively maintained with a recent release (3 days old) and steady repository activity. Supports Python 3.10 through 3.14.
License in practice
Apache-2.0 is permissive; you can use, modify, and distribute alpaca-py freely in commercial or private projects with minimal restrictions.
Quickstart
pip install alpaca-py
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')
order = trading_client.submit_order(
MarketOrderRequest(
symbol="BTC/USD",
qty=0.0001,
side=OrderSide.BUY,
time_in_force=TimeInForce.DAY
)
)
Requires an Alpaca account and API keys (trading, market data, or broker keys depending on which APIs you use); Python 3.10 or later.
Verify before relying
- Specific latency or throughput characteristics of WebSocket and SSE streaming connections.
- Whether all asset classes (stocks, crypto, options) are equally mature or if some are newer.
- Real-world performance under high-frequency trading or large data volume scenarios.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (<4.0.0,>=3.10.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — msgpack, pandas, pydantic, pytz, requests, sseclient-py, websockets |
| Maintenance | actively maintained — 3 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,969,763/month — #3,399 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: alpaca_py-0.44.0-py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
alpaca-trade-apiPython client library for the Alpaca Commission…
unclear · top 15,000 on PyPI
growwapiSDK for connecting to Groww's trading platform…
permissive · top 15,000 on PyPI
python-binanceUnofficial Python wrapper for the Binance…
permissive · top 15,000 on PyPI
fyers-apiv3Official Python client library for the Fyers…
permissive · top 15,000 on PyPI
robin-stocksProvides a Python interface to the Robinhood,…
permissive · top 15,000 on PyPI
python-kraken-sdkProvides REST and WebSocket clients for trading…
permissive · top 15,000 on PyPI
shioajiShioaji is a trading API for Taiwan's financial…
unclear · top 15,000 on PyPI
smartapi-pythonA Python client library for Angel Broking's…
unclear · top 15,000 on PyPI
lumibotLumibot is a Python framework for building,…
permissive · top 15,000 on PyPI
pycoingeckoPython wrapper around the CoinGecko API (v3)…
permissive · top 15,000 on PyPI