> For the complete documentation index, see [llms.txt](https://docs.hyperlink.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperlink.xyz/api/sdks.md).

# SDKs

HyperLink has no first-party SDK. Because it mirrors Hyperliquid's `/exchange` action format and EIP-712 signing, use Hyperliquid SDKs pointed at the HyperLink base URL for signed trading actions. HyperLink is a prime broker for Hyperliquid.

{% hint style="warning" %}
There is no `@hyperlink/sdk`, `@hyperlink-xyz/sdk`, or `hyperlink-sdk` package. Any guide showing `npm install @hyperlink/sdk` or `pip install hyperlink-sdk` is wrong. Reuse a Hyperliquid SDK for trading actions and change only the base URL.
{% endhint %}

## Base URL

Point a Hyperliquid SDK at `https://api.hyperlink.xyz`. WebSocket: `wss://api.hyperlink.xyz/ws`.

| Language   | Package                  | Repository                                                                                                     |
| ---------- | ------------------------ | -------------------------------------------------------------------------------------------------------------- |
| TypeScript | `@nktkas/hyperliquid`    | [github.com/nktkas/hyperliquid](https://github.com/nktkas/hyperliquid)                                         |
| Python     | `hyperliquid-python-sdk` | [github.com/hyperliquid-dex/hyperliquid-python-sdk](https://github.com/hyperliquid-dex/hyperliquid-python-sdk) |

{% hint style="info" %}
HyperLink **requires** a client order id (`cloid`) on every order. Pass it via the SDK's `cloid` parameter (Python) or the `c` field (TypeScript), as shown below.
{% endhint %}

## TypeScript

```bash
npm install @nktkas/hyperliquid viem
```

Set the transport's `apiUrl` to the HyperLink host. Everything else matches the Hyperliquid SDK.

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

// Point the transport at HyperLink instead of Hyperliquid.
const transport = new HttpTransport({ apiUrl: "https://api.hyperlink.xyz" });

const wallet = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);

// Signed trading actions.
const exchange = new ExchangeClient({ transport, wallet });

// Place a limit order. Asset is the numeric index (perps 0-9999, spot 10000+index).
const result = await exchange.order({
  orders: [
    {
      a: 0,             // asset index
      b: true,          // isBuy
      p: "50000",       // limit price
      s: "0.1",         // size
      r: false,         // reduceOnly
      t: { limit: { tif: "Gtc" } },
      c: "0x1234567890abcdef1234567890abcdef", // cloid (required)
    },
  ],
  grouping: "na",
});

console.log(result);
```

For streaming, set the WebSocket transport's `url` to the HyperLink WS endpoint:

```typescript
import { SubscriptionClient, WebSocketTransport } from "@nktkas/hyperliquid";

const wsTransport = new WebSocketTransport({ url: "wss://api.hyperlink.xyz/ws" });
const subs = new SubscriptionClient({ transport: wsTransport });
```

## Python

```bash
pip install hyperliquid-python-sdk
```

Pass `base_url="https://api.hyperlink.xyz"` to the `Exchange` constructor.

```python
import os

import eth_account
from hyperliquid.exchange import Exchange
from hyperliquid.utils.types import Cloid

BASE_URL = "https://api.hyperlink.xyz"

wallet = eth_account.Account.from_key(os.environ["PRIVATE_KEY"])

# Signed actions.
exchange = Exchange(wallet, base_url=BASE_URL)

# Place a limit order. "BTC" resolves to the perp asset index via Hyperliquid meta.
result = exchange.order(
    name="BTC",
    is_buy=True,
    sz=0.1,
    limit_px=50000,
    order_type={"limit": {"tif": "Gtc"}},
    reduce_only=False,
    cloid=Cloid.from_str("0x1234567890abcdef1234567890abcdef"),  # required
)

print(result)
```

| Parameter  | Required               | Description                                                                                                         |
| ---------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `wallet`   | Required               | An `eth_account` local account that signs actions. Use an approved [agent (API key)](/api/api-keys.md) for trading. |
| `base_url` | Required for HyperLink | Set to a HyperLink host. Omitting it defaults to Hyperliquid.                                                       |

## Discovering asset indexes

There is no HyperLink asset-mapping endpoint. Discover perp and spot indexes through Hyperliquid's `/info` `meta` and `spotMeta` responses, then use those indexes in HyperLink order actions.

| Market          | Index range                    |
| --------------- | ------------------------------ |
| Perps           | `0`-`9999`                     |
| Spot            | `10000 + index`                |
| Builder perps   | `100000 + dex * 10000 + index` |
| Outcome markets | Not supported                  |

## What the SDKs do not cover

The Hyperliquid SDKs do not know HyperLink private reads. For these, build raw signed requests using the [Authentication & Keys](/api/api-keys.md) signing scheme:

| Feature                                    | Action / endpoint                                                                               |
| ------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| Private balances, positions, orders, fills | `clearinghouseState`, `spotClearinghouseState`, `openOrders`, `userFills` over `POST /exchange` |

## Next steps

* [Authentication & Keys](/api/api-keys.md): signing and agent keys.
* [Exchange Methods](/api/exchange-methods.md): the unified `POST /exchange` actions and schemas.
* [API Quickstart](/api/setup.md): networks, base URLs, and your first request.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.hyperlink.xyz/api/sdks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
