### Get Order Detail Example Source: https://docs.snaptrade.com/reference/Account%20Information/AccountInformation_getUserAccountOrderDetail This example demonstrates how to retrieve the details of a specific order. ```APIDOC ## GET /accounts/{accountId}/orders/{orderId} ### Description Retrieves the details of a specific order for a given account. ### Method GET ### Endpoint `/accounts/{accountId}/orders/{orderId}` ### Parameters #### Path Parameters - **accountId** (string) - Required - The unique identifier of the account. - **orderId** (string) - Required - The unique identifier of the order. ### Response #### Success Response (200) - **brokerage_order_id** (string) - The unique ID of the order within the brokerage. - **brokerage_group_order_id** (string) - The group ID for the order within the brokerage. - **order_role** (string) - The role of the order (e.g., TRIGGER). - **status** (string) - The current status of the order. - **universal_symbol** (object) - Details about the security. - **id** (string) - Unique ID for the security. - **symbol** (string) - The trading symbol for the security. - **raw_symbol** (string) - The raw symbol without exchange suffix. - **description** (string) - A description of the security. - **currency** (object) - Currency details. - **id** (string) - Unique ID for the currency. - **code** (string) - Currency code (e.g., USD). - **name** (string) - Currency name. - **exchange** (object) - Exchange details. - **id** (string) - Unique ID for the exchange. - **code** (string) - Exchange code (e.g., TSX). - **mic_code** (string) - MIC code for the exchange. - **name** (string) - Exchange name. - **timezone** (string) - Timezone of the exchange. - **start_time** (string) - Opening time of the exchange. - **close_time** (string) - Closing time of the exchange. - **suffix** (string) - Suffix for symbols on this exchange. - **type** (object) - Type of the security. - **id** (string) - Unique ID for the security type. - **code** (string) - Code for the security type. - **description** (string) - Description of the security type. - **is_supported** (boolean) - Indicates if the security type is supported. - **figi_code** (string) - FIGI code for the security. - **figi_instrument** (object) - FIGI instrument details. - **figi_code** (string) - FIGI code for the instrument. - **figi_share_class** (string) - FIGI share class code. - **currencies** (array) - List of supported currencies for the security. - **option_symbol** (object or null) - Details about the option if it's an options order. - **id** (string) - Unique ID for the option symbol. - **ticker** (string) - The ticker symbol for the option. - **option_type** (string) - Type of option (CALL or PUT). - **strike_price** (number) - The strike price of the option. - **expiration_date** (string) - The expiration date of the option. - **is_mini_option** (boolean) - Indicates if it's a mini option. - **underlying_symbol** (object) - Details of the underlying security. - **quote_universal_symbol** (object) - Details about the quoted security. - **quote_currency** (object) - Details about the quote currency. - **action** (string) - The action of the order (e.g., BUY, SELL). - **total_quantity** (string) - The total quantity of the order. - **open_quantity** (string) - The remaining open quantity. - **canceled_quantity** (string) - The quantity that was canceled. - **filled_quantity** (string) - The quantity that has been filled. - **execution_price** (number) - The price at which the order was executed. - **limit_price** (number) - The limit price for the order. - **stop_price** (number) - The stop price for the order. - **trailing_stop** (object or null) - Trailing stop details. - **amount** (string) - The trailing stop amount. - **type** (string) - The type of trailing stop (e.g., DOLLAR). - **child_brokerage_order_ids** (object or null) - IDs of child orders. - **take_profit_order_id** (string) - Brokerage order ID for the take profit leg. - **stop_loss_order_id** (string) - Brokerage order ID for the stop loss leg. #### Response Example ```json { "brokerage_order_id": "66a033fa-da74-4fcf-b527-feefdec9257e", "brokerage_group_order_id": "1234567890", "order_role": "TRIGGER", "status": "NONE", "universal_symbol": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "symbol": "VAB.TO", "raw_symbol": "VAB", "description": "VANGUARD CDN AGGREGATE BOND INDEX ETF", "currency": { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" }, "exchange": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "TSX", "mic_code": "XTSE", "name": "Toronto Stock Exchange", "timezone": "America/New_York", "start_time": "09:30:00", "close_time": "16:00:00", "suffix": ".TO" }, "type": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "cs", "description": "Common Stock", "is_supported": true }, "figi_code": "BBG000B9XRY4", "figi_instrument": { "figi_code": "BBG000B9Y5X2", "figi_share_class": "BBG001S5N8V8" }, "currencies": [ { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" } ] }, "option_symbol": null, "quote_universal_symbol": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "symbol": "VAB.TO", "raw_symbol": "VAB", "description": "VANGUARD CDN AGGREGATE BOND INDEX ETF", "currency": { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" }, "exchange": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "TSX", "mic_code": "XTSE", "name": "Toronto Stock Exchange", "timezone": "America/New_York", "start_time": "09:30:00", "close_time": "16:00:00", "suffix": ".TO" }, "type": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "cs", "description": "Common Stock", "is_supported": true }, "figi_code": "BBG000B9XRY4", "figi_instrument": { "figi_code": "BBG000B9Y5X2", "figi_share_class": "BBG001S5N8V8" }, "currencies": [ { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" } ] }, "quote_currency": { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" }, "action": "string", "total_quantity": "100", "open_quantity": "10", "canceled_quantity": "10", "filled_quantity": "80", "execution_price": 12.34, "limit_price": 12.34, "stop_price": 12.5, "trailing_stop": { "amount": "0.60", "type": "DOLLAR" }, "child_brokerage_order_ids": null } ``` ``` -------------------------------- ### Get Partner Info with SnapTrade TypeScript SDK Source: https://docs.snaptrade.com/reference/Reference%20Data/ReferenceData_getPartnerInfo Instantiate the SnapTrade SDK with your client and consumer keys, then call the getPartnerInfo method to retrieve configurations. Ensure you have installed the SDK using 'npm install snaptrade-typescript-sdk'. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.referenceData.getPartnerInfo(); console.log(response.data); ``` -------------------------------- ### List All Brokerage Instruments (TypeScript) Source: https://docs.snaptrade.com/reference/Reference%20Data/ReferenceData_listAllBrokerageInstruments Use this snippet to get all available instruments for a given brokerage. Ensure you have installed the snaptrade-typescript-sdk and initialized the Snaptrade client with your credentials. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.referenceData.listAllBrokerageInstruments( { slug: "QUESTRADE" }, ); console.log(response.data); ``` -------------------------------- ### Execute a Get Option Impact Request in TypeScript Source: https://docs.snaptrade.com/reference/Trading/Trading_getOptionImpact Initializes the Snaptrade SDK and makes a request to simulate an option order. Ensure you have installed the SDK using 'npm install snaptrade-typescript-sdk'. Replace placeholder values for clientId, consumerKey, and accountId with your actual credentials. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.trading.getOptionImpact({ accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", order_type: "MARKET", time_in_force: "Day", price_effect: "DEBIT", legs: [ { instrument: { symbol: "PBI 250718C00006000", instrument_type: "INSTRUMENT_TYPE", }, action: "BUY_TO_OPEN", units: 1, }, ], }); console.log(response.data); ``` -------------------------------- ### Preview Crypto Order using TypeScript SDK Source: https://docs.snaptrade.com/reference/Trading/Trading_previewCryptoOrder Instantiate the SnapTrade SDK and call the previewCryptoOrder method to get an order preview. Ensure you have installed the SDK using 'npm install snaptrade-typescript-sdk'. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({}); const response = await snaptrade.trading.previewCryptoOrder({}); console.log(response.data); ``` -------------------------------- ### Login Response Example Source: https://docs.snaptrade.com/reference/Authentication/Authentication_loginSnapTradeUser Example of a successful response from the loginSnapTradeUser endpoint, containing the redirect URI and a session ID. ```json { "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", "sessionId": "cf371bb4-a475-4f17-ab94-d0fee699960d" } ``` -------------------------------- ### Get Account Activities with TypeScript SDK Source: https://docs.snaptrade.com/reference/Account%20Information/AccountInformation_getAccountActivities Initializes the SnapTrade SDK and retrieves account activities for a specific account. Includes parameters for account ID, user credentials, date range, and transaction types. Ensure your SDK is installed via npm. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.accountInformation.getAccountActivities({ accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", startDate: "2022-01-24", endDate: "2022-01-24", type: "BUY,SELL,DIVIDEND", }); console.log(response.data); ``` -------------------------------- ### Get User Account Recent Orders V2 Source: https://docs.snaptrade.com/reference/Experimental%20endpoints/AccountInformation_getUserAccountRecentOrdersV2 This example demonstrates how to retrieve a list of recent orders for a user's account using the V2 format. It includes details on order status, type, and execution. ```json { "orders": [ { "brokerage_order_id": "123456789", "brokerage_group_order_id": null, "order_role": null, "status": "EXECUTED", "order_type": "MARKET", "time_in_force": "DAY", "time_placed": "2023-10-26T10:00:00Z", "time_executed": "2023-10-26T10:05:00Z", "quote_currency": "USD", "execution_price": 150.75, "limit_price": null, "stop_price": null, "trailing_stop": null, "legs": [ { "leg_id": "leg_abc", "instrument": { "symbol": "AAPL", "description": "Apple Inc.", "asset_type": "EQUITY", "exchange_mic_code": "XNAS", "figi_code": "BBG000B9X520" }, "action": "BUY", "execution_price": 150.75, "total_quantity": "10", "canceled_quantity": "0", "filled_quantity": "10", "status": "EXECUTED" } ] } ] } ``` -------------------------------- ### List All Brokerages (TypeScript) Source: https://docs.snaptrade.com/reference/Reference%20Data/ReferenceData_listAllBrokerages Initializes the Snaptrade SDK and calls the `listAllBrokerages` function to retrieve a list of supported brokerages. Ensure you have installed the SDK using `npm install snaptrade-typescript-sdk`. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.referenceData.listAllBrokerages(); console.log(response.data); ``` -------------------------------- ### Example Response for Get Stock Exchanges Source: https://docs.snaptrade.com/reference/Reference%20Data/ReferenceData_getStockExchanges This is an example of the JSON response structure when retrieving stock exchanges. Each object represents a single exchange with its details. ```json [ { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "TSX", "mic_code": "XTSE", "name": "Toronto Stock Exchange", "timezone": "America/New_York", "start_time": "09:30:00", "close_time": "16:00:00", "suffix": ".TO" } ] ``` -------------------------------- ### Preview Crypto Order Response Example Source: https://docs.snaptrade.com/reference/Trading/Trading_previewCryptoOrder This is an example of the response structure when previewing a crypto order, showing the estimated fee details. ```json { "estimated_fee": { "currency": "BTC", "amount": "123.45" } } ``` -------------------------------- ### Example Connection Object Source: https://docs.snaptrade.com/reference/Connections/Connections_listBrokerageAuthorizations This is an example of a single connection object returned when listing brokerage authorizations. It includes the connection ID, creation date, and details about the associated brokerage. ```json [ { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "created_date": "2024-08-20T21:56:19.123Z", "brokerage": { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "slug": "TDAMERITRADE", "name": "TD Ameritrade", "display_name": "TD Ameritrade", "description": "TD Ameritrade is a leading online broker offering a platform for trading stocks, ETFs, options, and futures.", "aws_s3_logo_url": "https://example.com/logos/tdameritrade.png", "aws_s3_square_logo_url": "https://example.com/logos/tdameritrade_square.png", "url": "https://www.tdameritrade.com", "enabled": true, "maintenance_mode": false, "is_degraded": false, "allows_trading": true, "allows_fractional_units": true, "has_reporting": true, "is_real_time_connection": true, "brokerage_type": { "id": "traditional", "name": "Traditional", "exchanges": [] }, "open_url": "https://connect.tdameritrade.com" }, "name": "My TD Ameritrade Account", "type": "trade", "disabled": false, "disabled_date": null, "meta": {}, "updated_date": "2024-08-20T21:56:19.123Z", "is_eligible_for_payout": false } ] ``` -------------------------------- ### Get Cryptocurrency Pair Quote (TypeScript) Source: https://docs.snaptrade.com/reference/Trading/Trading_getCryptocurrencyPairQuote Use this snippet to retrieve a quote for a cryptocurrency pair. Ensure you have installed the snaptrade-typescript-sdk and initialized the Snaptrade client with your credentials. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.trading.getCryptocurrencyPairQuote( { accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631", instrumentSymbol: "BTC-USD", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", }, ); console.log(response.data); ``` -------------------------------- ### Place Equity Order with TypeScript SDK Source: https://docs.snaptrade.com/reference/Trading/Trading_placeForceOrder Demonstrates how to place a market order for AAPL shares using the SnapTrade TypeScript SDK. Ensure you have initialized the Snaptrade client with your credentials. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.trading.placeForceOrder({ userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", action: "ACTION", symbol: "AAPL", order_type: "Market", time_in_force: "Day", trading_session: "REGULAR", price: 31.33, stop: 31.33, }); console.log(response.data); ``` -------------------------------- ### Get Brokerage Connection Detail (TypeScript) Source: https://docs.snaptrade.com/reference/Connections/Connections_detailBrokerageAuthorization Use this method to retrieve the details of a specific brokerage connection. Ensure you have installed the SDK and initialized it with your client credentials. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.connections.detailBrokerageAuthorization({ authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", }); console.log(response.data); ``` -------------------------------- ### Place Multi-Leg Option Order in TypeScript Source: https://docs.snaptrade.com/reference/Trading/Trading_placeMlegOrder Demonstrates how to place a multi-leg option order using the SnapTrade TypeScript SDK. Ensure you have installed the SDK and initialized it with your client and consumer keys. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.trading.placeMlegOrder({ accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", order_type: "MARKET", time_in_force: "Day", price_effect: "DEBIT", legs: [ { instrument: { symbol: "PBI 250718C00006000", instrument_type: "INSTRUMENT_TYPE", }, action: "BUY_TO_OPEN", units: 1, }, ], }); console.log(response.data); ``` -------------------------------- ### Get User Account Positions (TypeScript) Source: https://docs.snaptrade.com/reference/Account%20Information/AccountInformation_getUserAccountPositions Use this method to retrieve a list of positions for a given account. Ensure you have installed the snaptrade-typescript-sdk and initialized it with your client credentials. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.accountInformation.getUserAccountPositions({ accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", }); console.log(response.data); ``` -------------------------------- ### User Account Orders Response Example Source: https://docs.snaptrade.com/reference/Account%20Information/AccountInformation_getUserAccountOrders This JSON object represents a sample response for a user's account orders. It includes details such as brokerage order IDs, status, and nested objects for universal symbol, option symbol, and quote information. ```json [ { "brokerage_order_id": "66a033fa-da74-4fcf-b527-feefdec9257e", "brokerage_group_order_id": "1234567890", "order_role": "TRIGGER", "status": "NONE", "universal_symbol": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "symbol": "VAB.TO", "raw_symbol": "VAB", "description": "VANGUARD CDN AGGREGATE BOND INDEX ETF", "currency": { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" }, "exchange": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "TSX", "mic_code": "XTSE", "name": "Toronto Stock Exchange", "timezone": "America/New_York", "start_time": "09:30:00", "close_time": "16:00:00", "suffix": ".TO" }, "type": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "cs", "description": "Common Stock", "is_supported": true }, "figi_code": "BBG000B9XRY4", "figi_instrument": { "figi_code": "BBG000B9Y5X2", "figi_share_class": "BBG001S5N8V8" }, "currencies": [ { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" } ] }, "option_symbol": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "ticker": "AAPL 261218C00240000", "option_type": "CALL", "strike_price": 240, "expiration_date": "2026-12-18", "is_mini_option": false, "underlying_symbol": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "symbol": "SPY", "raw_symbol": "VAB", "description": "SPDR S&P 500 ETF Trust", "currency": { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" }, "exchange": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "ARCX", "mic_code": "ARCA", "name": "NYSE ARCA", "timezone": "America/New_York", "start_time": "09:30:00", "close_time": "16:00:00", "suffix": "None", "allows_cryptocurrency_symbols": false }, "type": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "cs", "description": "Common Stock", "is_supported": true }, "figi_code": "BBG000B9XRY4", "figi_instrument": { "figi_code": "BBG000B9Y5X2", "figi_share_class": "BBG001S5N8V8" }, "currencies": [ { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" } ] } }, "quote_universal_symbol": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "symbol": "VAB.TO", "raw_symbol": "VAB", "description": "VANGUARD CDN AGGREGATE BOND INDEX ETF", "currency": { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" }, "exchange": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "TSX", "mic_code": "XTSE", "name": "Toronto Stock Exchange", "timezone": "America/New_York", "start_time": "09:30:00", "close_time": "16:00:00", "suffix": ".TO" }, "type": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "code": "cs", "description": "Common Stock", "is_supported": true }, "figi_code": "BBG000B9XRY4", "figi_instrument": { "figi_code": "BBG000B9Y5X2", "figi_share_class": "BBG001S5N8V8" }, "currencies": [ { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" } ] }, "quote_currency": { "id": "87b24961-b51e-4db8-9226-f198f6518a89", "code": "USD", "name": "US Dollar" }, "action": "string" } ] ``` -------------------------------- ### Get Account Balance History (TypeScript) Source: https://docs.snaptrade.com/reference/Account%20Information/AccountInformation_getAccountBalanceHistory Initializes the Snaptrade SDK and calls the `getAccountBalanceHistory` endpoint with required account and user credentials. Ensure you have installed the `snaptrade-typescript-sdk` package. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.accountInformation.getAccountBalanceHistory({ accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", }); console.log(response.data); ``` -------------------------------- ### Execute API Request to Get Recent Orders Source: https://docs.snaptrade.com/reference/Account%20Information/AccountInformation_getUserAccountRecentOrders Use this snippet to fetch only executed orders from a specified account. Ensure you have installed the snaptrade-typescript-sdk and have your client ID and consumer key. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.accountInformation.getUserAccountRecentOrders( { accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", }, ); console.log(response.data); ``` -------------------------------- ### Place Complex Order with TypeScript SDK Source: https://docs.snaptrade.com/reference/Trading/Trading_placeComplexOrder Demonstrates how to initialize the SnapTrade SDK and place a complex order of type OTO. Ensure you replace placeholder values with your actual client ID, consumer key, account ID, and user details. The `orders` array must be structured according to the complex order type specified. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.trading.placeComplexOrder({ accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", type: "OTO", orders: [ { order_role: "TRIGGER", action: "ACTION", instrument: { symbol: "AAPL", type: "TYPE", }, order_type: "Market", units: 10.5, time_in_force: "Day", price: 31.33, stop: 29.5, }, ], client_order_id: "my-order-123", }); console.log(response.data); ``` -------------------------------- ### Example getPartnerInfo Response Source: https://docs.snaptrade.com/reference/Reference%20Data/ReferenceData_getPartnerInfo This JSON object represents the response from the getPartnerInfo endpoint, detailing client configurations and allowed brokerages. ```json { "slug": "WEALTHLY", "name": "Wealthly", "logo_url": "https://example.com/logo.png", "allowed_brokerages": [ { "id": "ebf91a5b-0920-4266-9e36-f6cfe8c40946", "slug": "ROBINHOOD", "name": "Robinhood", "display_name": "Robinhood", "description": "Robinhood is an American multinational financial services corporation based in Menlo Park, California.", "aws_s3_logo_url": "https://passiv-brokerage-logos.s3.ca-central-1.amazonaws.com/robinhood-logo.png", "aws_s3_square_logo_url": "https://passiv-brokerage-logos.s3.ca-central-1.amazonaws.com/robinhood-logo-square.png", "url": "https://robinhood.com", "enabled": true, "maintenance_mode": true, "is_degraded": true, "allows_trading": true, "allows_fractional_units": true, "has_reporting": true, "is_real_time_connection": true, "brokerage_type": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "name": "Traditional Brokerage" }, "exchanges": [ "2bcd7cc3-e922-4976-bce1-9858296801c3", "4bcd8cc3-c122-4974-dc21-1858296801f4" ], "open_url": "string" } ], "can_access_trades": true, "can_access_holdings": true, "can_access_account_history": true, "can_access_reference_data": true, "can_access_portfolio_management": true, "can_access_orders": true, "redirect_uri": "https://example.com/oauth/snaptrade" } ``` -------------------------------- ### Get User Account Order Detail - TypeScript SDK Source: https://docs.snaptrade.com/reference/Account%20Information/AccountInformation_getUserAccountOrderDetail Use the TypeScript SDK to retrieve the details of a specific order. Ensure you have installed the SDK and initialized it with your client credentials. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = 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", }); console.log(response.data); ``` -------------------------------- ### Get Connection Return Rates (TypeScript) Source: https://docs.snaptrade.com/reference/Connections/Connections_returnRates Use this snippet to fetch rate of return data for a given connection. Ensure you have the SnapTrade SDK installed and your client credentials configured. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.connections.returnRates({ authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89", userId: "snaptrade-user-123", userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61", timeframes: "ALL,1Y", }); console.log(response.data); ``` -------------------------------- ### List All Brokerages Source: https://docs.snaptrade.com/reference/Reference%20Data/ReferenceData_listAllBrokerages This snippet shows how to use the Snaptrade SDK to retrieve a list of all brokerages. It requires your `clientId` and `consumerKey` for authentication. ```APIDOC ## Get brokerages ### Description Returns a list of all defined Brokerage objects. ### Method GET ### Endpoint `https://api.snaptrade.com/api/v1/brokerages` ### Parameters No query parameters. ### Request Body No request body. ### Authorization - `clientId` (string) - Required - `consumerKey` (string) - Required ### Response #### Success Response (200) `array of objects` - An array of brokerage objects. Each brokerage object contains the following properties: - `id` (string, format: uuid) - Unique identifier for the brokerage firm. - `slug` (string) - A short, unique identifier for the brokerage. - `name` (string) - Full name of the brokerage. - `display_name` (string) - A display-friendly name of the brokerage. - `description` (string) - A brief description of the brokerage. - `aws_s3_logo_url` (string, format: url) - URL to the brokerage's logo. - `aws_s3_square_logo_url` (string or null, format: url) - URL to the brokerage's logo in square format. - `url` (string, format: url) - URL to the brokerage's website. - `enabled` (boolean) - Whether the brokerage is enabled in SnapTrade. - `maintenance_mode` (boolean) - Whether the brokerage is currently in maintenance mode. - `is_degraded` (boolean) - Whether the brokerage is currently degraded. - `allows_trading` (boolean or null) - Whether the brokerage allows trading through SnapTrade. - `allows_fractional_units` (boolean or null) - Deprecated. - `has_reporting` (boolean or null) - Deprecated. - `is_real_time_connection` (boolean) - Deprecated. - `brokerage_type` (object) - Type of brokerage. - `id` (string, format: uuid) - `name` (string) - `exchanges` (array) - Deprecated. - `open_url` (string or null, format: url) - Deprecated. ### Request Example (TypeScript SDK) ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.referenceData.listAllBrokerages(); console.log(response.data); ``` ### Response Example (JSON) ```json [ { "id": "ebf91a5b-0920-4266-9e36-f6cfe8c40946", "slug": "ROBINHOOD", "name": "Robinhood", "display_name": "Robinhood", "description": "Robinhood is an American multinational financial services corporation based in Menlo Park, California.", "aws_s3_logo_url": "https://passiv-brokerage-logos.s3.ca-central-1.amazonaws.com/robinhood-logo.png", "aws_s3_square_logo_url": "https://passiv-brokerage-logos.s3.ca-central-1.amazonaws.com/robinhood-logo-square.png", "url": "https://robinhood.com", "enabled": true, "maintenance_mode": true, "is_degraded": true, "allows_trading": true, "allows_fractional_units": true, "has_reporting": true, "is_real_time_connection": true, "brokerage_type": { "id": "2bcd7cc3-e922-4976-bce1-9858296801c3", "name": "Traditional Brokerage" }, "exchanges": [ "2bcd7cc3-e922-4976-bce1-9858296801c3", "4bcd8cc3-c122-4974-dc21-1858296801f4" ], "open_url": "string" } ] ``` ``` -------------------------------- ### Get Currency Exchange Rate Pair (TypeScript) Source: https://docs.snaptrade.com/reference/Reference%20Data/ReferenceData_getCurrencyExchangeRatePair Use this method to retrieve the exchange rate for a given currency pair. Ensure you have installed the snaptrade-typescript-sdk and initialized the Snaptrade client with your credentials. ```typescript import { Snaptrade } from "snaptrade-typescript-sdk"; const snaptrade = new Snaptrade({ clientId: "PARTNER_CLIENT_ID", consumerKey: "CONSUMER_KEY", }); const response = await snaptrade.referenceData.getCurrencyExchangeRatePair( { currencyPair: "CURRENCY_PAIR" }, ); console.log(response.data); ```