Getting Started
This is an interactive demo to help you get started with the SnapTrade API. You can run the code snippets directly in your browser to see the API in action. By the end of this demo, you will have created a new user, connected a brokerage account, and retrieved account details and positions. Let's get started!
1. Initialize a client with your clientId and consumerKey
You can get your SnapTrade clientId
and consumerKey
by registering for a new account. Once you have your credentials, please enter them below to initialize the SnapTrade client. Please note that your consumerKey
is sensitive information and should be kept secure at all times.
2. Create a new user on SnapTrade
To create a secure brokerage connection, we first need to register a SnapTrade user. Call the Register User endpoint with a unique ID for an end user in your system. Upon success, you should receive a system generated user secret. You can think of the user secret like a per-user API key that provides an additional layer of security for protecting user data. The user id and user secret need to be passed along to all SnapTrade API endpoints that involve access to user data.
3. Connect a brokerage account
Now that the user is created, we are ready to connect their brokerage accounts to SnapTrade. This is done via the SnapTrade Connection Portal. Each Connection Portal session is unique to the user and is generated by calling the Generate Connection Portal URL endpoint passing in the user ID and user secret.
From the response, open the redirect URL in a new browser tab to complete the connection, and close it after you're done.
If you don't have a live brokerage account to test with, you can create a Paper Trading account with Alpaca and select "Alpaca Paper" as the instituion in the Connection Portal when prompted.
4. List connected accounts
Once the end user makes a successful connection, SnapTrade will retrieve all the brokerage accounts that the user has granted access to. You can use the List Accounts endpoint to retrieve all connected accounts. For each account, the id
field uniquely identifies the account within SnapTrade and needs to be passed in for all subsequent account-related API calls.
5. Get account detail
The Account Detail endpoint gives you a detailed view of the account, including account number, name, total market value, and more.
Select a connected account below to retrieve the account detail.
6. Get account positions
The Account Positions endpoint give you a list of stock/ETF/crypto/mutual fund positions in the account.
Option positions are currently returned via a separate Options Positions endpoint.
7. Deleting a user
You've reached the end of this demo! If you want to delete the user you created, you can do so by calling the Delete User endpoint. This will delete the user and all associated data (connections, accounts, positions, etc) permanently.
Get Historical Transactions
Use this interactive demo to retrieve historical transactions from the connected accounts for a SnapTrade user.
1. Initialize SnapTrade client and the connected SnapTrade user
Please copy the values from the Getting Started demo and paste them below.
2. Retrieve historical transactions
Once a user connects a brokerage account, you can retrieve historical transactions using the Transaction History endpoint. This demo retrieves transactions across all connected accounts for the user. To perform additional filtering, please check the API reference.
Please note for accounts with a large number of transactions, it could take a significant amount of time for SnapTrade to initially retrieve and index the data. If you don't see any transactions now, please try again later.
Placing Orders
In this interactive demo, you'll learn how to place equity order using the SnapTrade API. Trading is only available to certain brokerages. See here for a complete list of supported brokerages and their capabilities.
1. Initialize SnapTrade client and the connected SnapTrade user
Please copy the values from the Getting Started demo and paste them below.
2. Create a trade-enabled connection
By default, SnapTrade connections are read-only. To enable trading for a specific connection, you need to pass in connection_type="trade"
when generating the Connection Portal URL.
From the response, open the redirect URL in a new browser tab to complete the connection, and close it after you're done.
If you don't have a live brokerage account to test with, you can create a Paper Trading account with Alpaca and select "Alpaca Paper" as the instituion in the Connection Portal when prompted.
3. List connected accounts
Once the end user makes a successful connection, SnapTrade will retrieve all the brokerage accounts that the user has granted access to. You can use the List Accounts endpoint to retrieve all connected accounts. For each account, the id
field uniquely identifies the account within SnapTrade and needs to be passed in for all subsequent account-related API calls.
4. Identify the instrument to trade
To identify the instrument you want to trade, you need to know the Universal Symbol ID of the instrument. A Universal Symbol is SnapTrade's way to uniquely describe a single security + exchange combination across all brokerages. You can use the Symbol Quote endpoint to find the Universal Symbol ID along with the latest market quote of the instrument you want to trade.
4. Submit an equity order
You can use the Place Order endpoint to submit an equity order under the connected brokerage account.
If the order is successfully placed, you'll receive a response with the order details. You can use the brokerage_order_id
in the response to track the order status. Please double check in your brokerage account to ensure the order was placed successfully.