Authentication Methods
SnapTrade supports two SDK authentication modes for API key integrations: Commercial API key and Personal API key. The selected SDK auth mode controls whether userId and userSecret are valid operation parameters.
Commercial apps own many SnapTrade users. They register or authenticate a SnapTrade user, then fetch account data by passing that user's userId and userSecret.
Your Personal API key identifies your SnapTrade account directly. Account data is fetched without userId or userSecret.
In both modes, generate a Connection Portal URL and connect a brokerage account before calling account-data APIs.
Quick Comparison
| Method | Best for | SDK auth setup | Account-data operation credentials |
|---|---|---|---|
| Commercial API key | Apps managing many end users | SnaptradeAuth.commercialApiKey(...) / SnapTradeAuth.commercial_api_key(...) | Pass userId and userSecret |
| Personal API key | You, when calling SnapTrade with your own API key | SnaptradeAuth.personalApiKey(...) / SnapTradeAuth.personal_api_key(...) | Omit userId and userSecret |
For a broader product-model comparison, see SnapTrade Personal vs Commercial.
Commercial API Key Authentication
Use Commercial API key authentication when your backend manages brokerage connections for your own end users.
The Commercial workflow is:
- Initialize the SDK with Commercial
clientIdandconsumerKey. - Register one SnapTrade user per end user with .
- Store the returned
userIdanduserSecretfor that SnapTrade user. - Generate a Connection Portal URL with and have the user connect a brokerage account.
- After the account is connected, fetch that user's account data by passing
userIdanduserSecretto user-scoped operations.
TypeScript
Python
Rules:
- Use
SnaptradeAuth.commercialApiKeyin TypeScript orSnapTradeAuth.commercial_api_keyin Python. - Register or otherwise obtain a SnapTrade user's
userIdanduserSecretbefore fetching that user's account data. - Pass
userIdanduserSecreton user-scoped operations such as listing accounts, balances, positions, orders, holdings, activities, and connections. - Keep the
consumerKeyand each user'suserSecreton a secure backend. Do not expose them in browser or mobile clients.
Personal API Key Authentication
Use Personal API key authentication when you call SnapTrade with your own Personal API key.
Your Personal clientId and consumerKey identify your SnapTrade account. There is no separate SnapTrade end-user record to register or pass on account-data calls. Generate a Connection Portal URL, connect your brokerage account, then fetch account data directly.
TypeScript
Python
Rules:
- Use
SnaptradeAuth.personalApiKeyin TypeScript orSnapTradeAuth.personal_api_keyin Python. - Generate a Connection Portal URL and connect your brokerage account before fetching account data.
- Fetch account data directly after connection. Your Personal API key identifies your SnapTrade account.
- Omit
userIdanduserSecreton account-data operations. - Do not call . User registration is for Commercial apps managing SnapTrade users for their own end users.
Credential Rules
Commercial API key:
- SDK initialization uses Commercial
clientIdandconsumerKeythrough the Commercial API key auth helper. - User-management operations register and authenticate individual SnapTrade users.
- User-scoped account-data calls include
userIdanduserSecret. - Direct HTTP requests are signed with the Commercial
consumerKey.
Personal API key:
- SDK initialization uses Personal
clientIdandconsumerKeythrough the Personal API key auth helper. - Your Personal API key identifies your SnapTrade account.
- Connection Portal login uses the Personal API key context and does not require
userIdoruserSecret. - Account-data calls omit
userIdanduserSecret. - Direct HTTP requests are signed with the Personal
consumerKey.
Direct HTTP Reference
Prefer the SDKs unless you need to debug a raw request.
Commercial API key requests include clientId, timestamp, a Signature header, and user credentials for user-scoped endpoints:
# Commercial signed requests include the SnapTrade user's credentials. GET /api/v1/accounts/<account_id>/activities?clientId=<client_id>×tamp=<unix_timestamp>&userId=<user_id>&userSecret=<user_secret> Signature: <signature>
Personal API key requests include clientId, timestamp, and a Signature header, but omit user credentials:
# Personal signed requests omit user credentials. GET /api/v1/accounts/<account_id>/activities?clientId=<client_id>×tamp=<unix_timestamp> Signature: <signature>
For signature details, see Request Signatures.