Skip to content

REST API mappings

Oleg Rakhmatulin edited this page Nov 8, 2021 · 8 revisions

IAlpacaTradingClient interface

Account

Operation URL Path SDK Method
Get the account [GET] /v2/account Task<IAccount> GetAccountAsync(CancellationToken)
Get the account configurations [GET] /v2/account/configurations Task<IAccountConfiguration> GetAccountConfigurationAsync(CancellationToken)
Update the account configurations [PATCH] /v2/account/configurations Task<IAccountConfiguration> PatchAccountConfigurationAsync(IAccountConfiguration, CancellationToken)
Get account activities of one type [GET] /v2/account/activities/{activity_type} Task<IReadOnlyList<IAccountActivity>> ListAccountActivitiesAsync(AccountActivitiesRequest, CancellationToken)
Get account activities of multiple types [GET] /v2/account/activities Task<IReadOnlyList<IAccountActivity>> ListAccountActivitiesAsync(AccountActivitiesRequest, CancellationToken)
Get the account portfolio history [GET] /v2/account/portfolio/history Task<IPortfolioHistory> GetPortfolioHistoryAsync(PortfolioHistoryRequest, CancellationToken)

Orders

Operation URL Path SDK Method
Get a list of orders [GET] /v2/orders Task<IReadOnlyList<IOrder>> ListOrdersAsync(ListOrdersRequest, CancellationToken)
Request a new order [POST] /v2/orders Task<IOrder> PostOrderAsync(NewOrderRequest, CancellationToken)
Request a new order [POST] /v2/orders Task<IOrder> PostOrderAsync(OrderBase, CancellationToken)
Get an order [GET] /v2/orders/{order_id} Task<IOrder> GetOrderAsync(Guid, CancellationToken)
Get an order by client order id [GET] /v2/orders:by_client_order_id Task< > GetOrderAsync(String, CancellationToken)
Replace an order [PATCH] /v2/orders/{order_id} Task<IOrder> PatchOrderAsync(ChangeOrderRequest, CancellationToken)
Cancel all orders [DELETE] /v2/orders Task<IReadOnlyList<IOrderActionStatus>> DeleteAllOrdersAsync(CancellationToken)
Cancel an order [DELETE] /v2/orders/{order_id} Task<Boolean> DeleteOrderAsync(Guid, CancellationToken)

Positions

Operation URL Path SDK Method
Get open positions [GET] /v2/positions Task<IReadOnlyList<IPosition>> ListPositionsAsync(CancellationToken)
Get an open position [GET] /v2/positions/{symbol} Task<IPosition> GetPositionAsync(String, CancellationToken)
Close all positions [DELETE] /v2/positions Task<IReadOnlyList<IPositionActionStatus>> DeleteAllPositionsAsync(DeleteAllPositionsRequest, CancellationToken)
Close a position [DELETE] /v2/positions/{symbol} Task<IOrder> DeletePositionAsync(DeletePositionRequest, CancellationToken)

Assets

Operation URL Path SDK Method
Get assets [GET] v2/assets Task<IReadOnlyList<IAsset>> ListAssetsAsync(AssetsRequest, CancellationToken)
Get an asset [GET] v2/assets/{symbol} Task<IAsset> GetAssetAsync(String, CancellationToken)

Watchlists

Operation URL Path SDK Method
Get a list of watchlists [GET] v2/watchlists Task<IReadOnlyList<IWatchList>> ListWatchListsAsync(CancellationToken)
Create a watchlist [POST] v2/watchlists Task<IWatchList> CreateWatchListAsync
Get a watchlist [GET] v2/watchlists/{watchlist_id} Task<IWatchList> GetWatchListByIdAsync(Guid, CancellationToken)
Update watchlist [PUT] v2/watchlists/{watchlist_id} Task<IWatchList> UpdateWatchListByIdAsync(UpdateWatchListRequest, CancellationToken)
Add an asset [POST] v2/watchlists/{watchlist_id} Task<IWatchList> AddAssetIntoWatchListByIdAsync(ChangeWatchListRequest, CancellationToken)
Delete a watchlist [DELETE] v2/watchlists/{watchlist_id} Task<Boolean> DeleteWatchListByIdAsync(Guid, CancellationToken)
Remove a symbol from the watchlist [DELETE] v2/watchlists/{watchlist_id}/{symbol} Task<IWatchList> DeleteAssetFromWatchListByIdAsync(ChangeWatchListRequest, CancellationToken)

Calendar & Clock

Operation URL Path SDK Method
Get the calendar [GET] v2/calendar Task<IReadOnlyList<ICalendar>> ListCalendarAsync(CalendarRequest, CancellationToken)
Get the clock [GET] v2/clock Task<IClock> GetClockAsync(CancellationToken)

IAlpacaDataClient interface

Historical Data

Operation URL Path SDK Method
Trades [GET] /v2/stocks/{symbol}/trades Task<IPage<ITrade>> ListHistoricalTradesAsync(HistoricalTradesRequest, CancellationToken)
Latest trade [GET] /v2/stocks/{symbol}/trades/latest Task<ITrade> GetLatestTradeAsync(String, CancellationToken)
Quotes [GET] /v2/stocks/{symbol}/quotes Task<IPage<IQuote>> ListHistoricalQuotesAsync(HistoricalQuotesRequest, CancellationToken)
Latest quote [GET] /v2/stocks/{symbol}/quotes/latest Task<IQuote> GetLatestQuoteAsync(String, CancellationToken)
Bars [GET] /v2/stocks/{symbol}/bars Task<IPage<IBar>> ListHistoricalBarsAsync(HistoricalBarsRequest, CancellationToken)
Snapshot - Multiple tickers [GET] /v2/stocks/snapshots Task<IReadOnlyDictionary&ltString, ISnapshot>> GetSnapshotsAsync(IEnumerable<String>, CancellationToken)
Snapshot - Ticker [GET] /v2/stocks/{symbol}/snapshot Task<ISnapshot> GetSnapshotAsync(String, CancellationToken)

IAlpacaCryptoDataClient interface

Historical Data

Operation URL Path SDK Method
Trades [GET] /v1beta1/crypto/{symbol}/trades Task<IPage<ITrade>> ListHistoricalTradesAsync(HistoricalCryptoTradesRequest, CancellationToken)
Latest trade [GET] /v1beta1/crypto/{symbol}/trades/latest Task<ITrade> GetLatestTradeAsync(String, CancellationToken)
Quotes [GET] /v1beta1/crypto/{symbol}/quotes Task<IPage<IQuote>> ListHistoricalQuotesAsync(HistoricalCryptoQuotesRequest, CancellationToken)
Latest quote [GET] /v1beta1/crypto/{symbol}/quotes/latest Task<IQuote> GetLatestQuoteAsync(String, CancellationToken)
Bars [GET] /v1beta1/crypto/{symbol}/bars Task<IPage<IBar>> ListHistoricalBarsAsync(HistoricalCryptoBarsRequest, CancellationToken)
XBBO [GET] /v1beta1/crypto/{symbol}/xbbo/latest Task<IQuote;> GetLatestBestBidOfferAsync(LatestBestBidOfferRequest, CancellationToken)