konfig / snaptrade-php-sdk
Connect brokerage accounts to your app for live positions and trading
Installs: 3 884
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 1
Open Issues: 7
Requires
- php: ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
- dev-master
- dev-main
- v2.0.58
- v2.0.57
- v2.0.56
- v2.0.55
- v2.0.54
- v2.0.53
- v2.0.52
- v2.0.51
- v2.0.50
- v2.0.49
- v2.0.48
- v2.0.47
- v2.0.46
- v2.0.45
- v2.0.44
- v2.0.43
- v2.0.42
- v2.0.41
- v2.0.40
- v2.0.39
- v2.0.38
- v2.0.37
- v2.0.36
- v2.0.35
- v2.0.34
- v2.0.33
- v2.0.32
- v2.0.31
- v2.0.30
- v2.0.29
- v2.0.28
- v2.0.27
- v2.0.26
- v2.0.25
- v2.0.24
- v2.0.23
- v2.0.22
- v2.0.21
- v2.0.20
- v2.0.19
- v2.0.18
- v2.0.17
- v2.0.16
- v2.0.15
- v2.0.14
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.26.13
- v1.26.12
- v1.26.11
- v1.26.10
- v1.26.9
- v1.26.8
- v1.26.7
- v1.26.6
- v1.26.5
- v1.26.4
- v1.26.3
- v1.26.2
- v1.26.1
- v1.26.0
- v1.25.2
- v1.25.1
- v1.25.0
- v1.24.1
- v1.24.0
- v1.23.0
- v1.22.0
- v1.21.0
- v1.20.0
- v1.19.0
- v1.18.0
- v1.17.0
- v1.16.0
- v1.15.0
- v1.14.0
- v1.13.0
- v1.12.0
- v1.11.0
- v1.10.0
- v1.9.0
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- dev-bump
- dev-new-openapi-spec-1733526669958
- dev-new-openapi-spec-1732309723149
- dev-new-openapi-spec-1732200000056
- dev-new-openapi-spec-1731704940562
- dev-new-openapi-spec-1731635600290
- dev-new-openapi-spec-1731612533787
- dev-new-openapi-spec-1731020688893
- dev-new-openapi-spec-1730937566248
- dev-new-openapi-spec-1730250593047
- dev-new-openapi-spec-1730208425289
- dev-new-openapi-spec-1730156439091
- dev-new-openapi-spec-1728308333050
- dev-new-openapi-spec-1727872186832
- dev-new-openapi-spec-1727236781586
- dev-new-openapi-spec-1726939769863
- dev-new-openapi-spec-1725911630114
- dev-new-openapi-spec-1725574439875
- dev-new-openapi-spec-1725542273573
- dev-new-openapi-spec-1725060898552
- dev-new-openapi-spec-1724882834271
- dev-new-openapi-spec-1724419593624
- dev-new-openapi-spec-1724364636157
- dev-new-openapi-spec-1724279176654
- dev-new-openapi-spec-1724202904762
- dev-new-openapi-spec-1724127533946
- dev-new-openapi-spec-1724080143085
- dev-new-openapi-spec-1723821337151
- dev-new-openapi-spec-1723734797988
- dev-new-openapi-spec-1723579427038
- dev-new-openapi-spec-1691612468190
- dev-new-openapi-spec-1689595337599-php
- dev-new-openapi-spec-1689192808858
This package is auto-updated.
Last update: 2024-12-06 23:27:11 UTC
README
SnapTrade
Connect brokerage accounts to your app for live positions and trading
Table of Contents
- Installation & Usage
- Getting Started
- Reference
snaptrade.accountInformation.getAllUserHoldings
snaptrade.accountInformation.getUserAccountBalance
snaptrade.accountInformation.getUserAccountDetails
snaptrade.accountInformation.getUserAccountOrders
snaptrade.accountInformation.getUserAccountPositions
snaptrade.accountInformation.getUserAccountRecentOrders
snaptrade.accountInformation.getUserAccountReturnRates
snaptrade.accountInformation.getUserHoldings
snaptrade.accountInformation.listUserAccounts
snaptrade.accountInformation.updateUserAccount
snaptrade.apiStatus.check
snaptrade.authentication.deleteSnapTradeUser
snaptrade.authentication.listSnapTradeUsers
snaptrade.authentication.loginSnapTradeUser
snaptrade.authentication.registerSnapTradeUser
snaptrade.authentication.resetSnapTradeUserSecret
snaptrade.connections.detailBrokerageAuthorization
snaptrade.connections.disableBrokerageAuthorization
snaptrade.connections.listBrokerageAuthorizations
snaptrade.connections.refreshBrokerageAuthorization
snaptrade.connections.removeBrokerageAuthorization
snaptrade.connections.returnRates
snaptrade.connections.sessionEvents
snaptrade.options.getOptionStrategy
snaptrade.options.getOptionsChain
snaptrade.options.getOptionsStrategyQuote
snaptrade.options.listOptionHoldings
snaptrade.options.placeOptionStrategy
snaptrade.referenceData.getCurrencyExchangeRatePair
snaptrade.referenceData.getPartnerInfo
snaptrade.referenceData.getSecurityTypes
snaptrade.referenceData.getStockExchanges
snaptrade.referenceData.getSymbols
snaptrade.referenceData.getSymbolsByTicker
snaptrade.referenceData.listAllBrokerageAuthorizationType
snaptrade.referenceData.listAllBrokerages
snaptrade.referenceData.listAllCurrencies
snaptrade.referenceData.listAllCurrenciesRates
snaptrade.referenceData.symbolSearchUserAccount
snaptrade.trading.cancelUserAccountOrder
snaptrade.trading.getOrderImpact
snaptrade.trading.getUserAccountQuotes
snaptrade.trading.placeForceOrder
snaptrade.trading.placeOrder
snaptrade.transactionsAndReporting.getActivities
snaptrade.transactionsAndReporting.getReportingCustomRange
Installation & Usage
Requirements
This library requires PHP ^8.0
Composer
To install the bindings via Composer, add the following to composer.json
:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/passiv/snaptrade-php-sdk.git" } ], "require": { "konfig/snaptrade-php-sdk": "2.0.58" } }
Then run composer install
Manual Installation
Download the files and include autoload.php
:
<?php require_once('/path/to/snaptrade-php-sdk/vendor/autoload.php');
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); $snaptrade = new \SnapTrade\Client( clientId: getenv("SNAPTRADE_CLIENT_ID"), consumerKey: getenv("SNAPTRADE_CONSUMER_KEY") ); $result = $snaptrade->accountInformation->getAllUserHoldings( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631" );
Reference
snaptrade.accountInformation.getAllUserHoldings
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->accountInformation->getAllUserHoldings( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631" );
⚙️ 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.accountInformation.getUserAccountBalance
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.
The data returned here is cached. 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 data, please use the manual refresh endpoint.
🛠️ Usage
$result = $snaptrade->accountInformation->getUserAccountBalance( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
🔄 Return
🌐 Endpoint
/accounts/{accountId}/balances
GET
snaptrade.accountInformation.getUserAccountDetails
Returns account detail known to SnapTrade for the specified account.
The data returned here is always cached and refreshed once a day. If you need real-time data, please use the manual refresh endpoint.
🛠️ Usage
$result = $snaptrade->accountInformation->getUserAccountDetails( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
🔄 Return
🌐 Endpoint
/accounts/{accountId}
GET
snaptrade.accountInformation.getUserAccountOrders
Returns a list of recent orders in the specified account.
The data returned here is cached. 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 data, please use the manual refresh endpoint.
🛠️ Usage
$result = $snaptrade->accountInformation->getUserAccountOrders( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", state: "all", days: 30 );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
state: string
defaults value is set to "all"
days: int
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.accountInformation.getUserAccountPositions
Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the options endpoint.
The data returned here is cached. 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 data, please use the manual refresh endpoint.
🛠️ Usage
$result = $snaptrade->accountInformation->getUserAccountPositions( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
🔄 Return
🌐 Endpoint
/accounts/{accountId}/positions
GET
snaptrade.accountInformation.getUserAccountRecentOrders
Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been executed in the last 24 hours as opposed to pending or cancelled orders up to 30 days old Please contact support for access as this endpoint is not enabled by default.
🛠️ Usage
$result = $snaptrade->accountInformation->getUserAccountRecentOrders( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", only_executed: True );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
only_executed: bool
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.accountInformation.getUserAccountReturnRates
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->accountInformation->getUserAccountReturnRates( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
🔄 Return
🌐 Endpoint
/accounts/{accountId}/returnRates
GET
snaptrade.accountInformation.getUserHoldings
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.
The data returned here is cached. 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 data, please use the manual refresh endpoint.
🛠️ Usage
$result = $snaptrade->accountInformation->getUserHoldings( account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" );
⚙️ Parameters
account_id: string
user_id: string
user_secret: string
🔄 Return
🌐 Endpoint
/accounts/{accountId}/holdings
GET
snaptrade.accountInformation.listUserAccounts
Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user.
The data returned here is always cached and refreshed once a day. If you need real-time data, please use the manual refresh endpoint.
🛠️ Usage
$result = $snaptrade->accountInformation->listUserAccounts( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" );
⚙️ Parameters
user_id: string
user_secret: string
🔄 Return
🌐 Endpoint
/accounts
GET
snaptrade.accountInformation.updateUserAccount
Updates various properties of a specified account.
🛠️ Usage
$result = $snaptrade->accountInformation->updateUserAccount( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "accountId_example" );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
The ID of the account to update.
🔄 Return
🌐 Endpoint
/accounts/{accountId}
PUT
snaptrade.apiStatus.check
Check whether the API is operational and verify timestamps.
🛠️ Usage
$result = $snaptrade->apiStatus->check();
🔄 Return
🌐 Endpoint
/
GET
snaptrade.authentication.deleteSnapTradeUser
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->deleteSnapTradeUser( user_id: "snaptrade-user-123" );
⚙️ Parameters
user_id: string
🔄 Return
🌐 Endpoint
/snapTrade/deleteUser
DELETE
snaptrade.authentication.listSnapTradeUsers
Returns a list of all registered user IDs. Please note that the response is not currently paginated.
🛠️ Usage
$result = $snaptrade->authentication->listSnapTradeUsers();
🔄 Return
string[]
🌐 Endpoint
/snapTrade/listUsers
GET
snaptrade.authentication.loginSnapTradeUser
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->loginSnapTradeUser( 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", connection_portal_version: "v4" );
⚙️ 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: bool
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: string
Sets whether the connection should be read-only or trade-enabled. Defaults to read-only if not specified.
connectionPortalVersion: string
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.registerSnapTradeUser
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->registerSnapTradeUser( user_id: "snaptrade-user-123" );
⚙️ 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.resetSnapTradeUserSecret
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->resetSnapTradeUserSecret( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" );
⚙️ 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.detailBrokerageAuthorization
Returns a single connection for the specified ID.
🛠️ Usage
$result = $snaptrade->connections->detailBrokerageAuthorization( 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
🔄 Return
🌐 Endpoint
/authorizations/{authorizationId}
GET
snaptrade.connections.disableBrokerageAuthorization
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.
Please contact us in order to use this endpoint as it is disabled by default.
🛠️ Usage
$result = $snaptrade->connections->disableBrokerageAuthorization( 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
🔄 Return
BrokerageAuthorizationDisabledConfirmation
🌐 Endpoint
/authorizations/{authorizationId}/disable
POST
snaptrade.connections.listBrokerageAuthorizations
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->listBrokerageAuthorizations( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61" );
⚙️ Parameters
user_id: string
user_secret: string
🔄 Return
🌐 Endpoint
/authorizations
GET
snaptrade.connections.refreshBrokerageAuthorization
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.
Please contact support for access as this endpoint is not enabled by default.
🛠️ Usage
$result = $snaptrade->connections->refreshBrokerageAuthorization( 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
🔄 Return
BrokerageAuthorizationRefreshConfirmation
🌐 Endpoint
/authorizations/{authorizationId}/refresh
POST
snaptrade.connections.removeBrokerageAuthorization
Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted.
🛠️ Usage
$snaptrade->connections->removeBrokerageAuthorization( 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
🔄 Return
void (empty response body)
🌐 Endpoint
/authorizations/{authorizationId}
DELETE
snaptrade.connections.returnRates
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->returnRates( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", authorization_id: "87b24961-b51e-4db8-9226-f198f6518a89" );
⚙️ Parameters
user_id: string
user_secret: string
authorization_id: string
🔄 Return
🌐 Endpoint
/authorizations/{authorizationId}/returnRates
GET
snaptrade.connections.sessionEvents
Returns a list of session events associated with a user.
🛠️ Usage
$result = $snaptrade->connections->sessionEvents( 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" );
⚙️ 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.options.getOptionStrategy
Creates an option strategy object that will be used to place an option strategy order.
🛠️ Usage
$result = $snaptrade->options->getOptionStrategy( underlying_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", legs: [ [ "action" => "BUY_TO_OPEN", "option_symbol_id" => "SPY220819P00200000", "quantity" => 1, ] ], strategy_type: "CUSTOM", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "accountId_example" );
⚙️ Parameters
underlying_symbol_id: string
legs: OptionLeg
[]
strategy_type: string
user_id: string
user_secret: string
account_id: string
The ID of the account to create the option strategy object in.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/optionStrategy
POST
snaptrade.options.getOptionsChain
Returns the option chain for the specified symbol in the specified account.
🛠️ Usage
$result = $snaptrade->options->getOptionsChain( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "accountId_example", symbol: "symbol_example" );
⚙️ 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.getOptionsStrategyQuote
Returns a Strategy Quotes object which has latest market data of the specified option strategy.
🛠️ Usage
$result = $snaptrade->options->getOptionsStrategyQuote( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "accountId_example", option_strategy_id: "2bcd7cc3-e922-4976-bce1-9858296801c3" );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
The ID of the account the strategy will be placed in.
option_strategy_id: string
Option strategy id obtained from response when creating option strategy object
🔄 Return
🌐 Endpoint
/accounts/{accountId}/optionStrategy/{optionStrategyId}
GET
snaptrade.options.listOptionHoldings
Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the positions endpoint.
The data returned here is cached. 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 data, please use the manual refresh endpoint.
🛠️ Usage
$result = $snaptrade->options->listOptionHoldings( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631" );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
🔄 Return
🌐 Endpoint
/accounts/{accountId}/options
GET
snaptrade.options.placeOptionStrategy
Places the option strategy order and returns the order record received from the brokerage.
🛠️ Usage
$result = $snaptrade->options->placeOptionStrategy( order_type: "Market", time_in_force: "FOK", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", option_strategy_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", price: 31.33 );
⚙️ Parameters
order_type:
time_in_force:
user_id: string
user_secret: string
account_id: string
The ID of the account to execute the strategy in.
option_strategy_id: string
Option strategy id obtained from response when creating option strategy object
price: float
Trade Price if limit or stop limit order
🔄 Return
🌐 Endpoint
/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute
POST
snaptrade.referenceData.getCurrencyExchangeRatePair
Returns an Exchange Rate Pair object for the specified Currency Pair.
🛠️ Usage
$result = $snaptrade->referenceData->getCurrencyExchangeRatePair( currency_pair: "currencyPair_example" );
⚙️ Parameters
currency_pair: string
A currency pair based on currency code for example, {CAD-USD}
🔄 Return
🌐 Endpoint
/currencies/rates/{currencyPair}
GET
snaptrade.referenceData.getPartnerInfo
Returns configurations for your SnapTrade Client ID, including allowed brokerages and data access.
🛠️ Usage
$result = $snaptrade->referenceData->getPartnerInfo();
🔄 Return
🌐 Endpoint
/snapTrade/partners
GET
snaptrade.referenceData.getSecurityTypes
Return all available security types supported by SnapTrade.
🛠️ Usage
$result = $snaptrade->referenceData->getSecurityTypes();
🔄 Return
🌐 Endpoint
/securityTypes
GET
snaptrade.referenceData.getStockExchanges
Returns a list of all supported Exchanges.
🛠️ Usage
$result = $snaptrade->referenceData->getStockExchanges();
🔄 Return
🌐 Endpoint
/exchanges
GET
snaptrade.referenceData.getSymbols
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->referenceData->getSymbols( substring: "AAPL" );
⚙️ Parameters
substring: string
The search query for symbols.
🔄 Return
🌐 Endpoint
/symbols
POST
snaptrade.referenceData.getSymbolsByTicker
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->referenceData->getSymbolsByTicker( query: "query_example" );
⚙️ Parameters
query: string
The ticker or Universal Symbol ID to look up the symbol with.
🔄 Return
🌐 Endpoint
/symbols/{query}
GET
snaptrade.referenceData.listAllBrokerageAuthorizationType
Returns a list of all defined Brokerage authorization Type objects.
🛠️ Usage
$result = $snaptrade->referenceData->listAllBrokerageAuthorizationType( brokerage: "QUESTRADE,ALPACA" );
⚙️ Parameters
brokerage: string
Comma separated value of brokerage slugs
🔄 Return
BrokerageAuthorizationTypeReadOnly
🌐 Endpoint
/brokerageAuthorizationTypes
GET
snaptrade.referenceData.listAllBrokerages
Returns a list of all defined Brokerage objects.
🛠️ Usage
$result = $snaptrade->referenceData->listAllBrokerages();
🔄 Return
🌐 Endpoint
/brokerages
GET
snaptrade.referenceData.listAllCurrencies
Returns a list of all defined Currency objects.
🛠️ Usage
$result = $snaptrade->referenceData->listAllCurrencies();
🔄 Return
🌐 Endpoint
/currencies
GET
snaptrade.referenceData.listAllCurrenciesRates
Returns a list of all Exchange Rate Pairs for all supported Currencies.
🛠️ Usage
$result = $snaptrade->referenceData->listAllCurrenciesRates();
🔄 Return
🌐 Endpoint
/currencies/rates
GET
snaptrade.referenceData.symbolSearchUserAccount
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->referenceData->symbolSearchUserAccount( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", substring: "AAPL" );
⚙️ 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.cancelUserAccountOrder
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->cancelUserAccountOrder( user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e" );
⚙️ Parameters
user_id: string
user_secret: string
account_id: string
brokerage_order_id: string
Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
🔄 Return
🌐 Endpoint
/accounts/{accountId}/orders/cancel
POST
snaptrade.trading.getOrderImpact
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->getOrderImpact( account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", action: "BUY", universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", order_type: "Market", time_in_force: "FOK", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", price: 31.33, stop: 31.33, units: 10.5, notional_value: None );
⚙️ Parameters
account_id: string
Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
action:
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:
time_in_force:
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.getUserAccountQuotes
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.
🛠️ Usage
$result = $snaptrade->trading->getUserAccountQuotes( 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 );
⚙️ 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: bool
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.placeForceOrder
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->placeForceOrder( account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", action: "BUY", order_type: "Market", time_in_force: "FOK", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", symbol: "AAPL 131124C00240000", price: 31.33, stop: 31.33, units: 10.5, notional_value: None );
⚙️ Parameters
account_id: string
Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
action:
order_type:
time_in_force:
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. This currently only support Options symbols in the 21 character OCC format. For example \"AAPL 131124C00240000\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see here. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'.
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.placeOrder
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->placeOrder( trade_id: "139e307a-82f7-4402-b39e-4da7baa87758", user_id: "snaptrade-user-123", user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61", wait_to_confirm: True );
⚙️ Parameters
trade_id: string
Obtained from calling the check order impact endpoint
user_id: string
user_secret: string
wait_to_confirm: bool
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.transactionsAndReporting.getActivities
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. If you need real-time data, please use the manual refresh endpoint.
🛠️ Usage
$result = $snaptrade->transactionsAndReporting->getActivities( 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" );
⚙️ Parameters
user_id: string
user_secret: string
start_date: \DateTime
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: \DateTime
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.transactionsAndReporting.getReportingCustomRange
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->transactionsAndReporting->getReportingCustomRange( 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" );
⚙️ Parameters
start_date: \DateTime
end_date: \DateTime
user_id: string
user_secret: string
accounts: string
Optional comma separated list of account IDs used to filter the request on specific accounts
detailed: bool
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 PHP package is automatically generated by Konfig