cancel spot order

API details

This API cancels a spot market order. Note that only limit orders can be canceled; swap orders, being similar to market orders, are either fully executed or canceled.

Cancel spot order

post
Body
typestringOptional
userIdstringOptional
noncestringOptional
messagestringOptional
hashstringOptional
signaturestringOptional
Responses
200
OK
post
POST /v1/tx/cancel-spot-order HTTP/1.1
Host: testnetopenapi.hibit.app
Content-Type: application/json
Accept: */*
Content-Length: 96

{
  "type": "text",
  "userId": "text",
  "nonce": "text",
  "message": "text",
  "hash": "text",
  "signature": "text"
}
{
  "code": 1,
  "message": "text",
  "data": {}
}

Code example

import { hibitClient } from '@delandlabs/hibit-sdk';

const options = {
  network: HibitNetwork.Testnet,
  hin: 10000n,
  proxyKey:"your proxy key in hexadecimal (hex) format"
};
hibitClient.setOptions(options);

/**
 * Supports three cancellation scenarios:
 * 1. Cancel by order ID
 * 2. Cancel by market ID and side
 * 3. Cancel all orders in a market
 *
 * @example Scenario 1: Cancel a specific order by ID
 * ```typescript
 * const cancelSingleOrder: CancelSpotOrderInput = {
 *   orderId: "1234567890abcdef"
 * };
 * ```
 *
 * @example Scenario 2: Cancel all orders of a specific side in a market
 * ```typescript
 * const cancelOrdersBySide: CancelSpotOrderInput = {
 *   marketId: BigInt("12345"),
 *   orderSide: OrderSide.Bid
 * };
 * ```
 *
 * @example Scenario 3: Cancel all orders in a market
 * ```typescript
 * const cancelAllMarketOrders: CancelSpotOrderInput = {
 *   marketId: BigInt("12345"),
 *   isCancelAll: true
 * };
 * ```
 */
const cancelReq: CancelSpotOrderInput = {
  ...
};

await client.cancelSpotOrder(cancelReq);

SDK

Source code https://github.com/Deland-Labs/hibit-sdk

References

What is HIN?

How to Obtain your HIN and Proxy Key?

Last updated