snaptrade-typescript-sdk
TypeScript icon, indicating that this package has built-in type declarations

9.0.15 • Public • Published

Visit SnapTrade

Connect brokerage accounts to your app for live positions and trading

npm More Info

Table of Contents

Installation

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

Getting Started

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

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 = uuid();
  const { userSecret } = (
    await snaptrade.authentication.registerSnapTradeUser({
      userId,
    })
  ).data;

  // Note: A user secret is only generated once. It's required to access
  // resources for certain endpoints.
  console.log("userSecret:", userSecret);

  // 4) Get a redirect URI. Users will need this to connect
  const data = (
    await snaptrade.authentication.loginSnapTradeUser({ userId, userSecret })
  ).data;
  if (!("redirectURI" in data)) throw Error("Should have gotten redirect URI");
  console.log("redirectURI:", data.redirectURI);

  // 5) Obtaining account holdings data
  const holdings = (
    await snaptrade.accountInformation.getAllUserHoldings({
      userId,
      userSecret,
    })
  ).data;
  console.log("holdings:", holdings);

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

// Should be replaced with function to get user ID
function getUserId() {
  var d = new Date().getTime(); //Timestamp
  var d2 =
    (typeof performance !== "undefined" &&
      performance.now &&
      performance.now() * 1000) ||
    0; //Time in microseconds since page-load or 0 if unsupported
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
    var r = Math.random() * 16; //random number between 0 and 16
    if (d > 0) {
      //Use timestamp until depleted
      r = (d + r) % 16 | 0;
      d = Math.floor(d / 16);
    } else {
      //Use microseconds since page-load if supported
      r = (d2 + r) % 16 | 0;
      d2 = Math.floor(d2 / 16);
    }
    return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
  });
}

main();

Reference

snaptrade.accountInformation.getAllUserHoldings

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

🛠️ Usage

