Need help with your APIs? I offer API discovery, governance & evangelism services. Explore services →
API Evangelist API Evangelist
Discovery
Learnings
Guidance
Toolbox
Alignment
API Evangelist LLC

Alpaca Trading API

The Alpaca Trading API enables commission-free trading of US-listed equities, options, and crypto. It exposes endpoints for orders, positions, account information, watchlists, calendar, clock, and assets. A paper trading sandbox is available at paper-api.alpaca.markets.

Alpaca Trading API is one of 23 APIs that Alpaca publishes on the APIs.io network, described by a machine-readable OpenAPI specification and an AsyncAPI event-driven specification.

Tagged areas include Trading, Stocks, Options, Crypto, and Orders. The published artifact set on APIs.io includes API documentation, an OpenAPI specification, and an AsyncAPI specification.

This API exposes 11 operations across 5 paths, and defines 15 schemas. It is described by OpenAPI 3.0.0, at version 1.0.0.

Requests are made against 2 base URLs: https://broker-api.sandbox.alpaca.markets, https://broker-api.alpaca.markets.

11 operations 5 paths 15 schemas 4 DELETE5 GET1 PATCH1 POST

Metadata

The identity and technical contract details declared by the specification.

Specification
OpenAPI 3.0.0
API Version
1.0.0
Base URL
https://api.alpaca.markets/v2
Authentication
HTTP Basic
Terms of Service
Resource Areas
1

Authentication & Security 1

Alpaca Trading API declares 1 security scheme for authenticating requests. It accepts HTTP basic authentication (BasicAuth). By default, every request must be authenticated.

Paths & Operations 11

Across 5 paths, the API surfaces 11 operations — 4 DELETE, 5 GET, 1 PATCH, 1 POST. Each is listed below with its method, path, parameters, and response codes.

Trading 11
GET
/v1/trading/accounts/{account_id}/positions
List open positions for an account
getPositionsForAccount 1 param → 200
DELETE
/v1/trading/accounts/{account_id}/positions
Close All Positions for an Account
closeAllPositionsForAccount 2 params → 207500
GET
/v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id}
Get an Open Position for account by Symbol or AssetId
getPositionsForAccountBySymbol 2 params → 200404
DELETE
/v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id}
Close a Position for an Account
closePositionForAccountBySymbol 4 params → 200
GET
/v1/trading/accounts/{account_id}/orders/{order_id}
Retrieves a single order for the given orderid.
getOrderForAccount 2 params → 200400404
PATCH
/v1/trading/accounts/{account_id}/orders/{order_id}
Replaces a single order with updated parameters
replaceOrderForAccount 2 params body → 200400403404
DELETE
/v1/trading/accounts/{account_id}/orders/{order_id}
Attempts to cancel an open order.
deleteOrderForAccount 2 params → 204400404
GET
/v1/trading/accounts/{account_id}/orders
Retrieves a list of orders for the account, filtered by the supplied query parameters.
getAllOrdersForAccount 8 params → 200400404
POST
/v1/trading/accounts/{account_id}/orders
Create an order for an account.
createOrderForAccount 1 param body → 200400403404
DELETE
/v1/trading/accounts/{account_id}/orders
Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled.
deleteAllOrdersForAccount 1 param → 207400404
GET
/v1/events/trades
Subscribe to Trade Events (SSE)
subscribeToTradeSSE 4 params → 200

Schemas 15

The contract defines 15 schemas that model the data the API accepts and returns. The most detailed are Order (33 properties), Position (17 properties), CreateOrderRequest (16 properties), TradeUpdateEvent (7 properties). Each schema is shown below with its type and property counts.

TimeInForce
string
UpdateOrderRequest
object
Represents the fields that are editable in an order replace/update call. Note: clientorderid is currently not editable on its own, one of the other fields must…
6 properties
OrderStatus
string
Error
object
2 properties 2 required
OrderSide
string
Represents what side of the transaction an order was on.
Position
object
17 properties 16 required
TradeUpdateEventType
string
Common events These are the events that are the expected results of actions you may have taken by sending API requests. The meaning of the timestamp field chan…
OrderType
string
CreateOrderRequest
object
16 properties 4 required
PositionClosedResponse
object
Represents the result of asking the api to close a position. body is the Order used to close out the position.
3 properties 2 required
OrderClass
string
OrderClosedResponse
object
Represents the result of asking the api to cancel an Order.
3 properties 2 required
Order
object
33 properties 2 required
AssetClass
string
TradeUpdateEvent
object
Represents an update to an order/trade, sent over the events streaming api.
7 properties 7 required

Specification

The full machine-readable OpenAPI contract behind this narrative.

Source

alpaca-trading-api-openapi.yml Raw ↑

Other APIs Alpaca publishes across the network.

Alpaca OAuth API
Alpaca Account Activities API
Alpaca Account Configurations API
Alpaca Accounts API
Alpaca Assets API
Alpaca Calendar API
Alpaca Clock API
Alpaca Corporate Actions API
Alpaca Crypto Pricing Data API API
Alpaca Documents API
Alpaca Events API
Alpaca Funding API