Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ README_BEFORE_RELEASE.md
examples/tstests
/tmp/
localtest.sh
rest-ts.ts
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Node.js 22 or newer is supported.

Request and response types are exported from the package root. Every documented Info and Exchange operation has a corresponding `RestClient` method. Public lookup methods use `get...` names based on the information they return instead of exposing Hyperliquid's internal request type names. See the [examples](./examples) directory for REST API, WebSocket, and WebSocket API samples.

Exchange methods share one response wrapper: `ExchangeResponse` for acknowledgements, or `ExchangeResponse<T>` when the response contains data, such as `ExchangeResponse<OrderResponseData>` for orders and `ExchangeResponse<string>` for a new vault or subaccount address. Check `status === 'ok'` before reading `response.data`. Raw Exchange methods use `ExchangeResponse<unknown>` because the response depends on the submitted action. The same types apply to `RestClient` and `WebsocketAPIClient`.
Exchange methods share one response wrapper: `ExchangeResponse` for acknowledgements, or `ExchangeResponse<T>` when the response contains data, such as `ExchangeResponse<OrderResponseData>` for orders and `ExchangeResponse<string>` for a new vault or subaccount address. For an order result, check `order.status === 'ok'` before reading `order.response.data`. Raw Exchange methods use `ExchangeResponse<unknown>` because the response depends on the submitted action. The same types apply to `RestClient` and `WebsocketAPIClient`.

## Issues & Discussion

Expand Down Expand Up @@ -149,7 +149,6 @@ const mids = await client.getAllMids();
const book = await client.getOrderBook({
coin: 'BTC',
nSigFigs: 5,
mantissa: 1,
});
const perpSummary = await client.getPerpAccountSummary({
user: '0x1234567890123456789012345678901234567890',
Expand Down Expand Up @@ -188,7 +187,7 @@ console.log('Account:', balances.user);
console.log('Spot:', balances.spot.balances);
console.log('Perpetuals:', balances.perp.assetPositions);

const result = await client.submitOrder({
const order = await client.submitOrder({
orders: [
{
a: 'BTC',
Expand All @@ -200,6 +199,8 @@ const result = await client.submitOrder({
},
],
});

if (order.status === 'ok') console.log(order.response.data);
```

We've added some convenient wrapper methods for common workflows:
Expand Down Expand Up @@ -376,9 +377,9 @@ const book = {
type: 'l2Book',
coin: 'BTC',
nSigFigs: 5,
mantissa: 1,
fast: true,
} as const;

const fills = {
type: 'userFills',
user: '0x1234567890123456789012345678901234567890',
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@siebly/hyperliquid-api",
"version": "1.0.1",
"version": "1.0.2",
"description": "Professional JavaScript & Node.js SDK for Hyperliquid's REST APIs and WebSockets, built in TypeScript with strong end to end tests.",
"scripts": {
"clean": "node scripts/clean.mjs",
Expand Down
Loading