Table of Contents
- Installation
- Getting Started
- Raw HTTP Response
- Reference
snaptrade.account_information.get_account_activitiessnaptrade.account_information.get_all_user_holdingssnaptrade.account_information.get_user_account_balancesnaptrade.account_information.get_user_account_detailssnaptrade.account_information.get_user_account_order_detailsnaptrade.account_information.get_user_account_orderssnaptrade.account_information.get_user_account_positionssnaptrade.account_information.get_user_account_recent_orderssnaptrade.account_information.get_user_account_return_ratessnaptrade.account_information.get_user_holdingssnaptrade.account_information.list_user_accountssnaptrade.account_information.update_user_accountsnaptrade.api_status.checksnaptrade.authentication.delete_snap_trade_usersnaptrade.authentication.list_snap_trade_userssnaptrade.authentication.login_snap_trade_usersnaptrade.authentication.register_snap_trade_usersnaptrade.authentication.reset_snap_trade_user_secretsnaptrade.connections.detail_brokerage_authorizationsnaptrade.connections.disable_brokerage_authorizationsnaptrade.connections.list_brokerage_authorizationssnaptrade.connections.refresh_brokerage_authorizationsnaptrade.connections.remove_brokerage_authorizationsnaptrade.connections.return_ratessnaptrade.connections.session_eventssnaptrade.experimental_endpoints.get_user_account_order_detail_v2snaptrade.experimental_endpoints.get_user_account_orders_v2snaptrade.experimental_endpoints.get_user_account_recent_orders_v2snaptrade.options.get_options_chainsnaptrade.options.list_option_holdingssnaptrade.reference_data.get_currency_exchange_rate_pairsnaptrade.reference_data.get_partner_infosnaptrade.reference_data.get_security_typessnaptrade.reference_data.get_stock_exchangessnaptrade.reference_data.get_symbolssnaptrade.reference_data.get_symbols_by_tickersnaptrade.reference_data.list_all_brokerage_authorization_typesnaptrade.reference_data.list_all_brokerage_instrumentssnaptrade.reference_data.list_all_brokeragessnaptrade.reference_data.list_all_currenciessnaptrade.reference_data.list_all_currencies_ratessnaptrade.reference_data.symbol_search_user_accountsnaptrade.trading.cancel_ordersnaptrade.trading.cancel_user_account_ordersnaptrade.trading.get_cryptocurrency_pair_quotesnaptrade.trading.get_order_impactsnaptrade.trading.get_user_account_quotessnaptrade.trading.place_bracket_ordersnaptrade.trading.place_crypto_ordersnaptrade.trading.place_force_ordersnaptrade.trading.place_mleg_ordersnaptrade.trading.place_ordersnaptrade.trading.preview_crypto_ordersnaptrade.trading.replace_ordersnaptrade.trading.search_cryptocurrency_pair_instrumentssnaptrade.transactions_and_reporting.get_activitiessnaptrade.transactions_and_reporting.get_reporting_custom_range
Installation
Add to Gemfile:
gem 'snaptrade', '~> 2.0.160'
Getting Started
require 'snaptrade'
configuration = SnapTrade::Configuration.new
configuration.client_id = ENV["SNAPTRADE_CLIENT_ID"]
configuration.consumer_key = ENV["SNAPTRADE_CONSUMER_KEY"]
snaptrade = SnapTrade::Client.new(configuration)
result = snaptrade.account_information.get_account_activities(
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
start_date: "2022-01-24",
end_date: "2022-01-24",
offset: 0,
limit: 1,
type: "BUY,SELL,DIVIDEND",
)
p result
Raw HTTP Response
To access the raw HTTP response, suffix any method with _with_http_info.
result = snaptrade.account_information.get_account_activities_with_http_info(
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
start_date: "2022-01-24",
end_date: "2022-01-24",
offset: 0,
limit: 1,
type: "BUY,SELL,DIVIDEND",
)
p result[0] # [PaginatedUniversalActivity] Deserialized data
p.result[1] # [Integer] HTTP status code
p.result[2] # [Hash] HTTP headers
p.result[3] # [Faraday::Response] Raw HTTP response
Reference
snaptrade.account_information.get_account_activities
Returns all historical transactions for the specified account.
This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options.
Transaction are returned in reverse chronological order, using the trade_date field.
The data returned here is always cached and refreshed once a day.
If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.
🛠️ Usage
result = snaptrade.account_information.get_account_activities(
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
start_date: "2022-01-24",
end_date: "2022-01-24",
offset: 0,
limit: 1,
type: "BUY,SELL,DIVIDEND",
)
p result
⚙️ Parameters
account_id: String
user_id: String
user_secret: String
start_date: Date
The start date (inclusive) of the transaction history to retrieve. If not
provided, the default is the first transaction known to SnapTrade based on
trade_date.
end_date: Date
The end date (inclusive) of the transaction history to retrieve. If not
provided, the default is the last transaction known to SnapTrade based on
trade_date.
offset: Integer
An integer that specifies the starting point of the paginated results. Default is 0.
limit: Integer
An integer that specifies the maximum number of transactions to return. Default of 1000.
type: String
Optional comma separated list of transaction types to filter by. SnapTrade does
a best effort to categorize brokerage transaction types into a common set of
values. Here are some of the most popular values: - BUY - Asset bought. -
SELL - Asset sold. - DIVIDEND - Dividend payout. - CONTRIBUTION - Cash
contribution. - WITHDRAWAL - Cash withdrawal. - REI - Dividend reinvestment.
STOCK_DIVIDEND- A type of dividend where a company distributes shares instead of cash -INTEREST- Interest deposited into the account. -FEE- Fee withdrawn from the account. -TAX- A tax related fee. -OPTIONEXPIRATION- Option expiration event. -OPTIONASSIGNMENT- Option assignment event. -OPTIONEXERCISE- Option exercise event. -TRANSFER- Transfer of assets from one account to another. -SPLIT- A stock share split.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/activities GET
snaptrade.account_information.get_all_user_holdings
Deprecated, please use the account-specific holdings endpoint instead.
List all accounts for the user, plus balances, positions, and orders for each account.
🛠️ Usage
result = snaptrade.account_information.get_all_user_holdings(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
brokerage_authorizations: String
Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations).
🔄 Return
🌐 Endpoint
/holdings GET
snaptrade.account_information.get_user_account_balance
Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade allows holding multiple currencies in the same account.
Check your API key on the Customer Dashboard billing page to see if you have real-time data access:
- If you do, this endpoint returns real-time data.
- If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the manual refresh endpoint.
If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.
🛠️ Usage
result = snaptrade.account_information.get_user_account_balance(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/balances GET
snaptrade.account_information.get_user_account_details
Returns account detail known to SnapTrade for the specified account.
Check your API key on the Customer Dashboard billing page to see if you have real-time data access:
- If you do, this endpoint returns real-time data.
- If you don't, the data is cached and refreshed once a day. If you need real-time, use the manual refresh endpoint.
If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.
🛠️ Usage
result = snaptrade.account_information.get_user_account_details(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
🔄 Return
🌐 Endpoint
/accounts/{accountId} GET
snaptrade.account_information.get_user_account_order_detail
Returns the detail of a single order using the external order ID provided in the request body.
This endpoint only works for single-leg orders at this time. Support for multi-leg orders will be added in the future.
This endpoint is always realtime and does not rely on cached data.
This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint.
🛠️ Usage
result = snaptrade.account_information.get_user_account_order_detail(
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
p result
⚙️ Parameters
brokerage_order_id: String
Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
account_id: String
user_id: String
user_secret: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/orders/details POST
snaptrade.account_information.get_user_account_orders
Returns a list of recent orders in the specified account.
Check your API key on the Customer Dashboard billing page to see if you have real-time data access:
- If you do, this endpoint returns real-time data.
- If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the manual refresh endpoint.
If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.
🛠️ Usage
result = snaptrade.account_information.get_user_account_orders(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
state: "all",
days: 30,
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
state: String
defaults value is set to \"all\"
days: Integer
Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/orders GET
snaptrade.account_information.get_user_account_positions
Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the options endpoint.
Check your API key on the Customer Dashboard billing page to see if you have real-time data access:
- If you do, this endpoint returns real-time data.
- If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the manual refresh endpoint.
If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.
🛠️ Usage
result = snaptrade.account_information.get_user_account_positions(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/positions GET
snaptrade.account_information.get_user_account_recent_orders
A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is always realtime, and only checks the last 24 hours By default only returns executed orders, but that can be changed by setting only_executed to false
🛠️ Usage
result = snaptrade.account_information.get_user_account_recent_orders(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
only_executed: true,
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
only_executed: Boolean
Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well
🔄 Return
🌐 Endpoint
/accounts/{accountId}/recentOrders GET
snaptrade.account_information.get_user_account_return_rates
Returns a list of rate of return percents for a given account. Will include timeframes available from the brokerage, for example "ALL", "1Y", "6M", "3M", "1M"
🛠️ Usage
result = snaptrade.account_information.get_user_account_return_rates(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/returnRates GET
snaptrade.account_information.get_user_holdings
Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained balances, positions and orders endpoints. The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.
Check your API key on the Customer Dashboard billing page to see if you have real-time data access:
- If you do, this endpoint returns real-time data.
- If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the manual refresh endpoint.
If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.
🛠️ Usage
result = snaptrade.account_information.get_user_holdings(
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
p result
⚙️ Parameters
account_id: String
user_id: String
user_secret: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/holdings GET
snaptrade.account_information.list_user_accounts
Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user.
Check your API key on the Customer Dashboard billing page to see if you have real-time data access:
- If you do, this endpoint returns real-time data.
- If you don't, the data is cached and refreshed once a day. If you need real-time, use the manual refresh endpoint.
🛠️ Usage
result = snaptrade.account_information.list_user_accounts(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
🔄 Return
🌐 Endpoint
/accounts GET
snaptrade.account_information.update_user_account
Updates various properties of a specified account.
🛠️ Usage
result = snaptrade.account_information.update_user_account(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "accountId_example",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
The ID of the account to update.
🔄 Return
🌐 Endpoint
/accounts/{accountId} PUT
snaptrade.api_status.check
Check whether the API is operational and verify timestamps.
🛠️ Usage
result = snaptrade.api_status.check
p result
🔄 Return
🌐 Endpoint
/ GET
snaptrade.authentication.delete_snap_trade_user
Deletes a registered user and all associated data. This action is irreversible. This API is asynchronous and will return a 200 status code if the request is accepted. The user and all associated data will be queued for deletion. Once deleted, a USER_DELETED webhook will be sent.
🛠️ Usage
result = snaptrade.authentication.delete_snap_trade_user(
user_id: "snaptrade-user-123",
)
p result
⚙️ Parameters
user_id: String
🔄 Return
🌐 Endpoint
/snapTrade/deleteUser DELETE
snaptrade.authentication.list_snap_trade_users
Returns a list of all registered user IDs. Please note that the response is not currently paginated.
🛠️ Usage
result = snaptrade.authentication.list_snap_trade_users
p result
🌐 Endpoint
/snapTrade/listUsers GET
snaptrade.authentication.login_snap_trade_user
Authenticates a SnapTrade user and returns the Connection Portal URL used for connecting brokerage accounts. Please check this guide for how to integrate the Connection Portal into your app.
Please note that the returned URL expires in 5 minutes.
🛠️ Usage
result = snaptrade.authentication.login_snap_trade_user(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
broker: "ALPACA",
immediate_redirect: true,
custom_redirect: "https://snaptrade.com",
reconnect: "8b5f262d-4bb9-365d-888a-202bd3b15fa1",
connection_type: "read",
show_close_button: true,
dark_mode: true,
connection_portal_version: "v4",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
broker: String
Slug of the brokerage to connect the user to. See the integrations page for a list of supported brokerages and their slugs.
immediateRedirect: Boolean
When set to true, user will be redirected back to the partner's site instead
of the connection portal. This parameter is ignored if the connection portal is
loaded inside an iframe. See the guide on ways to integrate the connection
portal for more information.
customRedirect: String
URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the guide on ways to integrate the connection portal for more information.
reconnect: String
The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the guide on fixing broken connections for more information.
connectionType: ConnectionType
Determines connection permissions (default: read) - read: Data access only. -
trade: Data and trading access. - trade-if-available: Attempts to establish
a trading connection if the brokerage supports it, otherwise falls back to
read-only access automatically.
showCloseButton: Boolean
Controls whether the close (X) button is displayed in the connection portal. When false, you control closing behavior from your app. Defaults to true.
darkMode: Boolean
Enable dark mode for the connection portal. Defaults to false.
connectionPortalVersion: ConnectionPortalVersion
Sets the connection portal version to render. Currently only v4 is supported and is the default. All other versions are deprecated and will automatically be set to v4.
🔄 Return
AuthenticationLoginSnapTradeUser200Response
🌐 Endpoint
/snapTrade/login POST
snaptrade.authentication.register_snap_trade_user
Registers a new SnapTrade user under your Client ID. A user secret will be automatically generated for you and must be properly stored in your system. Most SnapTrade operations require a user ID and user secret to be passed in as parameters.
🛠️ Usage
result = snaptrade.authentication.register_snap_trade_user(
user_id: "snaptrade-user-123",
)
p result
⚙️ Parameters
userId: String
SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.
🔄 Return
🌐 Endpoint
/snapTrade/registerUser POST
snaptrade.authentication.reset_snap_trade_user_secret
Rotates the secret for a SnapTrade user. You might use this if userSecret is compromised. Please note that if you call this endpoint and fail to save the new secret, you'll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect.
🛠️ Usage
result = snaptrade.authentication.reset_snap_trade_user_secret(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
p result
⚙️ Parameters
userId: String
SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.
userSecret: String
SnapTrade User Secret. This is a randomly generated string and should be stored securely. If compromised, please rotate it via the rotate user secret endpoint.
🔄 Return
🌐 Endpoint
/snapTrade/resetUserSecret POST
snaptrade.connections.detail_brokerage_authorization
Returns a single connection for the specified ID.
🛠️ Usage
result = snaptrade.connections.(
authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
p result
⚙️ Parameters
authorization_id: String
user_id: String
user_secret: String
🔄 Return
🌐 Endpoint
/authorizations/{authorizationId} GET
snaptrade.connections.disable_brokerage_authorization
Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections.
Will trigger a disconnect as if it happened naturally, and send a CONNECTION_BROKEN webhook for the connection.
This endpoint is available on test keys. If you would like it enabled on production keys as well, please contact support as it is disabled by default.
🛠️ Usage
result = snaptrade.connections.(
authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
p result
⚙️ Parameters
authorization_id: String
user_id: String
user_secret: String
🔄 Return
BrokerageAuthorizationDisabledConfirmation
🌐 Endpoint
/authorizations/{authorizationId}/disable POST
snaptrade.connections.list_brokerage_authorizations
Returns a list of all connections for the specified user. Note that Connection and Brokerage Authorization are interchangeable, but the term Connection is preferred and used in the doc for consistency.
A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts.
SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one.
🛠️ Usage
result = snaptrade.connections.(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
🔄 Return
🌐 Endpoint
/authorizations GET
snaptrade.connections.refresh_brokerage_authorization
Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. ACCOUNT_HOLDINGS_UPDATED webhook will be sent once the sync completes for each account under the connection.
This endpoint will also trigger a transaction sync for the past day if one has not yet occurred.
Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the Customer Dashboard billing page
🛠️ Usage
result = snaptrade.connections.(
authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
p result
⚙️ Parameters
authorization_id: String
user_id: String
user_secret: String
🔄 Return
BrokerageAuthorizationRefreshConfirmation
🌐 Endpoint
/authorizations/{authorizationId}/refresh POST
snaptrade.connections.remove_brokerage_authorization
Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted.
🛠️ Usage
snaptrade.connections.(
authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
⚙️ Parameters
authorization_id: String
user_id: String
user_secret: String
🌐 Endpoint
/authorizations/{authorizationId} DELETE
snaptrade.connections.return_rates
Returns a list of rate of return percents for a given connection. Will include timeframes available from the brokerage, for example "ALL", "1Y", "6M", "3M", "1M"
🛠️ Usage
result = snaptrade.connections.return_rates(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
authorization_id: String
🔄 Return
🌐 Endpoint
/authorizations/{authorizationId}/returnRates GET
snaptrade.connections.session_events
Returns a list of session events associated with a user.
🛠️ Usage
result = snaptrade.connections.session_events(
partner_client_id: "SNAPTRADETEST",
user_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
session_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
)
p result
⚙️ Parameters
partner_client_id: String
user_id: String
Optional comma separated list of user IDs used to filter the request on specific users
session_id: String
Optional comma separated list of session IDs used to filter the request on specific users
🔄 Return
ConnectionsSessionEvents200ResponseInner
🌐 Endpoint
/sessionEvents GET
snaptrade.experimental_endpoints.get_user_account_order_detail_v2
Returns the detail of a single order using the external order ID provided in the request body.
The V2 order response format includes all legs of the order in the legs list field.
If the order is single legged, legs will be a list of one leg.
This endpoint is always realtime and does not rely on cached data.
This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint.
🛠️ Usage
result = snaptrade.experimental_endpoints.get_user_account_order_detail_v2(
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
)
p result
⚙️ Parameters
brokerage_order_id: String
Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
account_id: String
user_id: String
user_secret: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/orders/details/v2 POST
snaptrade.experimental_endpoints.get_user_account_orders_v2
Returns a list of recent orders in the specified account.
The V2 order response format will include all legs of each order in the legs list field. If the order is single legged, legs will be a list of one leg.
If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.
🛠️ Usage
result = snaptrade.experimental_endpoints.get_user_account_orders_v2(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
state: "all",
days: 30,
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
state: String
defaults value is set to \"all\"
days: Integer
Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/orders/v2 GET
snaptrade.experimental_endpoints.get_user_account_recent_orders_v2
A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting only_executed to false. Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the Customer Dashboard billing page
🛠️ Usage
result = snaptrade.experimental_endpoints.get_user_account_recent_orders_v2(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
only_executed: true,
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
only_executed: Boolean
Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well
🔄 Return
🌐 Endpoint
/accounts/{accountId}/recentOrders/v2 GET
snaptrade.options.get_options_chain
Returns the option chain for the specified symbol in the specified account.
🛠️ Usage
result = snaptrade..(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "accountId_example",
symbol: "symbol_example",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
The ID of the account to get the options chain from.
symbol: String
Universal symbol ID if symbol
🔄 Return
🌐 Endpoint
/accounts/{accountId}/optionsChain GET
snaptrade.options.list_option_holdings
Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the positions endpoint.
Check your API key on the Customer Dashboard billing page to see if you have real-time data access:
- If you do, this endpoint returns real-time data.
- If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the manual refresh endpoint.
🛠️ Usage
result = snaptrade..list_option_holdings(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/options GET
snaptrade.reference_data.get_currency_exchange_rate_pair
Returns an Exchange Rate Pair object for the specified Currency Pair.
🛠️ Usage
result = snaptrade.reference_data.get_currency_exchange_rate_pair(
currency_pair: "currencyPair_example",
)
p result
⚙️ Parameters
currency_pair: String
A currency pair based on currency code for example, CAD-USD
🔄 Return
🌐 Endpoint
/currencies/rates/{currencyPair} GET
snaptrade.reference_data.get_partner_info
Returns configurations for your SnapTrade Client ID, including allowed brokerages and data access.
🛠️ Usage
result = snaptrade.reference_data.get_partner_info
p result
🔄 Return
🌐 Endpoint
/snapTrade/partners GET
snaptrade.reference_data.get_security_types
Return all available security types supported by SnapTrade.
🛠️ Usage
result = snaptrade.reference_data.get_security_types
p result
🔄 Return
🌐 Endpoint
/securityTypes GET
snaptrade.reference_data.get_stock_exchanges
Returns a list of all supported Exchanges.
🛠️ Usage
result = snaptrade.reference_data.get_stock_exchanges
p result
🔄 Return
🌐 Endpoint
/exchanges GET
snaptrade.reference_data.get_symbols
Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned.
🛠️ Usage
result = snaptrade.reference_data.get_symbols(
substring: "AAPL",
)
p result
⚙️ Parameters
substring: String
The search query for symbols.
🔄 Return
🌐 Endpoint
/symbols POST
snaptrade.reference_data.get_symbols_by_ticker
Returns the Universal Symbol object specified by the ticker or the Universal Symbol ID. When a ticker is specified, the first matching result is returned. We largely follow the Yahoo Finance ticker format(click on "Yahoo Finance Market Coverage and Data Delays"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. Please use the ticker with the proper suffix for the best results.
🛠️ Usage
result = snaptrade.reference_data.get_symbols_by_ticker(
query: "query_example",
)
p result
⚙️ Parameters
query: String
The ticker or Universal Symbol ID to look up the symbol with.
🔄 Return
🌐 Endpoint
/symbols/{query} GET
snaptrade.reference_data.list_all_brokerage_authorization_type
Returns a list of all defined Brokerage authorization Type objects.
🛠️ Usage
result = snaptrade.reference_data.(
brokerage: "QUESTRADE,ALPACA",
)
p result
⚙️ Parameters
brokerage: String
Comma separated value of brokerage slugs
🔄 Return
BrokerageAuthorizationTypeReadOnly
🌐 Endpoint
/brokerageAuthorizationTypes GET
snaptrade.reference_data.list_all_brokerage_instruments
Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list.
🛠️ Usage
result = snaptrade.reference_data.list_all_brokerage_instruments(
slug: "QUESTRADE",
)
p result
⚙️ Parameters
slug: String
A short, unique identifier for the brokerage. It is usually the name of the brokerage in capital letters and will never change.
🔄 Return
🌐 Endpoint
/brokerages/{slug}/instruments GET
snaptrade.reference_data.list_all_brokerages
Returns a list of all defined Brokerage objects.
🛠️ Usage
result = snaptrade.reference_data.list_all_brokerages
p result
🔄 Return
🌐 Endpoint
/brokerages GET
snaptrade.reference_data.list_all_currencies
Returns a list of all defined Currency objects.
🛠️ Usage
result = snaptrade.reference_data.list_all_currencies
p result
🔄 Return
🌐 Endpoint
/currencies GET
snaptrade.reference_data.list_all_currencies_rates
Returns a list of all Exchange Rate Pairs for all supported Currencies.
🛠️ Usage
result = snaptrade.reference_data.list_all_currencies_rates
p result
🔄 Return
🌐 Endpoint
/currencies/rates GET
snaptrade.reference_data.symbol_search_user_account
Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned.
The search results are further limited to the symbols supported by the brokerage for which the account is under.
🛠️ Usage
result = snaptrade.reference_data.symbol_search_user_account(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
substring: "AAPL",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
substring: String
The search query for symbols.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/symbols POST
snaptrade.trading.cancel_order
Cancels an order in the specified account. Accepts order IDs for all asset types.
🛠️ Usage
result = snaptrade.trading.cancel_order(
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
p result
⚙️ Parameters
brokerage_order_id: String
Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
user_id: String
user_secret: String
account_id: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/trading/cancel POST
snaptrade.trading.cancel_user_account_order
*This endpoint is deprecated. Please switch to the new cancel order endpoint * Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected.
🛠️ Usage
result = snaptrade.trading.cancel_user_account_order(
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
p result
⚙️ Parameters
brokerage_order_id: String
Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
user_id: String
user_secret: String
account_id: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/orders/cancel POST
snaptrade.trading.get_cryptocurrency_pair_quote
Gets a quote for the specified account.
🛠️ Usage
result = snaptrade.trading.get_cryptocurrency_pair_quote(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
instrument_symbol: "BTC-USD",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
instrument_symbol: String
🔄 Return
🌐 Endpoint
/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote GET
snaptrade.trading.get_order_impact
Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a Trade object and the ID of the object can be used to place the order with the brokerage using the place checked order endpoint. Please note that the Trade object returned expires after 5 minutes. Any order placed using an expired Trade will be rejected.
🛠️ Usage
result = snaptrade.trading.get_order_impact(
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
action: "BUY",
universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
order_type: "Market",
time_in_force: "Day",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
price: 31.33,
stop: 31.33,
units: 10.5,
notional_value: None,
)
p result
⚙️ Parameters
account_id: String
Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
action: ActionStrict
The action describes the intent or side of a trade. This is either BUY or
SELL.
universal_symbol_id: String
Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls.
order_type: OrderTypeStrict
The type of order to place. - For Limit and StopLimit orders, the price
field is required. - For Stop and StopLimit orders, the stop field is
required.
time_in_force: TimeInForceStrict
The Time in Force type for the order. This field indicates how long the order
will remain active before it is executed or expires. Here are the supported
values: - Day - Day. The order is valid only for the trading day on which it
is placed. - GTC - Good Til Canceled. The order is valid until it is executed
or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety
immediately or be canceled completely. - IOC - Immediate Or Cancel. The order
must be executed immediately. Any portion of the order that cannot be filled
immediately will be canceled.
user_id: String
user_secret: String
price: Float
The limit price for Limit and StopLimit orders.
stop: Float
The price at which a stop order is triggered for Stop and StopLimit orders.
units: Float
notional_value: ManualTradeFormNotionalValue
🔄 Return
🌐 Endpoint
/trade/impact POST
snaptrade.trading.get_user_account_quotes
Returns quotes from the brokerage for the specified symbols and account.
The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint.
This endpoint does not work for options quotes.
This endpoint is disabled for free plans by default. Please contact support to enable this endpoint if needed.
🛠️ Usage
result = snaptrade.trading.get_user_account_quotes(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
symbols: "symbols_example",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
use_ticker: true,
)
p result
⚙️ Parameters
user_id: String
user_secret: String
symbols: String
List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator
account_id: String
use_ticker: Boolean
Should be set to True if symbols are comprised of tickers. Defaults to
False if not provided.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/quotes GET
snaptrade.trading.place_bracket_order
Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages
🛠️ Usage
result = snaptrade.trading.place_bracket_order(
action: "BUY",
instrument: {
"symbol" => "AAPL",
"type" => "EQUITY",
},
order_type: "Market",
time_in_force: "Day",
stop_loss: {
"stop_price" => "48.55",
"limit_price" => "48.50",
},
take_profit: {
"limit_price" => "49.95",
},
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
price: 31.33,
stop: 31.33,
units: 10.5,
)
p result
⚙️ Parameters
action: ActionStrictWithOptions
The action describes the intent or side of a trade. This is either BUY or
SELL for Equity symbols or BUY_TO_OPEN, BUY_TO_CLOSE, SELL_TO_OPEN or
SELL_TO_CLOSE for Options.
instrument: TradingInstrument
order_type: OrderTypeStrict
The type of order to place. - For Limit and StopLimit orders, the price
field is required. - For Stop and StopLimit orders, the stop field is
required.
time_in_force: TimeInForceStrict
The Time in Force type for the order. This field indicates how long the order
will remain active before it is executed or expires. Here are the supported
values: - Day - Day. The order is valid only for the trading day on which it
is placed. - GTC - Good Til Canceled. The order is valid until it is executed
or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety
immediately or be canceled completely. - IOC - Immediate Or Cancel. The order
must be executed immediately. Any portion of the order that cannot be filled
immediately will be canceled.
stop_loss: StopLoss
take_profit: TakeProfit
account_id: String
The ID of the account to execute the trade on.
user_id: String
user_secret: String
price: Float
The limit price for Limit and StopLimit orders.
stop: Float
The price at which a stop order is triggered for Stop and StopLimit orders.
units: Float
Number of shares for the order. This can be a decimal for fractional orders.
Must be null if notional_value is provided.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/trading/bracket POST
snaptrade.trading.place_crypto_order
Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order.
🛠️ Usage
result = snaptrade.trading.place_crypto_order(
instrument: {
"symbol" => "BTC",
"type" => "CRYPTOCURRENCY",
},
side: "BUY",
type: "MARKET",
time_in_force: "GTC",
amount: "123.45",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
limit_price: "123.45",
stop_price: "123.45",
post_only: false,
expiration_date: "2024-01-01T00:00:00Z",
)
p result
⚙️ Parameters
instrument: CryptoTradingInstrument
side: ActionStrict
The action describes the intent or side of a trade. This is either BUY or
SELL.
type: CryptoOrderFormType
The type of order to place.
time_in_force: CryptoOrderFormTimeInForce
The Time in Force type for the order. This field indicates how long the order
will remain active before it is executed or expires. - GTC - Good Til
Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or
Kill. The order must be executed in its entirety immediately or be canceled
completely. - IOC - Immediate Or Cancel. The order must be executed
immediately. Any portion of the order that cannot be filled immediately will be
canceled. - GTD - Good Til Date. The order is valid until the specified date.
amount: Float
The amount of the base currency to buy or sell.
user_id: String
user_secret: String
account_id: String
limit_price: Float
The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.
stop_price: Float
The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.
post_only: Boolean
Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
expiration_date: Time
The expiration date of the order. Required if the time_in_force is GTD.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/trading/crypto POST
snaptrade.trading.place_force_order
Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds.
This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the check order impact endpoint.
It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the manual refresh endpoint for this.
🛠️ Usage
result = snaptrade.trading.place_force_order(
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
action: "BUY",
order_type: "Market",
time_in_force: "Day",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
symbol: "AAPL",
trading_session: "REGULAR",
price: 31.33,
stop: 31.33,
units: 10.5,
notional_value: None,
)
p result
⚙️ Parameters
account_id: String
Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
action: ActionStrictWithOptions
The action describes the intent or side of a trade. This is either BUY or
SELL for Equity symbols or BUY_TO_OPEN, BUY_TO_CLOSE, SELL_TO_OPEN or
SELL_TO_CLOSE for Options.
order_type: OrderTypeStrict
The type of order to place. - For Limit and StopLimit orders, the price
field is required. - For Stop and StopLimit orders, the stop field is
required.
time_in_force: TimeInForceStrict
The Time in Force type for the order. This field indicates how long the order
will remain active before it is executed or expires. Here are the supported
values: - Day - Day. The order is valid only for the trading day on which it
is placed. - GTC - Good Til Canceled. The order is valid until it is executed
or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety
immediately or be canceled completely. - IOC - Immediate Or Cancel. The order
must be executed immediately. Any portion of the order that cannot be filled
immediately will be canceled.
user_id: String
user_secret: String
universal_symbol_id: String
The universal symbol ID of the security to trade. Must be 'null' if symbol is
provided, otherwise must be provided.
symbol: String
The security's trading ticker symbol. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'.
trading_session: TradingSession
The trading session for the order. This field indicates which market session the
order will be placed in. This is only available for certain brokerages. Defaults
to REGULAR. Here are the supported values: - REGULAR - Regular trading hours.
EXTENDED- Extended trading hours.
price: Float
The limit price for Limit and StopLimit orders.
stop: Float
The price at which a stop order is triggered for Stop and StopLimit orders.
units: Float
For Equity orders, this represents the number of shares for the order. This can
be a decimal for fractional orders. Must be null if notional_value is
provided. If placing an Option order, this field represents the number of
contracts to buy or sell. (e.g., 1 contract = 100 shares).
notional_value: ManualTradeFormNotionalValue
🔄 Return
🌐 Endpoint
/trade/place POST
snaptrade.trading.place_mleg_order
Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
🛠️ Usage
result = snaptrade.trading.place_mleg_order(
order_type: "MARKET",
time_in_force: "Day",
legs: [
{
"instrument" => {
"symbol" => "PBI 250718C00006000",
"instrument_type" => "OPTION",
},
"action" => "BUY_TO_OPEN",
"units" => 1,
}
],
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
limit_price: "",
stop_price: "",
price_effect: "DEBIT",
)
p result
⚙️ Parameters
order_type: MlegOrderTypeStrict
The type of order to place.
time_in_force: TimeInForceStrict
The Time in Force type for the order. This field indicates how long the order
will remain active before it is executed or expires. Here are the supported
values: - Day - Day. The order is valid only for the trading day on which it
is placed. - GTC - Good Til Canceled. The order is valid until it is executed
or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety
immediately or be canceled completely. - IOC - Immediate Or Cancel. The order
must be executed immediately. Any portion of the order that cannot be filled
immediately will be canceled.
legs: Array<MlegLeg>
user_id: String
user_secret: String
account_id: String
limit_price: Float
The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT.
stop_price: Float
The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT.
price_effect: MlegPriceEffectStrict
🔄 Return
🌐 Endpoint
/accounts/{accountId}/trading/options POST
snaptrade.trading.place_order
Places the previously checked order with the brokerage. The tradeId is obtained from the check order impact endpoint. If you prefer to place the order without checking for impact first, you can use the place order endpoint.
It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the manual refresh endpoint for this.
🛠️ Usage
result = snaptrade.trading.place_order(
trade_id: "139e307a-82f7-4402-b39e-4da7baa87758",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
wait_to_confirm: true,
)
p result
⚙️ Parameters
trade_id: String
Obtained from calling the check order impact endpoint
user_id: String
user_secret: String
wait_to_confirm: Boolean
Optional, defaults to true. Determines if a wait is performed to check on order
status. If false, latency will be reduced but orders returned will be more
likely to be of status PENDING as we will not wait to check on the status
before responding to the request.
🔄 Return
🌐 Endpoint
/trade/{tradeId} POST
snaptrade.trading.preview_crypto_order
Previews an order using the specified account.
🛠️ Usage
result = snaptrade.trading.preview_crypto_order(
instrument: {
"symbol" => "BTC",
"type" => "CRYPTOCURRENCY",
},
side: "BUY",
type: "MARKET",
time_in_force: "GTC",
amount: "123.45",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
limit_price: "123.45",
stop_price: "123.45",
post_only: false,
expiration_date: "2024-01-01T00:00:00Z",
)
p result
⚙️ Parameters
instrument: CryptoTradingInstrument
side: ActionStrict
The action describes the intent or side of a trade. This is either BUY or
SELL.
type: CryptoOrderFormType
The type of order to place.
time_in_force: CryptoOrderFormTimeInForce
The Time in Force type for the order. This field indicates how long the order
will remain active before it is executed or expires. - GTC - Good Til
Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or
Kill. The order must be executed in its entirety immediately or be canceled
completely. - IOC - Immediate Or Cancel. The order must be executed
immediately. Any portion of the order that cannot be filled immediately will be
canceled. - GTD - Good Til Date. The order is valid until the specified date.
amount: Float
The amount of the base currency to buy or sell.
user_id: String
user_secret: String
account_id: String
limit_price: Float
The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.
stop_price: Float
The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.
post_only: Boolean
Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
expiration_date: Time
The expiration date of the order. Required if the time_in_force is GTD.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/trading/crypto/preview POST
snaptrade.trading.replace_order
Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages
🛠️ Usage
result = snaptrade.trading.replace_order(
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
action: "BUY",
order_type: "Market",
time_in_force: "Day",
account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
price: 31.33,
symbol: "AAPL",
stop: 31.33,
units: 10.5,
)
p result
⚙️ Parameters
brokerage_order_id: String
Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
action: ActionStrict
The action describes the intent or side of a trade. This is either BUY or
SELL.
order_type: OrderTypeStrict
The type of order to place. - For Limit and StopLimit orders, the price
field is required. - For Stop and StopLimit orders, the stop field is
required.
time_in_force: TimeInForceStrict
The Time in Force type for the order. This field indicates how long the order
will remain active before it is executed or expires. Here are the supported
values: - Day - Day. The order is valid only for the trading day on which it
is placed. - GTC - Good Til Canceled. The order is valid until it is executed
or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety
immediately or be canceled completely. - IOC - Immediate Or Cancel. The order
must be executed immediately. Any portion of the order that cannot be filled
immediately will be canceled.
account_id: String
The ID of the account to execute the trade on.
user_id: String
user_secret: String
price: Float
The limit price for Limit and StopLimit orders.
symbol: String
The security's trading ticker symbol
stop: Float
The price at which a stop order is triggered for Stop and StopLimit orders.
units: Float
🔄 Return
🌐 Endpoint
/accounts/{accountId}/trading/replace POST
snaptrade.trading.search_cryptocurrency_pair_instruments
Searches cryptocurrency pairs instruments accessible to the specified account. Both base and quote are optional. Omit both for a full list of cryptocurrency pairs.
🛠️ Usage
result = snaptrade.trading.search_cryptocurrency_pair_instruments(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
base: "BTC",
quote: "USD",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
account_id: String
base: String
quote: String
🔄 Return
TradingSearchCryptocurrencyPairInstruments200Response
🌐 Endpoint
/accounts/{accountId}/trading/instruments/cryptocurrencyPairs GET
snaptrade.transactions_and_reporting.get_activities
This endpoint is being deprecated but will continue to be available for use via SDKs, please use the account level endpoint if possible
Returns all historical transactions for the specified user and filtering criteria. It's recommended to use startDate and endDate to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request.
There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the trade_date field if you need them in a specific order.
The data returned here is always cached and refreshed once a day.
🛠️ Usage
result = snaptrade.transactions_and_reporting.get_activities(
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
start_date: "2022-01-24",
end_date: "2022-01-24",
accounts: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
type: "BUY,SELL,DIVIDEND",
)
p result
⚙️ Parameters
user_id: String
user_secret: String
start_date: Date
The start date (inclusive) of the transaction history to retrieve. If not
provided, the default is the first transaction known to SnapTrade based on
trade_date.
end_date: Date
The end date (inclusive) of the transaction history to retrieve. If not
provided, the default is the last transaction known to SnapTrade based on
trade_date.
accounts: String
Optional comma separated list of SnapTrade Account IDs used to filter the
request to specific accounts. If not provided, the default is all known
brokerage accounts for the user. The brokerageAuthorizations parameter takes
precedence over this parameter.
brokerage_authorizations: String
Optional comma separated list of SnapTrade Connection (Brokerage Authorization)
IDs used to filter the request to only accounts that belong to those
connections. If not provided, the default is all connections for the user. This
parameter takes precedence over the accounts parameter.
type: String
Optional comma separated list of transaction types to filter by. SnapTrade does
a best effort to categorize brokerage transaction types into a common set of
values. Here are some of the most popular values: - BUY - Asset bought. -
SELL - Asset sold. - DIVIDEND - Dividend payout. - CONTRIBUTION - Cash
contribution. - WITHDRAWAL - Cash withdrawal. - REI - Dividend reinvestment.
INTEREST- Interest deposited into the account. -FEE- Fee withdrawn from the account. -OPTIONEXPIRATION- Option expiration event. -OPTIONASSIGNMENT- Option assignment event. -OPTIONEXERCISE- Option exercise event. -TRANSFER- Transfer of assets from one account to another
🔄 Return
🌐 Endpoint
/activities GET
snaptrade.transactions_and_reporting.get_reporting_custom_range
Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Please note that Total Equity Timeframe and Rate of Returns are experimental features. Please contact support@snaptrade.com if you notice any inconsistencies.
🛠️ Usage
result = snaptrade.transactions_and_reporting.get_reporting_custom_range(
start_date: "2022-01-24",
end_date: "2022-01-24",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
accounts: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
detailed: true,
frequency: "monthly",
)
p result
⚙️ Parameters
start_date: Date
end_date: Date
user_id: String
user_secret: String
accounts: String
Optional comma separated list of account IDs used to filter the request on specific accounts
detailed: Boolean
Optional, increases frequency of data points for the total value and contribution charts if set to true
frequency: String
Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly.
🔄 Return
🌐 Endpoint
/performance/custom GET
Author
This TypeScript package is automatically generated by Konfig