Skip to main content

Requests

Paging

ListOrderHistory, ListTrades and ListFundingPayments take a window, limit and offset:
  • window.from is inclusive and window.to exclusive. Either may be left out, and a to before from answers invalid_argument.
  • No limit, or 0, means 50; above 200 is clamped to 200. A negative limit or offset answers invalid_argument.
  • hasMore says a further page exists: request it at offset plus the number of rows returned.
  • On ListTrades and ListFundingPayments hasMore is worked out just before the page is read, so a row recorded in between can leave a full page saying false with a row still behind it. Where no row may be missed, as when reconciling fills, fetch the next page after every full page and stop at the first short one.
  • Pin window.to while paging, so a row recorded after it cannot shift later offsets. A row recorded late inside the window still can, so de-duplicate on each row’s id.

Retries

  • Every read, CancelOrder, CancelAllOrders and SetLeverage are safe to retry.
  • PlaceOrder is safe to retry with the clientOrderId the first attempt carried: a retry answers the first order instead of placing another.
  • ClosePosition never closes twice: a retry with the first clientOrderId replays the first close, and one without closes whatever is left.
  • CloseAllPositions is a new flatten on every call, closing whatever is still open.

Errors

A call that reaches an endpoint and fails answers with a non-200 status and a JSON body, { "code": "failed_precondition", "message": "order is not open" }. Switch on code, not on the HTTP status: two codes share 400, and resource_exhausted comes with 429 or 413. StreamAccountEvents answers HTTP 200 and reports an error in its last frame instead. Messages are generic except for invalid_argument, failed_precondition and resource_exhausted, which name the cause. An error from an endpoint carries an X-Request-Id header: if a failed call needs our help, send it in the Hypernova Discord.

Error kinds

Some refusals name their case in an X-Hn-Error-Kind header, so a bot can branch without parsing the message. No other response carries the header; treat a kind you do not know as its code alone. The stream has kinds of its own, listed under Stream errors, and carries them in its last frame.

Refusals that carry no error body

A client that reads Retry-After blindly will crash on the gateway’s bare 429. Back off and retry on any 429 you can’t parse.

Rate limits

Limits apply per user, shared across all of that user’s keys, as a sustained rate with a burst allowance.
  • Exits have a budget of their own that placements cannot use up, so an emergency flatten never queues behind entries.
  • The class follows the endpoint, never the body: a PlaceOrder counts as a write even when it only reduces a position. CancelAllOrders and CloseAllPositions count as one call however much they affect.
  • You may hold 20 streams open at once, and the events on an open stream cost nothing against any limit. To follow an account, open one real-time stream instead of polling.
  • A call over a per-user limit answers resource_exhausted with a Retry-After in whole seconds. No response carries a remaining-calls or reset header, so pace calls from the limits above.
  • Calls from one address are also limited at the edge, across every user they act for, and so are all calls to the API together. A call over either answers 429 resource_exhausted with Retry-After: 60.