Alpaca Trading

FREE
By alpacahq
Updated 5 months ago
5.8/10
Popularity Score
431ms
Latency
17%
Success Rate

Alpaca Trading API Documentation

Alpaca is a modern platform for algorithmic trading. Alpaca's API is the interface for your trading algo to communicate with Alpaca's brokerage service. The API allows your trading algo to access real-time price, fundamentals, place orders and manage your portfolio, in either REST (pull) or streaming (push) style.

Alpaca Securities LLC is SEC registered and a FINRA member.

View API Details
Account
GETGet the account
Orders
GETGet a list of orders
POSTRequest a new order
GETGet an order by client order id
GETGet an order
DELETECancel an order
Positions
GETGet open positions
GETRetrieves the account's open position for given symbol
Assets
GETGet an asset
GETGet assets
Clock
GETGet the clock
Calendar
GETGet the calendar
GETGet the account

Returns the account associated with the API key

Authorization:

Key-based API authentication

Header Parameters
X-RapidAPI-HostSTRING
REQUIRED
X-RapidAPI-KeySTRING
REQUIRED
APCA-API-SECRET-KEYHEADER
REQUIREDAPI secret key which is acquired in the dashboard
APCA-API-KEY-IDHEADER
REQUIREDAPI Key ID which is acquired in the dashboard
Code Snippet
unirest.get("https://alpacahq-alpaca-trading-v1.p.rapidapi.com/v1/account")
.header("X-RapidAPI-Host", "alpacahq-alpaca-trading-v1.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
Sample Response
General
Request URL: https://alpacahq-alpaca-trading-v1.p.rapidapi.com/v1/account
Request Method: GET
Response Headers
Response Body

Install SDK for NodeJS

Installing

To utilize unirest for node.js install the the npm module:

$ npm install unirest

After installing the npm package you can now start simplifying requests like so:

var unirest = require('unirest');

Creating Request

unirest.get("https://alpacahq-alpaca-trading-v1.p.rapidapi.com/v1/account")
.header("X-RapidAPI-Host", "alpacahq-alpaca-trading-v1.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication