For AI agents: the complete documentation index is available at https://docs.snaptrade.com/llms.txt, and the full documentation text is available at https://docs.snaptrade.com/llms-full.txt. Markdown versions of documentation pages are available by appending .md to the URL path.
View as Markdown
Authentication

Generate Connection Portal URL

post
https://api.snaptrade.com/snapTrade/login

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.

Execute an API Request

Authentication Method

Use commercial authentication when acting on behalf of your application and passing end-user credentials with requests that require them.

Credentials
Request Body
brokerstring

Slug of the brokerage to connect the user to. See the integrations page for a list of supported brokerages and their slugs.

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.

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.

reconnectstring

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.

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.

Controls whether the close (X) button is displayed in the connection portal. When false, you control closing behavior from your app. Defaults to true.

darkModeboolean

Enable dark mode for the connection portal. Defaults to false.

localestring

Language the connection portal renders in. en and pt-BR are the languages we ship; any other language is rejected with a 400. Matching is case- and separator-insensitive, so pt-br, pt-BR and pt_BR are equivalent, and a regional tag resolves to the language when we ship it, so en-US renders en. Deliberately not an enum: those equivalent spellings are all accepted by the API, and an enum would have generated SDKs reject them before the request is sent. Screens without translated copy fall back to English individually. Defaults to en.

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.

Request
Installation
$
npm install snaptrade-typescript-sdk
1
import {
2
Snaptrade,
3
SnaptradeAuth,
4
} from "snaptrade-typescript-sdk";
5
6
const snaptrade = new Snaptrade({
7
auth: SnaptradeAuth.commercialApiKey({
8
consumerKey: "CONSUMER_KEY",
9
clientId: "CLIENT_ID",
10
}),
11
});
12
13
const response =
14
await snaptrade.authentication.loginSnapTradeUser(
15
{
16
userId: "USER_ID",
17
userSecret: "USER_SECRET",
18
broker: "ALPACA",
19
immediateRedirect: true,
20
customRedirect: "https://snaptrade.com",
21
reconnect:
22
"8b5f262d-4bb9-365d-888a-202bd3b15fa1",
23
showCloseButton: true,
24
darkMode: true,
25
locale: "pt-BR",
26
connectionPortalVersion: "v4",
27
},
28
);
29
console.log(response.data);

Response fields

object

Redirect uri upon successful login

Connection Portal link to redirect user to connect a brokerage account.

sessionIdstring

ID to identify the connection portal session.

1
{
2
"redirectURI": "https://app.snaptrade.com/snapTrade/redeemToken?token=npVKchZrL0MYIHTusGfADT74r4xXpHkmbxbQDmt0RINLXbQ5cWsvGkPSgMQRxz8/cnxjzL9T2NWLuHuDyidHiCNeXXTb/tVhzC2olSyfxWW6DRrkUppArGCdmkIHyBMzog6C55P8yoqzcGer5Hml0Q%3D%3D&clientId=WEALTHLY&broker=ROBINHOOD&connectionPortalVersion=v4&sessionId=cf371bb4-a475-4f17-ab94-d0fee699960d",
3
"sessionId": "cf371bb4-a475-4f17-ab94-d0fee699960d"
4
}