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

Use a Personal API Key

Use this guide for scripts and tools that access your own brokerage accounts. A Personal API key represents your SnapTrade account directly. If you are building for other users, start with Choose Your Integration.

Get Your Credentials

  1. Create a Personal account in the SnapTrade Dashboard and verify your email.
  2. Enable two-factor authentication.
  3. Create a Personal API key on the API Key page.
  4. Store your clientId and consumerKey securely. They grant access to your own account; do not distribute them to other apps.

If your brokerage is already connected in the Dashboard, skip generating a portal URL and go directly to listing accounts. Otherwise open the returned Connection Portal URL and complete the brokerage connection before continuing.

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 a trusted backend or, for your own Personal tools, in secure local storage.

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

import { Snaptrade, SnaptradeAuth } from "snaptrade-typescript-sdk";
const snaptrade = new Snaptrade({
// Personal auth means your API key is the user context.
auth: SnaptradeAuth.personalApiKey({
clientId: process.env.SNAPTRADE_CLIENT_ID!,
consumerKey: process.env.SNAPTRADE_CONSUMER_KEY!,
}),
});

If your brokerage is already connected in the Dashboard, skip this block. Otherwise, generate a portal URL and complete the connection in your browser.

// Generate connection URL.
const login = await snaptrade.authentication.loginSnapTradeUser();
if (!("redirectURI" in login.data)) throw new Error("Expected a Connection Portal URL");
console.log("Open this Connection Portal URL:", login.data.redirectURI);

Once your brokerage is connected through the Dashboard or Connection Portal, run the following code. Reuse your initialized SDK client.

const accounts = await snaptrade.accountInformation.listAllUserAccounts();
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({
// No userId or userSecret for Personal account-data calls.
accountId: account.id,
});
console.log(positions.data);

Python

import os
from snaptrade_client import SnapTrade, SnapTradeAuth
snaptrade = SnapTrade(
# Personal auth means your API key is the user context.
auth=SnapTradeAuth.personal_api_key(
client_id=os.environ["SNAPTRADE_CLIENT_ID"],
consumer_key=os.environ["SNAPTRADE_CONSUMER_KEY"],
)
)

If your brokerage is already connected in the Dashboard, skip this block. Otherwise, generate a portal URL and complete the connection in your browser.

# Generate connection URL.
login = snaptrade.authentication.login_snap_trade_user()
print("Open this Connection Portal URL:", login.body["redirectURI"])

Once your brokerage is connected through the Dashboard or Connection Portal, run the following code. Reuse your initialized SDK client.

accounts = snaptrade.account_information.list_all_user_accounts()
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(
# No user_id or user_secret for Personal account-data calls.
account_id=account["id"],
)
print(positions.body)

Credential Rules

  • Use SnaptradeAuth.personalApiKey in TypeScript or SnapTradeAuth.personal_api_key in 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 userId and userSecret on account-data operations.
  • Do not call . User registration is for Commercial API-key integrations managing SnapTrade users for their own end users.

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.

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.