snaptrade-typescript-sdk 13.2.2 → 13.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -1
- package/dist/browser.umd.js +3 -3
- package/dist/index.cjs +239 -1
- package/dist/index.d.cts +159 -6
- package/dist/index.d.mts +159 -6
- package/dist/index.d.ts +159 -6
- package/dist/index.mjs +239 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ backoff with jitter rather than from the headers.
|
|
|
63
63
|
See https://docs.snaptrade.com/docs/ratelimiting.
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
[](https://www.npmjs.com/package/snaptrade-typescript-sdk/v/13.2.4)
|
|
67
67
|
[](https://snaptrade.com/)
|
|
68
68
|
|
|
69
69
|
</div>
|
|
@@ -111,7 +111,9 @@ See https://docs.snaptrade.com/docs/ratelimiting.
|
|
|
111
111
|
* [`snaptrade.connections.syncBrokerageAuthorizationTransactions`](#snaptradeconnectionssyncbrokerageauthorizationtransactions)
|
|
112
112
|
* [`snaptrade.experimentalEndpoints.addSubscription`](#snaptradeexperimentalendpointsaddsubscription)
|
|
113
113
|
* [`snaptrade.experimentalEndpoints.cancelSubscription`](#snaptradeexperimentalendpointscancelsubscription)
|
|
114
|
+
* [`snaptrade.experimentalEndpoints.getAccountOrder`](#snaptradeexperimentalendpointsgetaccountorder)
|
|
114
115
|
* [`snaptrade.experimentalEndpoints.getAllAccountOrders`](#snaptradeexperimentalendpointsgetallaccountorders)
|
|
116
|
+
* [`snaptrade.experimentalEndpoints.getAllAccountRecentOrders`](#snaptradeexperimentalendpointsgetallaccountrecentorders)
|
|
115
117
|
* [`snaptrade.experimentalEndpoints.getUserAccountOrderDetailV2`](#snaptradeexperimentalendpointsgetuseraccountorderdetailv2)
|
|
116
118
|
* [`snaptrade.experimentalEndpoints.getUserAccountOrdersV2`](#snaptradeexperimentalendpointsgetuseraccountordersv2)
|
|
117
119
|
* [`snaptrade.experimentalEndpoints.getUserAccountRecentOrdersV2`](#snaptradeexperimentalendpointsgetuseraccountrecentordersv2)
|
|
@@ -2368,6 +2370,71 @@ Unique identifier for the connected brokerage account. This is the UUID used to
|
|
|
2368
2370
|
---
|
|
2369
2371
|
|
|
2370
2372
|
|
|
2373
|
+
### `snaptrade.experimentalEndpoints.getAccountOrder`<a id="snaptradeexperimentalendpointsgetaccountorder"></a>
|
|
2374
|
+
|
|
2375
|
+
Returns the detail of a single order, identified by the brokerage order ID in the path, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`.
|
|
2376
|
+
|
|
2377
|
+
The order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. Multi-leg orders are a single order with multiple legs.
|
|
2378
|
+
|
|
2379
|
+
This endpoint is always realtime and does not rely on cached data, except that an order in a terminal state (executed, canceled, rejected, failed, expired, replaced) may be served from a short-lived cache since it can no longer change.
|
|
2380
|
+
|
|
2381
|
+
This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint.
|
|
2382
|
+
|
|
2383
|
+
**Experimental:** this endpoint may change without notice.
|
|
2384
|
+
|
|
2385
|
+
|
|
2386
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
|
2387
|
+
|
|
2388
|
+
##### Commercial API Key Auth<a id="commercial-api-key-auth"></a>
|
|
2389
|
+
|
|
2390
|
+
```typescript
|
|
2391
|
+
const getAccountOrderResponse =
|
|
2392
|
+
await commercialApiKeyClient.experimentalEndpoints.getAccountOrder({
|
|
2393
|
+
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2394
|
+
brokerageOrderId: "66a033fa-da74-4fcf-b527-feefdec9257e",
|
|
2395
|
+
userId: "snaptrade-user-123",
|
|
2396
|
+
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2397
|
+
});
|
|
2398
|
+
```
|
|
2399
|
+
|
|
2400
|
+
Required credentials for this mode:
|
|
2401
|
+
|
|
2402
|
+
- `userId` (string, required): 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.
|
|
2403
|
+
|
|
2404
|
+
- `userSecret` (string, required): 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](/reference/Authentication/Authentication_resetSnapTradeUserSecret).
|
|
2405
|
+
|
|
2406
|
+
##### Personal API Key Auth<a id="personal-api-key-auth"></a>
|
|
2407
|
+
|
|
2408
|
+
```typescript
|
|
2409
|
+
const getAccountOrderResponse =
|
|
2410
|
+
await personalApiKeyClient.experimentalEndpoints.getAccountOrder({
|
|
2411
|
+
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2412
|
+
brokerageOrderId: "66a033fa-da74-4fcf-b527-feefdec9257e",
|
|
2413
|
+
});
|
|
2414
|
+
```
|
|
2415
|
+
|
|
2416
|
+
The client identifies the user in this mode. Do not pass `userId` `userSecret` to this method.
|
|
2417
|
+
|
|
2418
|
+
|
|
2419
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
2420
|
+
|
|
2421
|
+
##### accountId: `string`<a id="accountid-string"></a>
|
|
2422
|
+
|
|
2423
|
+
##### brokerageOrderId: `string`<a id="brokerageorderid-string"></a>
|
|
2424
|
+
|
|
2425
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
|
2426
|
+
|
|
2427
|
+
[AccountOrder](./models/account-order.ts)
|
|
2428
|
+
|
|
2429
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
|
2430
|
+
|
|
2431
|
+
`/accounts/{accountId}/orders/{brokerageOrderId}` `GET`
|
|
2432
|
+
|
|
2433
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
|
2434
|
+
|
|
2435
|
+
---
|
|
2436
|
+
|
|
2437
|
+
|
|
2371
2438
|
### `snaptrade.experimentalEndpoints.getAllAccountOrders`<a id="snaptradeexperimentalendpointsgetallaccountorders"></a>
|
|
2372
2439
|
|
|
2373
2440
|
Returns a list of recent orders in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/positions/all`.
|
|
@@ -2441,6 +2508,74 @@ Number of days in the past to fetch the most recent orders. Defaults to the last
|
|
|
2441
2508
|
---
|
|
2442
2509
|
|
|
2443
2510
|
|
|
2511
|
+
### `snaptrade.experimentalEndpoints.getAllAccountRecentOrders`<a id="snaptradeexperimentalendpointsgetallaccountrecentorders"></a>
|
|
2512
|
+
|
|
2513
|
+
A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders.
|
|
2514
|
+
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.
|
|
2515
|
+
Differs from `/accounts/{accountId}/orders/all` in that it is always realtime, and only checks the last 24 hours as opposed to the last 30 days.
|
|
2516
|
+
By default only returns executed orders, but that can be changed by setting *only_executed* to false.
|
|
2517
|
+
|
|
2518
|
+
Every order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. `data_freshness.as_of` is the time of this live request.
|
|
2519
|
+
|
|
2520
|
+
**Experimental:** this endpoint may change without notice.
|
|
2521
|
+
|
|
2522
|
+
**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](https://dashboard.snaptrade.com/settings/billing)**
|
|
2523
|
+
|
|
2524
|
+
|
|
2525
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
|
2526
|
+
|
|
2527
|
+
##### Commercial API Key Auth<a id="commercial-api-key-auth"></a>
|
|
2528
|
+
|
|
2529
|
+
```typescript
|
|
2530
|
+
const getAllAccountRecentOrdersResponse =
|
|
2531
|
+
await commercialApiKeyClient.experimentalEndpoints.getAllAccountRecentOrders({
|
|
2532
|
+
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2533
|
+
onlyExecuted: true,
|
|
2534
|
+
userId: "snaptrade-user-123",
|
|
2535
|
+
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2536
|
+
});
|
|
2537
|
+
```
|
|
2538
|
+
|
|
2539
|
+
Required credentials for this mode:
|
|
2540
|
+
|
|
2541
|
+
- `userId` (string, required): 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.
|
|
2542
|
+
|
|
2543
|
+
- `userSecret` (string, required): 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](/reference/Authentication/Authentication_resetSnapTradeUserSecret).
|
|
2544
|
+
|
|
2545
|
+
##### Personal API Key Auth<a id="personal-api-key-auth"></a>
|
|
2546
|
+
|
|
2547
|
+
```typescript
|
|
2548
|
+
const getAllAccountRecentOrdersResponse =
|
|
2549
|
+
await personalApiKeyClient.experimentalEndpoints.getAllAccountRecentOrders({
|
|
2550
|
+
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2551
|
+
onlyExecuted: true,
|
|
2552
|
+
});
|
|
2553
|
+
```
|
|
2554
|
+
|
|
2555
|
+
The client identifies the user in this mode. Do not pass `userId` `userSecret` to this method.
|
|
2556
|
+
|
|
2557
|
+
|
|
2558
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
2559
|
+
|
|
2560
|
+
##### accountId: `string`<a id="accountid-string"></a>
|
|
2561
|
+
|
|
2562
|
+
##### onlyExecuted: `boolean`<a id="onlyexecuted-boolean"></a>
|
|
2563
|
+
|
|
2564
|
+
Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well
|
|
2565
|
+
|
|
2566
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
|
2567
|
+
|
|
2568
|
+
[AllAccountOrdersResponse](./models/all-account-orders-response.ts)
|
|
2569
|
+
|
|
2570
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
|
2571
|
+
|
|
2572
|
+
`/accounts/{accountId}/orders/recent` `GET`
|
|
2573
|
+
|
|
2574
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
|
2575
|
+
|
|
2576
|
+
---
|
|
2577
|
+
|
|
2578
|
+
|
|
2444
2579
|
### `snaptrade.experimentalEndpoints.getUserAccountOrderDetailV2`<a id="snaptradeexperimentalendpointsgetuseraccountorderdetailv2"></a>
|
|
2445
2580
|
|
|
2446
2581
|
Returns the detail of a single order using the brokerage order ID provided as a path parameter.
|