# TypeScript SDK

> The TypeScript SDK for the STX exchange.

Source: https://docs.stxapp.io/sdks/typescript/

`@stxapp/stx-typescript` is the TypeScript SDK for the STX exchange. Read markets, place and cancel orders, follow your account, and stream the [WebSocket channels](/websockets/), with every request signed by your API key and every response typed. Response fields are described in the [API reference](/api/rest/).

```bash
npm install @stxapp/stx-typescript
```

```ts
import { STX } from "@stxapp/stx-typescript";

// Reads your API key and exchange from STX_* environment variables or ~/.stx/credentials.
const client = new STX();

const me = await client.me();
const page = await client.markets({ status: "open", limit: 5 });
console.log(me.user_id, page.items.map((m) => m.symbol));
```

[Authentication](/sdks/typescript/authentication/) shows how to give the client your API key, and [Environments](/environments/) lists the exchanges and where to get a key.

## Prices and quantities are strings

Amounts come back as decimal strings, exactly as the API sends them (`order.price === "0.5600"`), and orders take strings too: `{ price: "0.56", quantity: "2" }`. Passing a number throws a `TypeError` before anything is sent. Use a decimal library for arithmetic, not `Number` or `parseFloat`.

Response objects keep the API's snake_case field names (`order.client_order_id`); method options are camelCase (`clientOrderId`).

## Where to go next

  - [Installation](/sdks/typescript/installation/): Install and import.
  - [Authentication](/sdks/typescript/authentication/): Pass your API key to the client.
  - [Environments](/sdks/typescript/environments/): Pick the exchange to connect to.
  - [Markets](/sdks/typescript/markets/): Markets, events and pagination.
  - [Trading](/sdks/typescript/trading/): Place and cancel orders.
  - [Portfolio](/sdks/typescript/portfolio/): Balance, positions, fills and history.
  - [WebSockets](/sdks/typescript/websockets/): Stream channels and keep a live account view.
  - [Errors & retries](/sdks/typescript/errors-and-retries/): Typed errors and what the client retries.
  - [OAuth apps](/isv/typescript-sdk/): Act for other STX members from your app, with the OAuth client.
  - [API reference](/sdks/typescript/reference/): Every method and what it returns.
  - [Example scripts](https://github.com/stxapp/stx-typescript-demo): List markets, place and cancel an order, stream live data.

Released under the MIT license.
