# tda-wsjson-client

> WebSocket client for the TD Ameritrade wsjson API

Latest version **0.10.2** (published 2023-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install tda-wsjson-client
pnpm add tda-wsjson-client
yarn add tda-wsjson-client
bun add tda-wsjson-client
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.10.2 |
| Published | 2023-12-12 |
| First published | 2023-06-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 13 |
| Unpacked size | 1.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Felipe Lima |
| Maintainers | felipecsl |

## Links

- npm: https://www.npmjs.com/package/tda-wsjson-client
- npm.io page: https://npm.io/package/tda-wsjson-client

## Dependencies (13)

- [ws](https://npm.io/package/ws.md) ^8.13.0
- [debug](https://npm.io/package/debug.md) ^4.3.4
- [obgen](https://npm.io/package/obgen.md) ^0.5.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [prompts](https://npm.io/package/prompts.md) 2.4.2
- [resolve](https://npm.io/package/resolve.md) 1.22.4
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.15.8
- [@types/node](https://npm.io/package/@types/node.md) ^20.3.0
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.186
- [isomorphic-ws](https://npm.io/package/isomorphic-ws.md) ^5.0.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.16.0
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.16.0
- [@badgateway/oauth2-client](https://npm.io/package/@badgateway/oauth2-client.md) ^2.2.0

## Recent versions

- 0.10.2 (latest) — 2023-12-12
- 0.10.1 — 2023-12-11
- 0.10.0 — 2023-12-11
- 0.9.0 — 2023-12-10
- 0.8.2 — 2023-12-10
- 0.8.1 — 2023-12-10
- 0.8.0 — 2023-12-10
- 0.7.2 — 2023-10-10
- 0.7.1 — 2023-09-12
- 0.7.0 — 2023-09-11
- 0.6.0 — 2023-09-08
- 0.5.3 — 2023-08-30
- 0.5.2 — 2023-08-30
- 0.5.1 — 2023-08-30
- 0.5.0 — 2023-08-30
- … 14 more at https://npm.io/package/tda-wsjson-client/versions

## README

# TD Ameritrade WsJson API client

This is a node and browser API client for the (undocumented) TD Ameritrade WebSocket API.

🚧 Work in progress 🚧

# Prerequisites

- Node 16+

Create a `.env` file and set your TD Ameritrade oauth access token:

```
CLIENT_ID=your-client-id
ACCESS_TOKEN=your-access-token
REFRESH_TOKEN=your-refresh-token
TOKEN_EXPIRES_AT=your-token-expires-at
```

# Building for Node

```
yarn install
yarn build
```

# Running the example app

```
cd example
yarn install
yarn link tda-wsjson-client
yarn start
```

# Supported APIs

- ✅ Authentication via access token
- ✅ Quotes
- ✅ Price History (chart)
- ✅ Account positions
- ✅ Place & submit order
- ✅ Cancel order
- ✅ User properties
- ✅ Create alert
- ✅ Cancel alert
- ✅ Instrument search
- ✅ Option chains
- ✅ Alert lookup
- ✅ Option chain details
- ✅ Option chain quotes
- ✅ Option quotes
- ✅ Order events
- ✅ Market depth
- ✅ Get watchlist

# Not yet implemented

- ❌ Instrument order events
- ❌ Alert subscription
- ❌ And many more 😀

# Usage

```typescript
import WsJsonClient from "tda-wsjson-client/wsJsonClient";

const client = new WsJsonClient();
await client.authenticate(accessToken);
console.log(loginResponse);
const chartRequest = {
  symbol: "UBER",
  timeAggregation: "DAY",
  range: "YEAR2",
  includeExtendedHours: true,
};
for await (const event of client.chart(chartRequest)) {
  console.log(event);
}
```

For more sample usage check out https://github.com/felipecsl/tda-wsjson-client/blob/master/src/testApp.ts and
https://github.com/felipecsl/tda-wsjson-client/blob/master/example/src/App.tsx

# Running tests

`yarn test`

# License

MIT

---
_Source: https://npm.io/package/tda-wsjson-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
