Find an API

Search public APIs with auth details & Postman guides

← All APIs

Alpaca Trading API

api.alpaca.markets · Finance

Finance API Key Free Tier Stocks Trading Finance

Commission-free US stock, ETF, options, and crypto trading API — built for developers. Real-time market data, paper trading sandbox, WebSocket streaming. Free paper trading forever.

Authentication

API Key authentication Free account at alpaca.markets. Get API key and secret from dashboard. Pass as APCA-API-KEY-ID and APCA-API-SECRET-KEY headers. Paper trading: use paper-api.alpaca.markets.

Sample Requests

GET Get account info

Get your paper trading account details.

https://api.alpaca.markets/v2/account

Hover any highlighted part to learn what it does

Headers — extra info sent with the request
APCA-API-KEY-ID YOUR_KEY_ID
APCA-API-SECRET-KEY YOUR_SECRET
curl -X GET "https://api.alpaca.markets/v2/account" \
  -H "APCA-API-KEY-ID: YOUR_KEY_ID" \
  -H "APCA-API-SECRET-KEY: YOUR_SECRET"
import requests
headers = {
    "APCA-API-KEY-ID": "YOUR_KEY_ID",
    "APCA-API-SECRET-KEY": "YOUR_SECRET"
}
response = requests.get(
    "https://api.alpaca.markets/v2/account",
    headers=headers,
)
print(response.json())
const url = 'https://api.alpaca.markets/v2/account';

const response = await fetch(url, {
  headers: {
    'APCA-API-KEY-ID': 'YOUR_KEY_ID',
    'APCA-API-SECRET-KEY': 'YOUR_SECRET'
  },
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	targetURL := "https://api.alpaca.markets/v2/account"
	req, _ := http.NewRequest("GET", targetURL, nil)
	req.Header.Set("APCA-API-KEY-ID", "YOUR_KEY_ID")
	req.Header.Set("APCA-API-SECRET-KEY", "YOUR_SECRET")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.alpaca.markets/v2/account")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Get.new(uri)
req["APCA-API-KEY-ID"] = "YOUR_KEY_ID"
req["APCA-API-SECRET-KEY"] = "YOUR_SECRET"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.alpaca.markets/v2/account";
$opts = ["http" => [
    "method" => "GET",
    "header" => implode("\r\n", [
        "APCA-API-KEY-ID: YOUR_KEY_ID",
        "APCA-API-SECRET-KEY: YOUR_SECRET"
    ]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET Get latest stock quote

Get the latest bid/ask quote for Apple stock.

https://api.alpaca.markets/v2https:/data.alpaca.markets/v2/stocks/AAPL/quotes/latest

Hover any highlighted part to learn what it does

Headers — extra info sent with the request
APCA-API-KEY-ID YOUR_KEY_ID
APCA-API-SECRET-KEY YOUR_SECRET
curl -X GET "https://api.alpaca.markets/v2https://data.alpaca.markets/v2/stocks/AAPL/quotes/latest" \
  -H "APCA-API-KEY-ID: YOUR_KEY_ID" \
  -H "APCA-API-SECRET-KEY: YOUR_SECRET"
import requests
headers = {
    "APCA-API-KEY-ID": "YOUR_KEY_ID",
    "APCA-API-SECRET-KEY": "YOUR_SECRET"
}
response = requests.get(
    "https://api.alpaca.markets/v2https://data.alpaca.markets/v2/stocks/AAPL/quotes/latest",
    headers=headers,
)
print(response.json())
const url = 'https://api.alpaca.markets/v2https://data.alpaca.markets/v2/stocks/AAPL/quotes/latest';

const response = await fetch(url, {
  headers: {
    'APCA-API-KEY-ID': 'YOUR_KEY_ID',
    'APCA-API-SECRET-KEY': 'YOUR_SECRET'
  },
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	targetURL := "https://api.alpaca.markets/v2https://data.alpaca.markets/v2/stocks/AAPL/quotes/latest"
	req, _ := http.NewRequest("GET", targetURL, nil)
	req.Header.Set("APCA-API-KEY-ID", "YOUR_KEY_ID")
	req.Header.Set("APCA-API-SECRET-KEY", "YOUR_SECRET")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.alpaca.markets/v2https://data.alpaca.markets/v2/stocks/AAPL/quotes/latest")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Get.new(uri)
req["APCA-API-KEY-ID"] = "YOUR_KEY_ID"
req["APCA-API-SECRET-KEY"] = "YOUR_SECRET"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.alpaca.markets/v2https://data.alpaca.markets/v2/stocks/AAPL/quotes/latest";
$opts = ["http" => [
    "method" => "GET",
    "header" => implode("\r\n", [
        "APCA-API-KEY-ID: YOUR_KEY_ID",
        "APCA-API-SECRET-KEY: YOUR_SECRET"
    ]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));

Postman Setup Guide

Get Postman ↗
  1. Sign up free at alpaca.markets
  2. Get API key ID and secret key from dashboard
  3. Paper trading: use paper-api.alpaca.markets (no real money)
  4. Set headers: APCA-API-KEY-ID and APCA-API-SECRET-KEY
  5. Market data: data.alpaca.markets (separate endpoint)

What can you build with Alpaca Trading API?

Alpaca Trading API is a Finance API. Developers commonly use finance APIs for:

  • processing payments and handling transactions
  • building subscription and billing systems
  • automating invoicing and financial reporting
  • fraud detection and risk scoring
  • connecting to banking and accounting software

API Key authentication. You'll receive a key after signing up. Send it with every request — in a header or query parameter. Keep it out of client-side code and never commit it to version control. Alpaca Trading API is free to use up to a usage limit, making it a low-risk choice to experiment with.

New to APIs? Read our beginner's guide

Open documentation ↗