npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

snaptrade-typescript-sdk

v10.0.13

Published

Client for SnapTrade

Downloads

69,389

Readme

Visit SnapTrade

SnapTrade

Connect brokerage accounts to your app for live positions and trading

npm More Info

Table of Contents

Installation

npm i snaptrade-typescript-sdk
pnpm i snaptrade-typescript-sdk
yarn add snaptrade-typescript-sdk

Getting Started

const { Snaptrade } = require("snaptrade-typescript-sdk");
const { randomUUID } = require("crypto");
const readline = require("readline");

async function main() {
  // 1) Initialize a client with your clientID and consumerKey.
  const snaptrade = new Snaptrade({
    consumerKey: process.env.SNAPTRADE_CONSUMER_KEY,
    clientId: process.env.SNAPTRADE_CLIENT_ID,
  });

  // 2) Check that the client is able to make a request to the API server.
  const status = await snaptrade.apiStatus.check();
  console.log("status:", status.data);

  // 3) Create a new user on SnapTrade
  const userId = randomUUID();
  const registerResponse = (
    await snaptrade.authentication.registerSnapTradeUser({
      userId,
    })
  ).data;
  console.log("registerResponse:", registerResponse);

  // Note: A user secret is only generated once. It's required to access
  // resources for certain endpoints.
  const userSecret = registerResponse.userSecret;

  // 4) Get a redirect URI. Users will need this to connect
  // their brokerage to the SnapTrade server.
  const redirectURI = (
    await snaptrade.authentication.loginSnapTradeUser({ userId, userSecret })
  ).data;
  console.log("redirectURI:", redirectURI);

  await waitForEnter(
    "Open the link in your browser. When done logging in, press Enter to continue..."
  );

  // 5) Get a list of connections
  const connections = (
    await snaptrade.connections.listBrokerageAuthorizations({
      userId,
      userSecret,
    })
  ).data;
  console.log("connections:", connections);

  // 6) Get a list of accounts for the first connection, if available
  if (!Array.isArray(connections) || connections.length === 0) {
    console.log("No brokerage connections found for the user.");
  } else {
    const accounts = (
      await snaptrade.connections.listBrokerageAuthorizationAccounts({
        authorizationId: connections[0].id,
        userId,
        userSecret,
      })
    ).data;
    console.log("accounts:", accounts);
  }

  // 6) Deleting a user
  const deleteResponse = (
    await snaptrade.authentication.deleteSnapTradeUser({ userId })
  ).data;
  console.log("deleteResponse:", deleteResponse);
}

function waitForEnter(prompt) {
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
  });

  return new Promise((resolve) => {
    rl.question(prompt, () => {
      rl.close();
      resolve();
    });
  });
}

main();

Reference

snaptrade.accountInformation.getAccountActivities

Returns all historical transactions for the specified account.

This endpoint is paginated with a default page size of 1000. The endpoint will return a maximum of 1000 transactions per request. See the query parameters for pagination options.

Transaction are returned in reverse chronological order, using the trade_date field.

This endpoint returns Daily data. Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage.

If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.

🛠️ Usage

