For AI agents: the documentation index is available at https://docs.snaptrade.com/llms.txt, and the comprehensive documentation index is available at https://docs.snaptrade.com/llms-full.txt. The complete public OpenAPI specification is available at https://docs.snaptrade.com/openapi.yaml. Complete public OpenAPI specification with all documented operations, schemas, servers, and authentication requirements. Use it for SDK generation and API tooling; beta operations are marked x-beta. Markdown versions of documentation pages are available by appending .md to the URL path.
Guides

Build With a Commercial API Key

Your backend creates a SnapTrade user for each end user and sends them through the Connection Portal. You own onboarding, user mapping, connection support, and credential storage. For apps using users’ existing SnapTrade Personal connections, consider OAuth.

Get Your Credentials

  1. Create a Commercial account in the SnapTrade Dashboard.
  2. Verify your email.
  3. Enable two-factor authentication.
  4. Create a test API key from the API Key page.
  5. Store the clientId and consumerKey on a secure backend.

Connect and Read Account Data

Open the portal URL in a browser, complete the connection, then resume the account-data calls. Keep API credentials on your backend. Use a stable, immutable user ID from your app; avoid email addresses.

Use Commercial API Key authentication when your backend manages brokerage connections for your own end users.

The Commercial workflow is:

  1. Initialize the SDK with Commercial clientId and consumerKey.
  2. Register one SnapTrade user per end user with .
  3. Store the returned userId and userSecret for that SnapTrade user.
  4. Generate a Connection Portal URL with and have the user connect a brokerage account.
  5. After the account is connected, fetch that user's account data by passing userId and userSecret to user-scoped operations.

TypeScript

import { Snaptrade, SnaptradeAuth } from "snaptrade-typescript-sdk";
const snaptrade = new Snaptrade({
// Your app manages each end user’s SnapTrade identity.
auth: SnaptradeAuth.commercialApiKey({
clientId: process.env.SNAPTRADE_CLIENT_ID!,
consumerKey: process.env.SNAPTRADE_CONSUMER_KEY!,
}),
});
// Register once during onboarding; securely persist the returned credentials.
const userId = "snaptrade-user-123";
const registeredUser = await snaptrade.authentication.registerSnapTradeUser({
userId,
});
const userSecret = registeredUser.data.userSecret!;
// Generate connection URL.
const login = await snaptrade.authentication.loginSnapTradeUser({
userId,
userSecret,
});
if (!("redirectURI" in login.data)) throw new Error("Expected a Connection Portal URL");
console.log("Send this Connection Portal URL to your user:", login.data.redirectURI);

After the user completes the Connection Portal, run the following code. Reuse your initialized SDK client and the user's stored credentials.

const accounts = await snaptrade.accountInformation.listAllUserAccounts({
// Commercial account-data calls include the user's credentials.
userId,
userSecret,
});
const account = accounts.data.results.find((account) => account.kind === "investment");
if (!account) throw new Error("No connected investment accounts yet");
const positions = await snaptrade.accountInformation.getAllAccountPositions({
accountId: account.id,
userId,
userSecret,
});
console.log(positions.data);

Python

import os
from snaptrade_client import SnapTrade, SnapTradeAuth
snaptrade = SnapTrade(
# Your app manages each end user’s SnapTrade identity.
auth=SnapTradeAuth.commercial_api_key(
client_id=os.environ["SNAPTRADE_CLIENT_ID"],
consumer_key=os.environ["SNAPTRADE_CONSUMER_KEY"],
)
)
# Register once during onboarding; securely persist the returned credentials.
user_id = "snaptrade-user-123"
registered_user = snaptrade.authentication.register_snap_trade_user(
user_id=user_id,
)
user_secret = registered_user.body["userSecret"]
# Generate connection URL.
login = snaptrade.authentication.login_snap_trade_user(
user_id=user_id,
user_secret=user_secret,
)
print("Send this Connection Portal URL to your user:", login.body["redirectURI"])

After the user completes the Connection Portal, run the following code. Reuse your initialized SDK client and the user's stored credentials.

accounts = snaptrade.account_information.list_all_user_accounts(
# Commercial account-data calls include the user's credentials.
user_id=user_id,
user_secret=user_secret,
)
account = next(
(account for account in accounts.body["results"] if account["kind"] == "investment"),
None,
)
if account is None:
raise RuntimeError("No connected investment accounts yet")
positions = snaptrade.account_information.get_all_account_positions(
account_id=account["id"],
user_id=user_id,
user_secret=user_secret,
)
print(positions.body)

Credential Rules

  • Use SnaptradeAuth.commercialApiKey in TypeScript or SnapTradeAuth.commercial_api_key in Python.
  • Register or otherwise obtain a SnapTrade user's userId and userSecret before fetching that user's account data.
  • Pass userId and userSecret on user-scoped operations such as listing accounts, balances, positions, orders, holdings, activities, and connections.
  • Keep the consumerKey and each user's userSecret on a secure backend. Do not expose them in browser or mobile clients.

Accounts and Trading

After connection, list accounts with . Its results list can contain multiple account kinds; choose an investment account before retrieving positions with . Balances and orders are available through and .

For trading, create the connection with connectionType / connection_type set to trade-if-available. The default read connection type only supports data access. Trading also depends on the key, brokerage, connection, and account capabilities. Build the order with the account ID and brokerage ticker, show the user its details and impact, obtain confirmation, then use . See Trading with SnapTrade for order types and supported assets.

Go to Production

When you are ready for production, complete the Production Access Application and required billing setup, then create a production key.

For plan limits and production requirements, see Billing.

Requests and Next Steps

The SDK signs API-key requests for you. For direct HTTP, follow Request Signatures. See General Errors for authentication and other request failures.