Alpaca Trading API integration
Alpaca is an API-first broker for US stocks, ETFs, options and crypto. Read the account (buying power, equity, positions, activities, portfolio history), place, replace and cancel orders, close positions, exercise options, look up tradable assets and option contracts, read the market clock and calendar, and manage watchlists. On a live account an order buys or sells real securities with real money; a paper account simulates it. Left out: the activity event stream (SSE), the deprecated corporate-action announcements, short-sale locates, tokenization minting (authorized participants only), and the crypto funding wallets, transfers and withdrawal whitelists. Authentication is an API key pair sent as the APCA-API-KEY-ID and APCA-API-SECRET-KEY headers; the connection also picks paper-api (paper trading keys) or api (live keys).
Say what should happen.
The workflow builds itself.
What you can do with Alpaca Trading API
Each of these is one operation on one endpoint, available both as a workflow step and as a tool an AI agent can call on its own. Nothing bundles several operations into one action, so what a run did stays readable afterwards.
Most endpoints run on the free plan. A few, mainly the ones that publish on your behalf, need a paid plan.
Watchlist, 7 operations
add_asset_to_watchlistAdd asset to watchlistPOSTAppend an asset for the symbol to the end of watchlist asset listcreate_watchlistCreate watchlistPOSTCreate a new watchlist with initial set of assets.delete_watchlistDelete watchlistDELETEDeletes a watchlist by its id, permanently.get_watchlistGet watchlistGETReturns a watchlist identified by the ID.list_watchlistsList watchlistsGETReturns the list of watchlists registered under the account.remove_asset_from_watchlistRemove asset from watchlistDELETEDelete one entry for an asset by symbol nameupdate_watchlistUpdate watchlistPUTRenames a watchlist and/or replaces its list of symbols.
Order, 6 operations
cancel_all_ordersCancel all ordersDELETECancels every open order of the account and returns, per order, its id and the HTTP status of the cancel attempt.cancel_orderCancel orderDELETECancels one open order. An order that can no longer be canceled is refused with status 422.create_orderCreate orderPOSTPlaces an order to buy or sell a stock, ETF, option or crypto: market, limit, stop, stop-limit or trailing stop, simple or bracket/OCO/OTO/multi-leg. On a live account this trades real securities with real money.get_orderGet orderGETRetrieves a single order for the given order_id.list_ordersList ordersGETRetrieves a list of orders for the account, filtered by the supplied query parameters.replace_orderReplace orderPATCHReplaces an open order with new quantity, limit, stop, trail or time in force; unspecified attributes are kept. Returns the new order; success does not guarantee the old one was replaced. On a live account this trades real money.
Position, 4 operations
close_all_positionsClose all positionsDELETECloses (liquidates) every open long and short position, optionally canceling open orders first. Returns one result per position. On a live account this sells or buys real securities.close_positionClose positionDELETECloses (liquidates) one open position, long or short, entirely or by qty or percentage, and returns the closing order. On a live account this sells or buys real securities.get_positionGet positionGETRetrieves the account's open position for the given symbol or assetId.list_positionsList positionsGETThe positions API provides information about an account's current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated.
Watchlists by name, 4 operations
add_asset_to_watchlist_by_nameAdd asset to watchlist by namePOSTAppends an asset, by symbol, to the end of the watchlist with the given name.delete_watchlist_by_nameDelete watchlist by nameDELETEDeletes the watchlist with the given name, permanently.get_watchlist_by_nameGet watchlist by nameGETReturns the watchlist with the given name and its assets.update_watchlist_by_nameUpdate watchlist by namePUTRenames the watchlist with the given name and/or replaces its list of symbols.
Activity, 2 operations
list_account_activitiesList account activitiesGETLists account activities (fills, dividends, fees, transfers and more), newest first by default, filtered by type, category, order or date. Page with page_size and page_token (the id of the last activity of the previous page).list_account_activities_by_typeList account activities by typeGETReturns account activity entries for a specific type of activity.
Asset, 2 operations
get_assetGet assetGETReturns one asset by symbol, asset id or CUSIP: class, exchange, tradable, marginable, shortable, fractionable flags, margin requirements and price increment.list_assetsList assetsGETThe assets API serves as the master list of assets available for trade and data consumption from Alpaca. Assets are sorted by asset class, exchange and symbol.
Calendar, 2 operations
get_market_calendarGet market calendarGETThis endpoint returns the market calendar.get_us_market_calendarGet us market calendarGETThe calendar API serves the full list of market days from 1970 to 2029. It can also be queried by specifying a start and/or end time to narrow down the results.
Clock, 2 operations
get_market_clockGet market clockGETThis API serves information about multiple markets: the current time, if it's a market day, the current phase of the market, etc.get_us_market_clockGet us market clockGETThe clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close.
Configuration, 2 operations
get_account_configurationsGet account configurationsGETReturns the account configuration: shorting, fractional and overnight trading, margin multiplier, options trading level, trade suspension and fill confirmation emails.update_account_configurationsUpdate account configurationsPATCHChanges account configuration values (shorting, fractional and overnight trading, margin multiplier, options level, trade suspension, fill emails) and returns the new configuration.
Contract, 2 operations
get_option_contractGet option contractGETGet an option contract by symbol or contract ID. The symbol or id should be passed in as a path parameter.list_option_contractsList option contractsGETThis endpoint allows you to retrieve a list of option contracts based on various filtering criteria. By default only active contracts that expire before the upcoming weekend are returned.
Account, 1 operation
get_accountGet accountGETReturns your account details.
Do not exercise, 1 operation
do_not_exercise_optionDo not exercise optionPOSTSubmits a do-not-exercise instruction for a held option contract, so Alpaca does not exercise it automatically at expiry. On a live account this decides what happens to a real position, with real money, at expiry.
Exercise, 1 operation
exercise_optionExercise optionPOSTExercises every held contract of an option position, converting it into the underlying per the contract terms. Processed at once; refused between market close and midnight. On a live account this trades real securities with real money.
History, 1 operation
get_portfolio_historyGet portfolio historyGETReturns timeseries data about equity and profit/loss (P/L) of the account in requested timespan.
Orders by client order id, 1 operation
get_order_by_client_order_idGet order by client order idGETRetrieves a single order specified by the client order ID.
Use Alpaca Trading API from Claude Code, Cursor or Codex
Connect Alpaca Trading API in LiveContext, create an API key in Settings, then add the LiveContext MCP server to your client. Its Alpaca Trading API operations become tools the client can call, next to every other integration you connected.
claude mcp add --transport http livecontext https://livecontext.ai/mcp --header "X-API-Key: YOUR_API_KEY"[mcp_servers.livecontext]
url = "https://livecontext.ai/mcp"
[mcp_servers.livecontext.http_headers]
"X-API-Key" = "YOUR_API_KEY"{
"mcpServers": {
"livecontext": {
"type": "http",
"url": "https://livecontext.ai/mcp",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}How to connect Alpaca Trading API
- Create your workspace
Sign up free. Nothing to install.
- Connect Alpaca Trading API once
Add your Alpaca Trading API connection in Settings. Every tool from this integration reuses it, and secrets are encrypted at rest and visible only to you.
- Describe the job in chat
The workflow builds itself in front of you and picks the endpoints it needs. Drag the steps yourself on the canvas whenever you would rather be explicit.
Alpaca Trading API integration FAQ
What can you do with the Alpaca Trading API integration?
LiveContext exposes 38 operations on Alpaca Trading API, covering watchlist, order, position and watchlists by name.
