Skip to content

docs(examples): add hyperliquid-examples-nodejs.md (one page of copy-ready snippets) - #19

Open
harbourlark wants to merge 1 commit into
sieblyio:mainfrom
harbourlark:docs/examples-markdown
Open

harbourlark wants to merge 1 commit into
sieblyio:mainfrom
harbourlark:docs/examples-markdown

Conversation

@harbourlark

Copy link
Copy Markdown

Adds examples/hyperliquid-examples-nodejs.md, a single page of short, copy-ready snippets in the same style as kucoin-api/examples/kucoin-*-examples-nodejs.md.

Why: Context7 parses markdown, and its benchmark for /sieblyio/hyperliquid-api is still 0 after the 27 Nov refresh ("low doc coverage"), while kucoin-api (with the examples markdown files) scores 73.88. The runnable .ts examples stay as they are; this page gives indexers and readers one place to find each task.

Covers: client setup (public, private key, API wallet with accountAddress, vault), Info market data (mids, L2 book, candles, trades, perp/spot metadata, resolveAsset/nameToCoin, funding history, predicted funding, exchange status), account reads (balances, positions for any address, open orders, fills by time, order status by oid/cloid, funding payments, ledger updates, rate limit), trading (GTC limit with cloid, market order and market close with expiresAfter, spot order, normalTpsl entry + TP/SL, trailing stop, modify, cancel by oid/cloid, cancel all, schedule cancel, leverage and isolated margin, TWAP), user-signed actions (approve API wallet, spot/perp USDC transfer, send, withdraw), WebSocket public and account streams, unsubscribe, WebSocket API, and error handling.

Checked against @siebly/hyperliquid-api 1.0.5:

  • All 35 snippets type-check as standalone files under tsc --strict (module nodenext).
  • Public Info snippets, the public WebSocket subscription, the unsubscribe snippet and the WS API getAllMids call ran live against mainnet.
  • Signed paths were exercised with an unfunded throwaway key only (Hyperliquid answered "User or API Wallet ... does not exist", so signing and routing work); no real orders were placed.
  • The WebSocket snippets set connectionTimeout: 5000, because with the 1000 ms default the first handshake from my test box timed out before reconnecting.

Prices and sizes in the trading snippets mirror the existing examples (far from market, around the $10 minimum).

… WS API

This document provides comprehensive examples for using the Hyperliquid API with Node.js, JavaScript, and TypeScript. It includes installation instructions, client creation, API usage for market data, account data, trading, and WebSocket subscriptions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant