Guides

Getting Started

Welcome to the SnapTrade developer hub. You'll find comprehensive documentation for all our endpoints, as well as detailed guides to help you in your build.

If you need further assistance or have any questions, please send us an email at api@snaptrade.com.

If you already have API Keys, you can use our demo tool to start making requests.

API Status

Call the endpoint to make sure the API is live and that you can make the most basic request. You should receive a response indicating the API status, current server timestamp, and internal API minor version number.

Example:

{ "version": 151, "timestamp": "2022-01-24T19:02:46.440074Z", "online": true }

Developer SDKs

Easily integrate with SnapTrade in your programming language of choice by using one of our SDKs:

Register a test user

To create a secure brokerage authorization, you first need to register a user.

Call the endpoint with a userId which can be any string as long as it's unique to a user. Upon receiving a 200 response, the user is registered successfully and you should receive a response with a user id and a randomly generated user secret.

You can think of the user secret as a password that you will store on your users’ behalf. This, combined with your consumerKey provides additional security for your users’ data. The user id and user secret need to be passed along to all SnapTrade API endpoints that involve access to user data.

Example:

{ "userId": "USERID123", "userSecret": "AYSEY8726837292873" }

To initiate a brokerage authorization for one of your users, you first create a redirect URI for that user to securely login to the SnapTrade Connection Portal and make brokerage connections.

The redirect URI can be generated by sending a POST request to the endpoint. userId and userSecret (previously generated through calling the registerUser endpoint) have to be in the query parameters of the POST request.

The response includes a redirectURI to be used to login a user to the connection portal.

Example:

{
"redirectURI": "https://app.snaptrade.com/snapTrade/redeemToken?token=TOKEN&clientId=PASSIVTEST"
}

Connect an account through the Connection Portal

Once a user successfully logs into the connection portal, they can select their brokerage and go through the connection flow to connect their brokerage accounts.

Pull user holdings

In order to retrieve user holdings for a specific account, you can call the endpoint by passing the clientId, timestamp, userId and list of account numbers (accounts) to filter the holdings.

In the response, you should get an array of objects containing each account holdings data.

Example:

[
{
"account": {
"id": "908192",
"brokerage": "X",
"number": "123456",
"name": "Y"
},
"balances": [
{
"currency": {
"id": "123",
"code": "CA",
"name": "Canadian dollar"
},
"cash": 1200
}
],
"positions": [
{
"symbol": {
"symbol": "SYMBL",
"name": "Symbol name",
"currency": {
"id": "123",
"code": "CA",
"name": "Canadian dollar"
},
"exchange": {
"code": "123123",
"name": "X"
}
},
"units": "1",
"price": 12
}
]
}
]

Place a limit order

To place an order through SnapTrade API, you need to go through the following two steps:

1- To receive information on how a specific order will impact an account, send a POST request to endpoint. The following example is how the body of the request should look like:

{
"account_id": "123456",
"universal_symbol_id": "78910",
"order_type": "Limit",
"time_in_force": "Day",
"action": "BUY",
"units": 1,
"price": 12.9
}

Example of the response:

{
"trade": {
"id": "0987654321",
"account": "ACCOUNTID",
"order_type": "Limit",
"time_in_force": "Day",
"symbol": {
"brokerage_symbol_id": "1234567",
"universal_symbol_id": "8912345",
"currency": {
"id": "012345",
"code": "USD"
},
"local_id": "121314",
"description": "SYMBOL",
"symbol": "SYMBL"
},
"action": "BUY",
"units": 1,
"price": 12.9
},
"trade_impacts": [
{
"account": "778899",
"currency": "023901",
"remaining_cash": -466.0569,
"estimated_commissions": 0.0,
"forex_fees": 0.0
},
{
"account": "12132214",
"currency": "f123123",
"remaining_cash": 667.8219,
"estimated_commissions": 0.0,
"forex_fees": 0.0
}
],
"combined_remaining_balance": {
"account": "99881882",
"currency": "57fs1223",
"cash": 64.5564
}
}

Example of the response for a failed request:

{
"detail": "Not enough cash to place trades",
"status_code": 400,
"code": "1068"
}

2- To place the order you need to send in the trade id (received through calling the Trade Impact endpoint) as a query parameter to the endpoint. The successful request would indicate the status of the order (EXECUTED, ACCEPTED, FAILED, REJECTED, PENDING, etc.) along with other information related to the order placed.

Example of the response:

{
"brokerage_order_id": "123456",
"status": "ACCEPTED",
"symbol": "7891011",
"universal_symbol": {
"id": "123456",
"symbol": "SYMBL",
"description": "Symbol",
"currency": {
"id": "1021993",
"code": "USD",
"name": "US Dollar"
},
"currencies": [],
"type": {
"id": "ceb92399",
"code": "code",
"is_supported": true
}
},
"action": "BUY",
"total_quantity": "1.00000000",
"open_quantity": "1.00000000",
"canceled_quantity": "0.00000000",
"filled_quantity": "0.00000000",
"execution_price": "0.0000",
"limit_price": "12.9000",
"stop_price": null,
"order_type": "Limit",
"time_in_force": "Day",
"time_placed": "2022-01-01T10:08:09.044000-05:00",
"time_updated": "2022-01-01T10:08:09.113000-05:00",
"expiry_date": null
}

Delete an open order

To cancel an open order, you need to POST to the endpoint with the account id in the query params and the brokerage order id in the body of the request.