Alpaca API

Finance / API Key Intermediate HTTPS CORS
Varies by plan (check documentation)

Overview

Alpaca provides real-time and historical market data for US equities and ETFs, along with commission-free trading capabilities. It uses API key authentication and supports both paper trading (simulation) and live trading environments. It is a strong choice for building algorithmic trading bots or financial data dashboards.

💡

Beginner Tip

Start with a paper trading account on alpaca.markets to get free API keys for testing without risking real money. Use the data API at data.alpaca.markets separately from the broker API at paper-api.alpaca.markets.

Available Data

stock price and symbol
open/close/high/low values
trading volume
market cap
historical price data

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Alpaca",
    "description": "Realtime and historical market data on all US equities and ETFs",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

t Timestamp for the bar in RFC 3339 format
o Opening price for the bar period
h Highest price during the bar period
l Lowest price during the bar period
c Closing price for the bar period
v Trading volume (number of shares) during the bar period

Implementation Example

const url = "https://alpaca.markets/docs/api-documentation/api-v2/market-data/alpaca-data-api-v2/";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

403 Forbidden Using paper trading keys to access live trading endpoints or vice versa
Make sure you are using the correct base URL — paper-api.alpaca.markets for paper trading and api.alpaca.markets for live trading
422 Unprocessable Entity Invalid timeframe or date format in market data requests
Use valid timeframe values like 1Min, 5Min, 1Hour, 1Day and ISO 8601 dates for start/end parameters
401 Unauthorized Both key ID and secret key are required but one is missing
Include both APCA-API-KEY-ID and APCA-API-SECRET-KEY headers in every authenticated request

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 5/20
🔒 Security 15/15
🛠 Developer XP 17/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth API Key
HTTPS REQUIRED
CORS YES
Category Finance
Difficulty Intermediate
Verified: 2026-04-07

Similar APIs

View All →