Getting Started with SnapTrade
Introduction
Welcome to SnapTrade! This is intended to be one of the first documents you read when learning how to use the SnapTrade API and will answer many questions you might have while getting started. This document when read from top-to-bottom is also a guide for making your first connection, and will get you set up to start pulling account data and placing trades.
Please see the FAQ of each section, as any questions you might have should be answered there.
If after reading this document you still have questions or need help, please do not hesitate to contact us through our Discord.
For a live demo, see the Getting Started Demo.
API Keys
Your API key consists of a clientId and consumerKey. Please note that your consumerKey is sensitive information and should be kept secure at all times. This API key is used to make any requests to the SnapTrade API, and is the first thing required to get started.
How to: Create a new API Key
When you are ready to get started with SnapTrade and want to start making requests to our API, you will need to create your free and paid API keys. You may create only your free key if preferred.
- Create a SnapTrade account at the SnapTrade Dashboard.
- Verify your email (You cannot create any
API Keysuntil your account is verified). - Generate your free
API Keythrough the SnapTrade Dashboard. - [OPTIONAL] Add a payment method through the Settings > Billing page of the SnapTrade Dashboard.
- [OPTIONAL] Upgrade to Pay-as-you-Go through Settings > Billing page of the SnapTrade Dashboard.
- [OPTIONAL] Generate your paid
API Keythrough the SnapTrade Dashboard.
After completing these steps, you will have two SnapTrade API Keys:
- A free
API Keythat limits the number of concurrent connections. - Optionally, a paid
API Keythat allows for unlimited connections.
These two API keys are essentially the same in terms of functionality, and the core difference between them is that the free API key is limited in terms of the number of concurrent connections you can have. You can use these API keys to make requests to the SnapTrade API.
How to: Make a request to the SnapTrade API
When you have an API Key and want to start using the SnapTrade API, you will need to use your API Key to make requests to the SnapTrade API.
- With your Free
API Key, enter yourclientIdandconsumerKeyinto the corresponding fields of . - Press ‘Send’.
In the box below the ‘request’ you should receive a response from the SnapTrade API. The endpoint is the most basic request you can make to the SnapTrade API.
You can also make this request with any of the SnapTrade SDKs. While we don’t officially support custom setups without an SDK, you can copy the signature generation logic from any of our SDKs if you want to go that route.
SnapTrade SDKs
API Keys FAQ
Users
Your API key will be used to manage a set of SnapTrade users. A SnapTrade user consists of a userId and a userSecret. The userSecret is a randomly generated string and is sensitive information. It should be kept secure at all times.
Typically if you have an application that manages end-users, each end-user of your application will get one SnapTrade user that will be used to manage that end-user’s connections. This way, SnapTrade users will be one-to-one with the end-users of your application.
How to: Create a new SnapTrade User
When you have a working API Key and want to create a new connection for a user, you will first need to register a SnapTrade user.
- Using your API Key, create a request to the endpoint. You will need to provide a unique SnapTrade
userId. This can be anything that is immutable. For this reason, it is recommended to NOT use email addresses for a SnapTradeuserId. - The response you receive from the SnapTrade API will contain the
userIdyou provided and theuserSecretgenerated by SnapTrade. TheuserSecretis a randomly generated string and is sensitive information.
You can list your created users by using the endpoint, and you can delete created users by using the endpoint. If needed, you may reset a user’s userSecret by using the endpoint. Now that you have one or more SnapTrade users under your API Key, you are ready to create connections under these users.
Users FAQ
Connections
Each user under your SnapTrade API key will be used to create and manage connections associated with that user. Each connection is associated one-to-one with a set of credentials to an institution.
How to: Create a new connection for a user
When you have a SnapTrade user and want to get access to their account data and/or place trades for an account, you will need to create a connection for that user.
- Generate a new redirectURI for the SnapTrade Connection Portal using
- Open the generated link. Depending on your application, there are different ways to open this link. See Methods to Integrate the Connection Portal into Your Application.
Once you have successfully completed the Connection Portal Flow, you should have an active connection to work with, and should have access to the accounts under that connection.
Connections FAQ
Accounts
When you create a connection, SnapTrade will automatically sync all accounts under the set of credentials to the brokerage. For example, if you made a new connection to Questrade (a Canadian brokerage) and that connection had a TFSA, an RRSP and an FHSA account under those credentials, SnapTrade would make all these accounts accessible over the SnapTrade API.
Once you have a connected account, you are ready to move on to pulling account data, and placing trades for that account.
How to: Get positions for an account
When you have at least one connected account and want to start making use of the positions, you will first need to get the accountId.
- You can find the
accountIdanywhere over the API where theaccountobject is returned. In this example, use the endpoint to get theaccountIdof the account you wish to pullpositionsfor. - With the
accountId, call . This will return a list of positions in the specified account.
Once you have positions returned, you’re able to make use of the data in analysis, monitoring, or another use-case you might be interested in. Other core endpoints for retrieving account information include and .
How to: Place a checked trade for an account
When you have at least one connected account and want to place a trade in the account, you will need to follow these steps to place a checked order. Note that you may also place an order without checking it.
- You need to get the
universalSymbolIdfor the instrument that you wish to place an order for. You can find this using . - Validate the order with . This is a safe way to check the impact that the trade will have on the account if it is executed, and this is recommended to show on a screen to your user to have them confirm the order. Save the
tradeIdreturned by this endpoint, it will be used in the next step. ThistradeIdwill expire after a few minutes. - Using the
tradeIdreturned from , place the checked order using . This will place the order at the brokerage for the account, and return the response given by the broker.
The order will now show over the endpoint. If it does not, you may need to trigger a refresh for the connection using .
Accounts FAQ
Next Steps
- To get started with Webhooks, see Webhooks
- To get started with implementing the SnapTrade Connection Portal, see Methods to Integrate the Connection Portal into Your Application