const getAccountActivitiesResponse =
  await snaptrade.accountInformation.getAccountActivities({
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    startDate: "2022-01-24",
    endDate: "2022-01-24",
    type: "BUY,SELL,DIVIDEND",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

accountId: string
userId: string
userSecret: string
startDate: string | Date

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.

endDate: string | Date

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.

offset: number

An integer that specifies the starting point of the paginated results. Default is 0.

limit: number

An integer that specifies the maximum number of transactions to return. Default of 1000.

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. - STOCK_DIVIDEND - A type of dividend where a company distributes shares instead of cash - INTEREST - Interest deposited into the account. - FEE - Fee withdrawn from the account. - TAX - A tax related fee. - OPTIONEXPIRATION - Option expiration event. - OPTIONASSIGNMENT - Option assignment event. - OPTIONEXERCISE - Option exercise event. - TRANSFER - Transfer of assets from one account to another. - SPLIT - A stock share split.

🔄 Return

PaginatedUniversalActivity

🌐 Endpoint

/accounts/{accountId}/activities GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getAccountBalanceHistory

An experimental endpoint that returns estimated historical total account value for the specified account. Total account value is the sum of the market value of all positions and cash in the account at a given time. This endpoint is experimental, disabled by default, and has a maximum lookback of 1 year.

🛠️ Usage

const getAccountBalanceHistoryResponse =
  await snaptrade.accountInformation.getAccountBalanceHistory({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

🔄 Return

AccountValueHistoryResponse

🌐 Endpoint

/accounts/{accountId}/balanceHistory GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getAllAccountPositions

Returns a list of all positions in the specified account.

The results list can contain multiple instrument types in the same response, including stocks, ADRs, ETFs, mutual funds, closed-end funds, crypto, futures, and option positions. Use the instrument.kind discriminator to determine the schema for each position's instrument.

mutualfund positions may also include cash_equivalent. stock positions may include tax_lots when tax lot data is enabled for the account.

If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.

🛠️ Usage

const getAllAccountPositionsResponse =
  await snaptrade.accountInformation.getAllAccountPositions({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

🔄 Return

AllAccountPositionsResponse

🌐 Endpoint

/accounts/{accountId}/positions/all GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getAllUserHoldings

Deprecated

Deprecated, please use the account-specific holdings endpoint instead.

List all accounts for the user, plus balances, positions, and orders for each account.

Note: This endpoint will return HTTP 410 Gone for all customers that sign up after April 25, 2026.

🛠️ Usage

const getAllUserHoldingsResponse =
  await snaptrade.accountInformation.getAllUserHoldings({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    brokerageAuthorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
brokerageAuthorizations: string

Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations).

🔄 Return

AccountHoldings

🌐 Endpoint

/holdings GET

🔙 Back to Table of Contents


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.

Check your API key on the Customer Dashboard billing page to see if you have real-time data access:

  • If you do, this endpoint returns real-time data.
  • If you don't, Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. If you need real-time, use the manual refresh endpoint.

If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.

🛠️ Usage

const getUserAccountBalanceResponse =
  await snaptrade.accountInformation.getUserAccountBalance({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

🔄 Return

Balance

🌐 Endpoint

/accounts/{accountId}/balances GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserAccountDetails

Returns account detail known to SnapTrade for the specified account.

Check your API key on the Customer Dashboard billing page to see if you have real-time data access:

  • If you do, this endpoint returns real-time data.
  • If you don't, Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. If you need real-time, use the manual refresh endpoint.

If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.

🛠️ Usage

const getUserAccountDetailsResponse =
  await snaptrade.accountInformation.getUserAccountDetails({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

🔄 Return

Account

🌐 Endpoint

/accounts/{accountId} GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserAccountOrderDetail

Returns the detail of a single order using the external order ID provided in the request body.

This endpoint only works for single-leg orders at this time. Support for multi-leg orders will be added in the future.

This endpoint is always realtime and does not rely on cached data.

This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint.

🛠️ Usage

const getUserAccountOrderDetailResponse =
  await snaptrade.accountInformation.getUserAccountOrderDetail({
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
  });

⚙️ Parameters

brokerage_order_id: string

Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.

accountId: string
userId: string
userSecret: string

🔄 Return

AccountOrderRecord

🌐 Endpoint

/accounts/{accountId}/orders/details POST

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserAccountOrders

Returns a list of recent orders in the specified account.

Check your API key on the Customer Dashboard billing page to see if you have real-time data access:

  • If you do, this endpoint returns real-time data.
  • If you don't, Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. If you need real-time, use the manual refresh endpoint.

If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.

🛠️ Usage

const getUserAccountOrdersResponse =
  await snaptrade.accountInformation.getUserAccountOrders({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    state: "all",
    days: 30,
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string
state: 'all' | 'open' | 'executed'

defaults to "all"

days: number

Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in. Values greater than 90 will be capped at 90.

🔄 Return

AccountOrderRecord

🌐 Endpoint

/accounts/{accountId}/orders GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserAccountPositions

Deprecated

Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the options endpoint.

This endpoint is deprecated. Consider using the newer unified positions endpoint. This will allow you to get both equity and option positions in a single call, as well as additional asset classes such as futures.

Check your API key on the Customer Dashboard billing page to see if you have real-time data access:

  • If you do, this endpoint returns real-time data.
  • If you don't, Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. If you need real-time, use the manual refresh endpoint.

If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.

🛠️ Usage

const getUserAccountPositionsResponse =
  await snaptrade.accountInformation.getUserAccountPositions({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

🔄 Return

Position

🌐 Endpoint

/accounts/{accountId}/positions GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserAccountRecentOrders

A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is always realtime, and only checks the last 24 hours By default only returns executed orders, but that can be changed by setting only_executed to false

🛠️ Usage

const getUserAccountRecentOrdersResponse =
  await snaptrade.accountInformation.getUserAccountRecentOrders({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string
onlyExecuted: boolean

Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well

🔄 Return

RecentOrdersResponse

🌐 Endpoint

/accounts/{accountId}/recentOrders GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserAccountReturnRates

Returns a list of rate of return percents for a given account.

🛠️ Usage

const getUserAccountReturnRatesResponse =
  await snaptrade.accountInformation.getUserAccountReturnRates({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    timeframes: "ALL,1Y",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string
timeframes: string

Optional comma separated list of rate-of-return timeframes to return. Supported values are ALL, 1Y, YTD, 1M, 1W, and 1D. If omitted, SnapTrade returns all six supported timeframes.

🔄 Return

RateOfReturnResponse

🌐 Endpoint

/accounts/{accountId}/returnRates GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserHoldings

Deprecated

Deprecated. Use the finer-grained account data endpoints instead: balances, positions, and orders. Returns a list of balances, positions, and recent orders for the specified account.

Check your API key on the Customer Dashboard billing page to see if you have real-time data access:

  • If you do, this endpoint returns real-time data.
  • If you don't, Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. If you need real-time, use the manual refresh endpoint.

If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.

🛠️ Usage

const getUserHoldingsResponse =
  await snaptrade.accountInformation.getUserHoldings({
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

accountId: string
userId: string
userSecret: string

🔄 Return

AccountHoldingsAccount

🌐 Endpoint

/accounts/{accountId}/holdings GET

🔙 Back to Table of Contents


snaptrade.accountInformation.listUserAccounts

Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user.

This endpoint returns Daily data regardless of the customer's plan. Daily data is cached and refreshed once a day, which makes this endpoint fast and well-suited to listing accounts across all of a user's connections in a single call. Exact refresh timing may vary by brokerage. To get real-time data on Pay as you Go / Real-time, use the list accounts for a connection endpoint. Customers on Pay as you Go / Daily can force a refresh with the manual refresh endpoint.

🛠️ Usage

const listUserAccountsResponse =
  await snaptrade.accountInformation.listUserAccounts({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

userId: string
userSecret: string

🔄 Return

Account

🌐 Endpoint

/accounts GET

🔙 Back to Table of Contents


snaptrade.accountInformation.updateUserAccount

Updates various properties of a specified account.

🛠️ Usage

const updateUserAccountResponse =
  await snaptrade.accountInformation.updateUserAccount({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    accountId: "accountId_example",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account to update.

🔄 Return

Account

🌐 Endpoint

/accounts/{accountId} PUT

🔙 Back to Table of Contents


snaptrade.apiStatus.check

Check whether the API is operational and verify timestamps.

🛠️ Usage

const checkResponse = await snaptrade.apiStatus.check();

🔄 Return

Status

🌐 Endpoint

/ GET

🔙 Back to Table of Contents


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

const deleteSnapTradeUserResponse =
  await snaptrade.authentication.deleteSnapTradeUser({
    userId: "snaptrade-user-123",
  });

⚙️ Parameters

userId: string

🔄 Return

DeleteUserResponse

🌐 Endpoint

/snapTrade/deleteUser DELETE

🔙 Back to Table of Contents


snaptrade.authentication.listSnapTradeUsers

Returns a list of all registered user IDs. Please note that the response is not currently paginated.

🛠️ Usage

const listSnapTradeUsersResponse =
  await snaptrade.authentication.listSnapTradeUsers();

🌐 Endpoint

/snapTrade/listUsers GET

🔙 Back to Table of Contents


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

const loginSnapTradeUserResponse =
  await snaptrade.authentication.loginSnapTradeUser({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    broker: "ALPACA",
    immediateRedirect: true,
    customRedirect: "https://snaptrade.com",
    reconnect: "8b5f262d-4bb9-365d-888a-202bd3b15fa1",
    connectionType: "read",
    showCloseButton: true,
    darkMode: true,
    connectionPortalVersion: "v4",
  });

⚙️ Parameters

userId: string
userSecret: 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: boolean

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

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.

showCloseButton: boolean

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

darkMode: boolean

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

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

🔙 Back to Table of Contents


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

const registerSnapTradeUserResponse =
  await snaptrade.authentication.registerSnapTradeUser({
    userId: "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

UserIDandSecret

🌐 Endpoint

/snapTrade/registerUser POST

🔙 Back to Table of Contents


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

const resetSnapTradeUserSecretResponse =
  await snaptrade.authentication.resetSnapTradeUserSecret({
    userId: "snaptrade-user-123",
    userSecret: "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

UserIDandSecret

🌐 Endpoint

/snapTrade/resetUserSecret POST

🔙 Back to Table of Contents


snaptrade.connections.deleteConnection

Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is asynchronous, a 200 response indicates that a task has been queued to delete the connection. Listen for the CONNECTION_DELETED webhook webhook to know when the deletion has been completed and the data has been removed.

🛠️ Usage

const deleteConnectionResponse = await snaptrade.connections.deleteConnection({
  connectionId: "87b24961-b51e-4db8-9226-f198f6518a89",
  userId: "snaptrade-user-123",
  userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
});

⚙️ Parameters

connectionId: string
userId: string
userSecret: string

🔄 Return

DeleteConnectionConfirmation

🌐 Endpoint

/connection/{connectionId} DELETE

🔙 Back to Table of Contents


snaptrade.connections.detailBrokerageAuthorization

Returns a single connection for the specified ID.

🛠️ Usage

const detailBrokerageAuthorizationResponse =
  await snaptrade.connections.detailBrokerageAuthorization({
    authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

authorizationId: string
userId: string
userSecret: string

🔄 Return

BrokerageAuthorization

🌐 Endpoint

/authorizations/{authorizationId} GET

🔙 Back to Table of Contents


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.

This endpoint is available on test keys. If you would like it enabled on production keys as well, please contact support as it is disabled by default.

🛠️ Usage

const disableBrokerageAuthorizationResponse =
  await snaptrade.connections.disableBrokerageAuthorization({
    authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

authorizationId: string
userId: string
userSecret: string

🔄 Return

BrokerageAuthorizationDisabledConfirmation

🌐 Endpoint

/authorizations/{authorizationId}/disable POST

🔙 Back to Table of Contents


snaptrade.connections.listBrokerageAuthorizationAccounts

Returns all brokerage accounts that belong to the specified connection for the authenticated user.

On Pay as you Go / Real-time, this endpoint refreshes each account's opening date, funding date, and total value live from the brokerage on each call.

On Pay as you Go / Daily, this endpoint returns Daily data. Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. To force a refresh, use the manual refresh endpoint.

Check your API key on the Customer Dashboard billing page to see whether your plan includes real-time data.

🛠️ Usage

const listBrokerageAuthorizationAccountsResponse =
  await snaptrade.connections.listBrokerageAuthorizationAccounts({
    authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

authorizationId: string
userId: string
userSecret: string

🔄 Return

Account

🌐 Endpoint

/authorizations/{authorizationId}/accounts GET

🔙 Back to Table of Contents


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

const listBrokerageAuthorizationsResponse =
  await snaptrade.connections.listBrokerageAuthorizations({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

userId: string
userSecret: string

🔄 Return

BrokerageAuthorization

🌐 Endpoint

/authorizations GET

🔙 Back to Table of Contents


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. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred.

Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the Customer Dashboard billing page Please note this endpoint is disabled for Real-time plans (Personal and Pay as you go) unless the connection is delayed. Real-time connections do not benefit from this feature since data is refreshed when calls are made. Refer to the data_freshness_mode field on a connection to determine this.

🛠️ Usage

const refreshBrokerageAuthorizationResponse =
  await snaptrade.connections.refreshBrokerageAuthorization({
    authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

authorizationId: string
userId: string
userSecret: string

🔄 Return

BrokerageAuthorizationRefreshConfirmation

🌐 Endpoint

/authorizations/{authorizationId}/refresh POST

🔙 Back to Table of Contents


snaptrade.connections.removeBrokerageAuthorization

Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted.

🛠️ Usage

const removeBrokerageAuthorizationResponse =
  await snaptrade.connections.removeBrokerageAuthorization({
    authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

authorizationId: string
userId: string
userSecret: string

🌐 Endpoint

/authorizations/{authorizationId} DELETE

🔙 Back to Table of Contents


snaptrade.connections.returnRates

Returns a list of rate of return percents for a given connection.

🛠️ Usage

const returnRatesResponse = await snaptrade.connections.returnRates({
  userId: "snaptrade-user-123",
  userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
  timeframes: "ALL,1Y",
});

⚙️ Parameters

userId: string
userSecret: string
authorizationId: string
timeframes: string

Optional comma separated list of rate-of-return timeframes to return. Supported values are ALL, 1Y, YTD, 1M, 1W, and 1D. If omitted, SnapTrade returns all six supported timeframes.

🔄 Return

RateOfReturnResponse

🌐 Endpoint

/authorizations/{authorizationId}/returnRates GET

🔙 Back to Table of Contents


snaptrade.connections.sessionEvents

Returns a list of session events associated with a user.

🛠️ Usage

const sessionEventsResponse = await snaptrade.connections.sessionEvents({
  partnerClientId: "SNAPTRADETEST",
  userId:
    "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
  sessionId:
    "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
});

⚙️ Parameters

partnerClientId: string
userId: string

Optional comma separated list of user IDs used to filter the request on specific users

sessionId: string

Optional comma separated list of session IDs used to filter the request on specific users

🔄 Return

ConnectionsSessionEvents200ResponseInner

🌐 Endpoint

/sessionEvents GET

🔙 Back to Table of Contents


snaptrade.connections.syncBrokerageAuthorizationTransactions

Trigger a transactions sync for all accounts under this connection. Updates will be queued asynchronously. Transactions are not updated intra-day, but calling this endpoint can ensure that the previous day's transactions have been synced. For more information on sync behaviour, see: https://docs.snaptrade.com/docs/syncing

🛠️ Usage

const syncBrokerageAuthorizationTransactionsResponse =
  await snaptrade.connections.syncBrokerageAuthorizationTransactions({
    authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

authorizationId: string
userId: string
userSecret: string

🔄 Return

BrokerageAuthorizationTransactionsSyncConfirmation

🌐 Endpoint

/authorizations/{authorizationId}/transactions/sync POST

🔙 Back to Table of Contents


snaptrade.experimentalEndpoints.addSubscription

Adds or restores a Trade Detection subscription for a connected brokerage account. This endpoint requires userId and userSecret in addition to the partner signature.

🛠️ Usage

const addSubscriptionResponse =
  await snaptrade.experimentalEndpoints.addSubscription({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    check_interval_seconds: 300,
  });

⚙️ Parameters

account_id: string

Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.

check_interval_seconds: number

How often the subscribed account should be checked for new trades. Must match an active Trade Detection plan.

userId: string
userSecret: string

🔄 Return

TradeDetectionSubscription

🌐 Endpoint

/snapTrade/tradeDetection/subscriptions POST

🔙 Back to Table of Contents


snaptrade.experimentalEndpoints.cancelSubscription

Cancels a Trade Detection subscription for a connected brokerage account. This endpoint requires partner signature authentication only and does not require userId or userSecret.

🛠️ Usage

const cancelSubscriptionResponse =
  await snaptrade.experimentalEndpoints.cancelSubscription({
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

account_id: string

Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.

🔄 Return

TradeDetectionCancelSubscriptionResponse

🌐 Endpoint

/snapTrade/tradeDetection/subscriptions/cancel POST

🔙 Back to Table of Contents


snaptrade.experimentalEndpoints.getUserAccountOrderDetailV2

Returns the detail of a single order using the brokerage order ID provided as a path parameter.

The V2 order response format includes all legs of the order in the legs list field. If the order is single legged, legs will be a list of one leg.

This endpoint is always realtime and does not rely on cached data.

This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint.

🛠️ Usage

const getUserAccountOrderDetailV2Response =
  await snaptrade.experimentalEndpoints.getUserAccountOrderDetailV2({
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    brokerageOrderId: "66a033fa-da74-4fcf-b527-feefdec9257e",
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  });

⚙️ Parameters

accountId: string
brokerageOrderId: string
userId: string
userSecret: string

🔄 Return

AccountOrderRecordV2

🌐 Endpoint

/accounts/{accountId}/orders/details/v2/{brokerageOrderId} GET

🔙 Back to Table of Contents


snaptrade.experimentalEndpoints.getUserAccountOrdersV2

Returns a list of recent orders in the specified account.

The V2 order response format will include all legs of each order in the legs list field. If the order is single legged, legs will be a list of one leg.

If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see this guide on how to fix a disabled connection.

🛠️ Usage

const getUserAccountOrdersV2Response =
  await snaptrade.experimentalEndpoints.getUserAccountOrdersV2({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    state: "all",
    days: 30,
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string
state: 'all' | 'open' | 'executed'

defaults to "all"

days: number

Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in. Values greater than 90 will be capped at 90.

🔄 Return

AccountOrdersV2Response

🌐 Endpoint

/accounts/{accountId}/orders/v2 GET

🔙 Back to Table of Contents


snaptrade.experimentalEndpoints.getUserAccountRecentOrdersV2

A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting only_executed to false. Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the Customer Dashboard billing page

🛠️ Usage

const getUserAccountRecentOrdersV2Response =
  await snaptrade.experimentalEndpoints.getUserAccountRecentOrdersV2({
    userId: "snaptrade-user-123",
    userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string
onlyExecuted: boolean

Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well

🔄 Return

AccountOrdersV2Response

🌐 Endpoint

/accounts/{accountId}/recentOrders/v2 GET

🔙 Back to Table of Contents


snaptrade.experimentalEndpoints.listSubscriptions

Returns active Trade Detection subscriptions for your Client ID. Cancelled subscriptions are not returned.

🛠️ Usage

const listSubscriptionsResponse =
  await snaptrade.experimentalEndpoints.listSubscriptions();

🔄 Return

TradeDetectionSubscription

🌐 Endpoint

/snapTrade/tradeDetection/subscriptions GET

🔙 Back to Table of Contents


snaptrade.options.listOptionHoldings

Deprecated

Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the positions endpoint.

This endpoint is deprecatd. Consider using the newer unified positions endpoint. This will allow you to get both equity and option positions in a single call, as well as additional asset classes such as futures.

Check your API key on the Customer Dashboard billing page to see if you have real-time data access:

  • If you do, this endpoint returns real-time data.
  • If you don't, Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. If you need real-time, use the manual refresh endpoint.

🛠️ Usage

const listOptionHoldingsResponse = await snaptrade.options.listOptionHoldings({
  userId: "snaptrade-user-123",
  userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
  accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
});

⚙️ Parameters

userId: string
userSecret: string
accountId: string

🔄 Return

OptionsPosition

🌐 Endpoint

/accounts/{accountId}/options GET

🔙 Back to Table of Contents


snaptrade.referenceData.getCurrencyExchangeRatePair

Returns an Exchange Rate Pair object for the specified Currency Pair.

🛠️ Usage

const getCurrencyExchangeRatePairResponse =
  await snaptrade.referenceData.getCurrencyExchangeRatePair({
    currencyPair: "currencyPair_example",
  });

⚙️