alpaca-trade-api
Alpaca API python client
What it is and what it does
alpaca-trade-api is a Python client for Alpaca's commission-free trading platform. It wraps the Alpaca REST and streaming APIs, allowing developers to fetch historical market data (bars, quotes, trades), manage trading accounts and portfolios, and stream live market data. The library supports both synchronous REST calls and asynchronous operations via asyncio, with built-in pagination for large data queries.
The package depends on pandas, numpy, requests, websocket-client, websockets, aiohttp, and other utilities for HTTP and data handling. It is designed for rapid algo development but is no longer actively maintained—the maintainers deprecated it in favor of Alpaca-py starting in 2023 and committed to maintenance only through end-2022. The repository is now archived, making this a legacy choice for new projects.
Use it for:
- Fetch historical OHLCV bars and quotes for backtesting trading strategies
- Stream real-time market data and execute trades programmatically against a live or paper trading account
- Build automated trading bots that monitor account positions and rebalance portfolios on schedule
- Retrieve historical trade data and account statements for analysis and reporting
- Prototype trading algorithms with support for custom timeframes and data pagination
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python client library for the Alpaca Commission Free Trading API, providing REST and streaming interfaces for market data retrieval, account management, and algorithmic trading.
No, not for new projects. The package is abandoned and explicitly superseded by Alpaca-py. While it has low install friction and no known vulnerabilities, the lack of active maintenance, unclear license, and the maintainers' own recommendation to migrate make it unsuitable for new development. Use only if maintaining legacy code that cannot yet be ported to Alpaca-py.
Install
alpaca-trade-api on PyPI
pip
pip install alpaca-trade-apiuv
uv add alpaca-trade-apipoetry
poetry add alpaca-trade-apiInstalling alpaca-trade-api
Before you install
Low install friction with a pure-Python wheel and ten runtime dependencies. However, the package is abandoned as of end-2022; the maintainers explicitly recommend migrating to the newer Alpaca-py SDK. Last commit was 2024-12-02, but the repository is archived and no active development is expected.
License in practice
License treatment is unclear—no SPDX identifier or raw license text is available in the metadata. Before adopting this package, verify the actual license terms in the repository to ensure compatibility with your project.
Quickstart
from alpaca_trade_api.rest import REST, TimeFrame
api = REST()
bars = api.get_bars("AAPL", TimeFrame.Hour, "2021-06-08", "2021-06-08", adjustment='raw')
print(bars.df)
Requires Python 3.7 or above. API key from Alpaca (https://app.alpaca.markets/signup) and environment variables APCA_API_BASE_URL and APCA_API_DATA_URL must be set or passed directly to REST().
Verify before relying
- Current state of the archived repository and whether security patches are still applied
- Compatibility of this SDK with the current Alpaca API v2 after end-of-2022 maintenance window
- Whether the websockets>=9.0 recommendation is a hard requirement or a best practice
Package facts
| License | not declared (unclear) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 10 — pandas, numpy, requests, urllib3, websocket-client, websockets, msgpack, aiohttp, PyYAML, deprecation |
| Maintenance | abandoned — 945 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 655,225/month — #5,516 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: alpaca_trade_api-3.2.0-py3-none-any.whl
Keywords: financial, timeseries, api, trade
Tags
More Internet packages
Botocore provides low-level, data-driven access…
permissive · top 100 on PyPI
aiobotocoreProvides an async client for AWS services using…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
googleapis-common-protosProvides common Protocol Buffer message…
permissive · top 100 on PyPI
alpaca-pyAlpaca-py is the official Python SDK for…
permissive · top 5,000 on PyPI
snaptrade-python-sdkPython SDK client for SnapTrade's brokerage…
permissive · top 15,000 on PyPI
kiteconnectOfficial Python client for the Kite Connect…
permissive · top 15,000 on PyPI
growwapiSDK for connecting to Groww's trading platform…
permissive · top 15,000 on PyPI
databentoOfficial Python client for accessing live and…
permissive · top 5,000 on PyPI
pandas_market_calendarsProvides market and exchange trading calendars…
permissive · top 5,000 on PyPI
dhanhqPython client library for the Dhan trading API,…
permissive · top 15,000 on PyPI
exchange_calendarsProvides trading calendars for more than 50…
permissive · top 5,000 on PyPI
yahooqueryRetrieves financial data from Yahoo Finance…
permissive · top 15,000 on PyPI
metatrader5Connects Python to MetaTrader 5 Terminal to…
permissive · top 15,000 on PyPI