> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tayho.io/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK overview

> The provider-neutral Tayho client for authenticated API reads, direct onchain preparation, relayed writes, and realtime.

# SDK overview

`@tayho/sdk` is a provider-neutral TypeScript client for browsers, Node.js, and edge runtimes. It
uses the Tayho API for indexed data and lifecycle state, can optionally read execution-critical
values directly from HyperEVM, and submits every signed write through the Tayho relayer.

<Warning>
  The package is currently a development-preview workspace package. Public npm availability is not
  asserted until Tayho publishes and verifies the package.
</Warning>

## Design guarantees

* The API key is required when creating a client.
* Environment configuration is validated before data is trusted.
* API results preserve request IDs, opaque cursors, and indexed checkpoints.
* Onchain amounts and identifiers are decoded to `bigint`.
* RPC and wallet adapters expose narrow interfaces rather than arbitrary provider access.
* Contract preparation reads use named ABIs and one pinned-block Multicall3 snapshot.
* No adapter exposes `eth_getLogs` or transaction broadcasting.
* Writes produce inspectable typed data and stable idempotency keys before submission.

## Client modules

| Module          | Reads                                                                                                      | Writes                                            |
| --------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| `configuration` | Deployment identity and capabilities                                                                       | —                                                 |
| `markets`       | Market, funding, stats, price, oracle, liquidity, events, trades, candles                                  | —                                                 |
| `accounts`      | Positions, sessions, portfolio, balances, exposure, PnL, activity, trades, funding, settlements, transfers | —                                                 |
| `positions`     | Position, events, settlements, live risk                                                                   | Add margin                                        |
| `sessions`      | Via `accounts.sessions`                                                                                    | Authorize, revoke                                 |
| `vault`         | Protocol state, events, claims, account state                                                              | Deposit, withdraw                                 |
| `staking`       | Protocol state, events, account rewards                                                                    | Stake, claim, unstake                             |
| `orders`        | Order status and account orders                                                                            | Prepare/submit order, prepare/submit cancellation |
| `transactions`  | Indexed transaction correlation                                                                            | —                                                 |
| `realtime`      | Resumable channel events                                                                                   | Subscribe/unsubscribe control messages            |

## Client shape

```ts theme={null}
import { createTayhoClient } from "@tayho/sdk";

const client = createTayhoClient({
  environment: "development",
  apiKey: "th_pk_example",
});

const configuration = await client.configuration();
const markets = await client.markets.list({ limit: 25 });
```

`configuration()` is memoized for the client lifetime. Create a new client when changing
environment, API key, API origin, signer, or RPC configuration.

## Choose a data path

<CardGroup cols={2}>
  <Card title="Configuration and providers" href="/public/sdk/configuration" icon="sliders-horizontal">
    Configure API origins, RPC failover, EIP-1193, viem, ethers, and typed-data signing.
  </Card>

  <Card title="Reads" href="/public/sdk/reads" icon="database">
    Browse every indexed and live read module and its consistency semantics.
  </Card>

  <Card title="Relayed actions" href="/public/sdk/actions" icon="signature">
    Prepare, inspect, sign, submit, and wait for non-order actions.
  </Card>

  <Card title="Orders" href="/public/sdk/orders" icon="list-checks">
    Submit market and conditional orders and signed cancellation requests.
  </Card>
</CardGroup>

## Package entry points

| Import                 | Purpose                                                              |
| ---------------------- | -------------------------------------------------------------------- |
| `@tayho/sdk`           | Client, public response types, `TayhoError`, and signer/reader types |
| `@tayho/sdk/actions`   | Action/order preparation and receipt types                           |
| `@tayho/sdk/contracts` | Typed contract snapshot helpers                                      |
| `@tayho/sdk/rpc`       | Native RPC reader and narrow `ChainReader`                           |
| `@tayho/sdk/realtime`  | Realtime client and event types                                      |
| `@tayho/sdk/eip1193`   | Browser wallet reader and signer                                     |
| `@tayho/sdk/viem`      | viem reader and signer adapters                                      |
| `@tayho/sdk/ethers`    | ethers v6 reader and signer adapters                                 |

Ethers is an optional peer dependency. Import only the adapter your application uses.