const getAllUserHoldingsResponse =
  await snaptrade.accountInformation.getAllUserHoldings({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    brokerageAuthorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
brokerageAuthorizations: string

Optional. Comma seperated 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

A list of account balances for the specified account (one per currency that the account holds).

🛠️ Usage

const getUserAccountBalanceResponse =
  await snaptrade.accountInformation.getUserAccountBalance({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account to get balances.

🔄 Return

Balance

🌐 Endpoint

/accounts/{accountId}/balances GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserAccountDetails

Return details of a specific investment account

🛠️ Usage

const getUserAccountDetailsResponse =
  await snaptrade.accountInformation.getUserAccountDetails({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account to get detail of.

🔄 Return

Account

🌐 Endpoint

/accounts/{accountId} GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserAccountOrders

Fetch all recent orders from a user's account.

🛠️ Usage

const getUserAccountOrdersResponse =
  await snaptrade.accountInformation.getUserAccountOrders({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    state: "all",
    days: 30,
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account to get orders.

state: 'all' | 'open' | 'executed'

defaults value is set 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.

🔄 Return

AccountOrderRecord

🌐 Endpoint

/accounts/{accountId}/orders GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserAccountPositions

List account positions

🛠️ Usage

const getUserAccountPositionsResponse =
  await snaptrade.accountInformation.getUserAccountPositions({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account to get positions.

🔄 Return

Position

🌐 Endpoint

/accounts/{accountId}/positions GET

🔙 Back to Table of Contents


snaptrade.accountInformation.getUserHoldings

List balances, positions and orders for the specified account

🛠️ Usage

const getUserHoldingsResponse =
  await snaptrade.accountInformation.getUserHoldings({
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
  });

⚙️ Parameters

accountId: string

The ID of the account to fetch holdings for.

userId: string
userSecret: string

🔄 Return

AccountHoldingsAccount

🌐 Endpoint

/accounts/{accountId}/holdings GET

🔙 Back to Table of Contents


snaptrade.accountInformation.listUserAccounts

List accounts

🛠️ Usage

const listUserAccountsResponse =
  await snaptrade.accountInformation.listUserAccounts({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
  });

⚙️ Parameters

userId: string
userSecret: string

🔄 Return

Account

🌐 Endpoint

/accounts GET

🔙 Back to Table of Contents


snaptrade.accountInformation.updateUserAccount

Update details of an investment account

🛠️ Usage

const updateUserAccountResponse =
  await snaptrade.accountInformation.updateUserAccount({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    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 user you've registered over the SnapTrade API, and any data associated with them or their investment accounts.

🛠️ Usage

const deleteSnapTradeUserResponse =
  await snaptrade.authentication.deleteSnapTradeUser({
    userId: "John.doe@snaptrade.com",
  });

⚙️ Parameters

userId: string

🔄 Return

DeleteUserResponse

🌐 Endpoint

/snapTrade/deleteUser DELETE

🔙 Back to Table of Contents


snaptrade.authentication.getUserJWT

Generate encrypted JWT token

🛠️ Usage

const getUserJWTResponse = await snaptrade.authentication.getUserJWT({
  userId: "John.doe@snaptrade.com",
  userSecret: "USERSECRET123",
});

⚙️ Parameters

userId: string
userSecret: string

🔄 Return

EncryptedResponse

🌐 Endpoint

/snapTrade/encryptedJWT GET

🔙 Back to Table of Contents


snaptrade.authentication.listSnapTradeUsers

Returns a list of users you've registered over the SnapTrade API.

🛠️ Usage

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

🌐 Endpoint

/snapTrade/listUsers GET

🔙 Back to Table of Contents


snaptrade.authentication.loginSnapTradeUser

Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account.

🛠️ Usage

const loginSnapTradeUserResponse =
  await snaptrade.authentication.loginSnapTradeUser({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    broker: "ALPACA",
    immediateRedirect: true,
    customRedirect: "https://snaptrade.com",
    reconnect: "8b5f262d-4bb9-365d-888a-202bd3b15fa1",
    connectionType: "read",
    connectionPortalVersion: "v2",
  });

⚙️ Parameters

userId: string
userSecret: string
broker: string

Slug of the brokerage to connect the user to

immediateRedirect: boolean

When set to True, user will be redirected back to the partner\'s site instead of the connection portal

customRedirect: string

URL to redirect the user to after the user connects their brokerage account

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 ‘Reconnecting Accounts’ for more information.

connectionType: string

Sets whether the connection should be read or trade

connectionPortalVersion: string

Sets the version of the connection portal to render, with a default to \'v2\'

🔄 Return

AuthenticationLoginSnapTradeUser200Response

🌐 Endpoint

/snapTrade/login POST

🔙 Back to Table of Contents


snaptrade.authentication.registerSnapTradeUser

Create SnapTrade user

🛠️ Usage

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

⚙️ Parameters

userId: string

SnapTrade User ID. Provided by SnapTrade Partner. Can be any string, as long as it\'s unique to a user

🔄 Return

UserIDandSecret

🌐 Endpoint

/snapTrade/registerUser POST

🔙 Back to Table of Contents


snaptrade.authentication.resetSnapTradeUserSecret

Obtain a new user secret for a user

🛠️ Usage

const resetSnapTradeUserSecretResponse =
  await snaptrade.authentication.resetSnapTradeUserSecret({
    userId: "snaptrade-user-123",
    userSecret: "h81@cx1lkalablakwjaltkejraj11=",
  });

⚙️ Parameters

userId: string

SnapTrade User ID. Provided by SnapTrade Partner. Can be any string, as long as it\'s unique to a user

userSecret: string

SnapTrade User Secret randomly generated by SnapTrade. This should be considered priviledged information and if compromised, you should delete and re-create this SnapTrade user.

🔄 Return

UserIDandSecret

🌐 Endpoint

/snapTrade/resetUserSecret POST

🔙 Back to Table of Contents


snaptrade.connections.detailBrokerageAuthorization

Get brokerage authorization details

🛠️ Usage

const detailBrokerageAuthorizationResponse =
  await snaptrade.connections.detailBrokerageAuthorization({
    authorizationId: "2bcd7cc3-e922-4976-bce1-9858296801c3",
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
  });

⚙️ Parameters

authorizationId: string

The ID of a brokerage authorization object.

userId: string
userSecret: string

🔄 Return

BrokerageAuthorization

🌐 Endpoint

/authorizations/{authorizationId} GET

🔙 Back to Table of Contents


snaptrade.connections.listBrokerageAuthorizations

List all brokerage authorizations for the user

🛠️ Usage

const listBrokerageAuthorizationsResponse =
  await snaptrade.connections.listBrokerageAuthorizations({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
  });

⚙️ Parameters

userId: string
userSecret: string

🔄 Return

BrokerageAuthorization

🌐 Endpoint

/authorizations GET

🔙 Back to Table of Contents


snaptrade.connections.removeBrokerageAuthorization

Delete brokerage authorization

🛠️ Usage

const removeBrokerageAuthorizationResponse =
  await snaptrade.connections.removeBrokerageAuthorization({
    authorizationId: "2bcd7cc3-e922-4976-bce1-9858296801c3",
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
  });

⚙️ Parameters

authorizationId: string

The ID of the Authorization to delete.

userId: string
userSecret: string

🌐 Endpoint

/authorizations/{authorizationId} DELETE

🔙 Back to Table of Contents


snaptrade.connections.sessionEvents

List all session events for the partner

🛠️ 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 seperated list of user IDs used to filter the request on specific users

sessionId: string

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

🔄 Return

ConnectionsSessionEvents200ResponseInner

🌐 Endpoint

/sessionEvents GET

🔙 Back to Table of Contents


snaptrade.options.getOptionStrategy

Creates an option strategy object that will be used to place an option strategy order

🛠️ Usage

const getOptionStrategyResponse = await snaptrade.options.getOptionStrategy({
  userId: "John.doe@snaptrade.com",
  userSecret: "USERSECRET123",
  accountId: "accountId_example",
  underlying_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
  legs: [
    {
      action: "BUY_TO_OPEN",
      option_symbol_id: "SPY220819P00200000",
      quantity: 1,
    },
  ],
  strategy_type: "CUSTOM",
});

⚙️ Parameters

underlying_symbol_id: string
legs: OptionLeg[]
strategy_type: string
userId: string
userSecret: string
accountId: string

The ID of the account to create the option strategy object in.

🔄 Return

StrategyQuotes

🌐 Endpoint

/accounts/{accountId}/optionStrategy POST

🔙 Back to Table of Contents


snaptrade.options.getOptionsChain

Get the options chain

🛠️ Usage

const getOptionsChainResponse = await snaptrade.options.getOptionsChain({
  userId: "John.doe@snaptrade.com",
  userSecret: "USERSECRET123",
  accountId: "accountId_example",
  symbol: "symbol_example",
});

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account to get the options chain from.

symbol: string

Universal symbol ID if symbol

🔄 Return

OptionChainInner

🌐 Endpoint

/accounts/{accountId}/optionsChain GET

🔙 Back to Table of Contents


snaptrade.options.getOptionsStrategyQuote

Get latest market data of option strategy

🛠️ Usage

const getOptionsStrategyQuoteResponse =
  await snaptrade.options.getOptionsStrategyQuote({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    accountId: "accountId_example",
    optionStrategyId: "2bcd7cc3-e922-4976-bce1-9858296801c3",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account the strategy will be placed in.

optionStrategyId: string

Option strategy id obtained from response when creating option strategy object

🔄 Return

StrategyQuotes

🌐 Endpoint

/accounts/{accountId}/optionStrategy/{optionStrategyId} GET

🔙 Back to Table of Contents


snaptrade.options.listOptionHoldings

Get the options holdings in the account

🛠️ Usage

const listOptionHoldingsResponse = await snaptrade.options.listOptionHoldings({
  userId: "John.doe@snaptrade.com",
  userSecret: "USERSECRET123",
  accountId: "accountId_example",
});

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account to fetch options holdings for.

🔄 Return

OptionsPosition

🌐 Endpoint

/accounts/{accountId}/options GET

🔙 Back to Table of Contents


snaptrade.options.placeOptionStrategy

Place an option strategy order on the brokerage

🛠️ Usage

const placeOptionStrategyResponse = await snaptrade.options.placeOptionStrategy(
  {
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    accountId: "2bcd7cc3-e922-4976-bce1-9858296801c3",
    optionStrategyId: "2bcd7cc3-e922-4976-bce1-9858296801c3",
    order_type: "Limit",
    time_in_force: "FOK",
    price: 31.33,
  }
);

⚙️ Parameters

order_type: OrderType

Order Type

time_in_force: TimeInForceStrict

Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled

userId: string
userSecret: string
accountId: string

The ID of the account to execute the strategy in.

optionStrategyId: string

Option strategy id obtained from response when creating option strategy object

price: number

Trade Price if limit or stop limit order

🔄 Return

StrategyOrderRecord

🌐 Endpoint

/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute POST

🔙 Back to Table of Contents


snaptrade.referenceData.getCurrencyExchangeRatePair

Return the exchange rate of a currency pair

🛠️ Usage

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

⚙️ Parameters

currencyPair: string

A currency pair based on currency code for example, {CAD-USD}

🔄 Return

ExchangeRatePairs

🌐 Endpoint

/currencies/rates/{currencyPair} GET

🔙 Back to Table of Contents


snaptrade.referenceData.getPartnerInfo

Get metadata related to Snaptrade partner

🛠️ Usage

const getPartnerInfoResponse = await snaptrade.referenceData.getPartnerInfo();

🔄 Return

PartnerData

🌐 Endpoint

/snapTrade/partners GET

🔙 Back to Table of Contents


snaptrade.referenceData.getSecurityTypes

List security types available on SnapTrade.

🛠️ Usage

const getSecurityTypesResponse =
  await snaptrade.referenceData.getSecurityTypes();

🔄 Return

SecurityType

🌐 Endpoint

/securityTypes GET

🔙 Back to Table of Contents


snaptrade.referenceData.getStockExchanges

List exchanges

🛠️ Usage

const getStockExchangesResponse =
  await snaptrade.referenceData.getStockExchanges();

🔄 Return

Exchange

🌐 Endpoint

/exchanges GET

🔙 Back to Table of Contents


snaptrade.referenceData.getSymbols

Search for symbols

🛠️ Usage

const getSymbolsResponse = await snaptrade.referenceData.getSymbols({
  substring: "apple",
});

⚙️ Parameters

substring: string

🔄 Return

UniversalSymbol

🌐 Endpoint

/symbols POST

🔙 Back to Table of Contents


snaptrade.referenceData.getSymbolsByTicker

Get details of a symbol by the ticker or the universal_symbol_id

🛠️ Usage

const getSymbolsByTickerResponse =
  await snaptrade.referenceData.getSymbolsByTicker({
    query: "query_example",
  });

⚙️ Parameters

query: string

The ticker or universal_symbol_id of the UniversalSymbol to get.

🔄 Return

UniversalSymbol

🌐 Endpoint

/symbols/{query} GET

🔙 Back to Table of Contents


snaptrade.referenceData.listAllBrokerageAuthorizationType

List of all brokerage authorization types

🛠️ Usage

const listAllBrokerageAuthorizationTypeResponse =
  await snaptrade.referenceData.listAllBrokerageAuthorizationType({
    brokerage: "QUESTRADE,ALPACA",
  });

⚙️ Parameters

brokerage: string

Comma separated value of brokerage slugs

🔄 Return

BrokerageAuthorizationTypeReadOnly

🌐 Endpoint

/brokerageAuthorizationTypes GET

🔙 Back to Table of Contents


snaptrade.referenceData.listAllBrokerages

List brokerages

🛠️ Usage

const listAllBrokeragesResponse =
  await snaptrade.referenceData.listAllBrokerages();

🔄 Return

Brokerage

🌐 Endpoint

/brokerages GET

🔙 Back to Table of Contents


snaptrade.referenceData.listAllCurrencies

List currencies

🛠️ Usage

const listAllCurrenciesResponse =
  await snaptrade.referenceData.listAllCurrencies();

🔄 Return

Currency

🌐 Endpoint

/currencies GET

🔙 Back to Table of Contents


snaptrade.referenceData.listAllCurrenciesRates

List currency exchange rates

🛠️ Usage

const listAllCurrenciesRatesResponse =
  await snaptrade.referenceData.listAllCurrenciesRates();

🔄 Return

ExchangeRatePairs

🌐 Endpoint

/currencies/rates GET

🔙 Back to Table of Contents


snaptrade.referenceData.symbolSearchUserAccount

Search for symbols available in an account

🛠️ Usage

const symbolSearchUserAccountResponse =
  await snaptrade.referenceData.symbolSearchUserAccount({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    substring: "apple",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account to search for symbols within.

substring: string

🔄 Return

UniversalSymbol

🌐 Endpoint

/accounts/{accountId}/symbols POST

🔙 Back to Table of Contents


snaptrade.trading.cancelUserAccountOrder

Cancel open order in account

🛠️ Usage

const cancelUserAccountOrderResponse =
  await snaptrade.trading.cancelUserAccountOrder({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
    brokerage_order_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
  });

⚙️ Parameters

userId: string
userSecret: string
accountId: string

The ID of the account to cancel the order in.

brokerage_order_id: string

🔄 Return

AccountOrderRecord

🌐 Endpoint

/accounts/{accountId}/orders/cancel POST

🔙 Back to Table of Contents


snaptrade.trading.getOrderImpact

Check impact of trades on account.

🛠️ Usage

const getOrderImpactResponse = await snaptrade.trading.getOrderImpact({
  userId: "John.doe@snaptrade.com",
  userSecret: "USERSECRET123",
  account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
  action: "BUY",
  order_type: "Limit",
  price: 31.33,
  stop: 31.33,
  time_in_force: "FOK",
  universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
  notional_value: 100,
});

⚙️ Parameters

userId: string
userSecret: string
account_id: string
action: Action

Trade Action

order_type: OrderType

Order Type

price: number

Trade Price if limit or stop limit order

stop: number

Stop Price. If stop loss or stop limit order, the price to trigger the stop

time_in_force: TimeInForceStrict

Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled

units: number
universal_symbol_id: string
notional_value: number

🔄 Return

ManualTradeAndImpact

🌐 Endpoint

/trade/impact POST

🔙 Back to Table of Contents


snaptrade.trading.getUserAccountQuotes

Get symbol quotes

🛠️ Usage

const getUserAccountQuotesResponse =
  await snaptrade.trading.getUserAccountQuotes({
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
    symbols: "symbols_example",
    accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
  });

⚙️ Parameters

userId: string
userSecret: string
symbols: string

List of universal_symbol_id or tickers to get quotes for.

accountId: string

The ID of the account to get quotes.

useTicker: boolean

Should be set to True if providing tickers.

🔄 Return

SymbolsQuotesInner

🌐 Endpoint

/accounts/{accountId}/quotes GET

🔙 Back to Table of Contents


snaptrade.trading.placeForceOrder

Place a trade with NO validation.

🛠️ Usage

const placeForceOrderResponse = await snaptrade.trading.placeForceOrder({
  userId: "John.doe@snaptrade.com",
  userSecret: "USERSECRET123",
  account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
  action: "BUY",
  order_type: "Limit",
  price: 31.33,
  stop: 31.33,
  time_in_force: "FOK",
  universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
  notional_value: 100,
});

⚙️ Parameters

userId: string
userSecret: string
account_id: string
action: Action

Trade Action

order_type: OrderType

Order Type

price: number

Trade Price if limit or stop limit order

stop: number

Stop Price. If stop loss or stop limit order, the price to trigger the stop

time_in_force: TimeInForceStrict

Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled

units: number
universal_symbol_id: string
notional_value: number

🔄 Return

AccountOrderRecord

🌐 Endpoint

/trade/place POST

🔙 Back to Table of Contents


snaptrade.trading.placeOCOOrder

Place a OCO (One Cancels Other) order

🛠️ Usage

const placeOCOOrderResponse = await snaptrade.trading.placeOCOOrder({
  userId: "John.doe@snaptrade.com",
  userSecret: "USERSECRET123",
});

⚙️ Parameters

userId: string
userSecret: string
first_trade_id: any

The ID of first trade object obtained from trade/impact endpoint

second_trade_id: any

The ID of second trade object obtained from trade/impact endpoint

🔄 Return

AccountOrderRecord

🌐 Endpoint

/trade/oco POST

🔙 Back to Table of Contents


snaptrade.trading.placeOrder

Place order

🛠️ Usage

const placeOrderResponse = await snaptrade.trading.placeOrder({
  tradeId: "tradeId_example",
  userId: "John.doe@snaptrade.com",
  userSecret: "USERSECRET123",
  wait_to_confirm: true,
});

⚙️ Parameters

tradeId: string

The ID of trade object obtained from trade/impact endpoint

userId: string
userSecret: string
wait_to_confirm: boolean

Optional, defaults to true. Determines if a wait is performed to check on order status. If false, latency will be reduced but orders returned will be more likely to be of status PENDING as we will not wait to check on the status before responding to the request

🔄 Return

AccountOrderRecord

🌐 Endpoint

/trade/{tradeId} POST

🔙 Back to Table of Contents


snaptrade.transactionsAndReporting.getActivities

Returns activities (transactions) for a user. Specifying start and end date is highly recommended for better performance

🛠️ Usage

const getActivitiesResponse =
  await snaptrade.transactionsAndReporting.getActivities({
    startDate: "2022-01-24",
    endDate: "2022-01-24",
    accounts:
      "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
    brokerageAuthorizations:
      "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
    type: "DIVIDEND",
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
  });

⚙️ Parameters

userId: string
userSecret: string
startDate: string | Date
endDate: string | Date
accounts: string

Optional comma seperated list of account IDs used to filter the request on specific accounts

brokerageAuthorizations: string

Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations

type: string

Optional comma seperated list of types to filter activities by. This is not an exhaustive list, if we fail to match to these types, we will return the raw description from the brokerage. Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT

🔄 Return

UniversalActivity

🌐 Endpoint

/activities GET

🔙 Back to Table of Contents


snaptrade.transactionsAndReporting.getReportingCustomRange

Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Please note that Total Equity Timeframe and Rate of Returns are experimental features. Please contact support@snaptrade.com if you notice any inconsistencies.

🛠️ Usage

const getReportingCustomRangeResponse =
  await snaptrade.transactionsAndReporting.getReportingCustomRange({
    startDate: "2022-01-24",
    endDate: "2022-01-24",
    accounts:
      "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
    detailed: true,
    frequency: "monthly",
    userId: "John.doe@snaptrade.com",
    userSecret: "USERSECRET123",
  });

⚙️ Parameters

startDate: string | Date
endDate: string | Date
userId: string
userSecret: string
accounts: string

Optional comma seperated list of account IDs used to filter the request on specific accounts

detailed: boolean

Optional, increases frequency of data points for the total value and contribution charts if set to true

frequency: string

Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly.

🔄 Return

PerformanceCustom

🌐 Endpoint

/performance/custom GET

🔙 Back to Table of Contents


Author

This TypeScript package is automatically generated by Konfig

Package Sidebar

Install

npm i snaptrade-typescript-sdk

Weekly Downloads

322

Version

9.0.15

License

Unlicense

Unpacked Size

724 kB

Total Files

307

Last publish

Collaborators

  • dphuang2
  • konfig-publisher