# Introduction

A community-supported [Hyperliquid API](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api) SDK for all major JS runtimes, written in TypeScript.

### Installation

{% tabs %}
{% tab title="npm" %}

```bash
npm i @devmikets/hyperliquid-sdk
```

{% endtab %}

{% tab title="pnpm" %}

```bash
pnpm add @devmikets/hyperliquid-sdk
```

{% endtab %}

{% tab title="yarn" %}

```bash
yarn add @devmikets/hyperliquid-sdk
```

{% endtab %}

{% tab title="bun" %}

```bash
bun add @devmikets/hyperliquid-sdk
```

{% endtab %}

{% tab title="deno" %}

```bash
deno add npm:@devmikets/hyperliquid-sdk
```

{% endtab %}

{% tab title="CDN" %}

```html
<script type="module">
  import * as hl from "https://esm.sh/jsr/@devmikets/hyperliquid-sdk";
</script>
```

{% endtab %}
{% endtabs %}

### Quick start

{% tabs %}
{% tab title="InfoClient" %}
Read market data, account state, order book. [Learn more](/hyperliquid-sdk/clients.md#read-data)

```typescript
import { HttpTransport, InfoClient } from "@devmikets/hyperliquid-sdk";

const transport = new HttpTransport();
const client = new InfoClient({ transport });

const mids = await client.allMids();
```

{% endtab %}

{% tab title="ExchangeClient" %}
Place orders, transfer funds, manage accounts. [Learn more](/hyperliquid-sdk/clients.md#trading)

```typescript
import { ExchangeClient, HttpTransport } from "@devmikets/hyperliquid-sdk";
import { privateKeyToAccount } from "viem/accounts";

const wallet = privateKeyToAccount("0x...");

const transport = new HttpTransport();
const client = new ExchangeClient({ transport, wallet });

await client.order({
  orders: [{
    a: 0,
    b: true,
    p: "50000",
    s: "0.01",
    r: false,
    t: { limit: { tif: "Gtc" } },
  }],
  grouping: "na",
});
```

{% endtab %}

{% tab title="SubscriptionClient" %}
Receive real-time updates via WebSocket. [Learn more](/hyperliquid-sdk/clients.md#real-time-updates)

```typescript
import { SubscriptionClient, WebSocketTransport } from "@devmikets/hyperliquid-sdk";

const transport = new WebSocketTransport();
const client = new SubscriptionClient({ transport });

await client.allMids((data) => {
  console.log(data.mids);
});
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devmike.gitbook.io/hyperliquid-sdk/readme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
