DocsExchange Endpoint
POST/v1/exchanges/hyperliquid/exchange

Exchange Endpoint

Place orders, cancel orders, update leverage, and manage positions. 100% compatible with Hyperliquid's /exchange endpoint.

Base URL

https://api.paperx.co/v1/exchanges/hyperliquid/exchange

Request Format

All requests are POST with a JSON body containing an action object:

{
  "action": {
    "type": "actionType",
    // ... action parameters
  }
}

Order Actions

order

Place a new order

Request

{
  "action": {
    "type": "order",
    "orders": [
      {
        "a": 0,              // Asset index (0 = BTC)
        "b": true,           // true = buy, false = sell
        "p": "97000.00",     // Price (string)
        "s": "0.1",          // Size (string)
        "r": false,          // Reduce only
        "t": {
          "limit": {
            "tif": "Gtc"     // Time in force
          }
        }
      }
    ],
    "grouping": "na"
  }
}

Order Parameters

FieldTypeDescription
anumberAsset index (from meta endpoint)
bbooleantrue = buy/long, false = sell/short
pstringLimit price (use "0" for market orders)
sstringOrder size in base currency
rbooleanReduce only (close position only)

Time in Force Options

ValueDescription
GtcGood til cancelled (default)
IocImmediate or cancel
AloAdd liquidity only (post-only)

Response

{
  "status": "ok",
  "response": {
    "type": "order",
    "data": {
      "statuses": [
        {
          "resting": {
            "oid": 12345
          }
        }
      ]
    }
  }
}

Market Order Example

Place a market order using IOC

{
  "action": {
    "type": "order",
    "orders": [
      {
        "a": 0,
        "b": true,
        "p": "0",            // Price 0 = market order
        "s": "0.1",
        "r": false,
        "t": {
          "limit": {
            "tif": "Ioc"     // Immediate or cancel
          }
        }
      }
    ],
    "grouping": "na"
  }
}

cancel

Cancel one or more orders

Request

{
  "action": {
    "type": "cancel",
    "cancels": [
      {
        "a": 0,        // Asset index
        "o": 12345     // Order ID
      }
    ]
  }
}

Response

{
  "status": "ok",
  "response": {
    "type": "cancel",
    "data": {
      "statuses": ["success"]
    }
  }
}

cancelByCloid

Cancel order by client order ID

{
  "action": {
    "type": "cancelByCloid",
    "cancels": [
      {
        "asset": 0,
        "cloid": "my-order-123"
      }
    ]
  }
}

Position Management

updateLeverage

Update leverage for an asset

Request

{
  "action": {
    "type": "updateLeverage",
    "asset": 0,
    "leverage": 10,
    "isCross": true
  }
}

Parameters

FieldTypeDescription
assetnumberAsset index
leveragenumberLeverage (1-50)
isCrossbooleantrue = cross margin, false = isolated

updateIsolatedMargin

Add or remove margin from isolated position

{
  "action": {
    "type": "updateIsolatedMargin",
    "asset": 0,
    "isBuy": true,
    "ntli": 100    // Amount to add (negative to remove)
  }
}

Trigger Orders (TP/SL)

order with trigger

Place stop loss or take profit orders

Stop Loss Example

{
  "action": {
    "type": "order",
    "orders": [
      {
        "a": 0,
        "b": false,          // Sell to close long
        "p": "95000.00",     // Execution price
        "s": "0.1",
        "r": true,           // Reduce only
        "t": {
          "trigger": {
            "triggerPx": "95500.00",
            "isMarket": true,
            "tpsl": "sl"     // "sl" or "tp"
          }
        }
      }
    ],
    "grouping": "na"
  }
}

Take Profit Example

{
  "action": {
    "type": "order",
    "orders": [
      {
        "a": 0,
        "b": false,
        "p": "100000.00",
        "s": "0.1",
        "r": true,
        "t": {
          "trigger": {
            "triggerPx": "99500.00",
            "isMarket": true,
            "tpsl": "tp"
          }
        }
      }
    ],
    "grouping": "na"
  }
}

Order Modification

modify

Modify an existing order

{
  "action": {
    "type": "modify",
    "oid": 12345,
    "order": {
      "a": 0,
      "b": true,
      "p": "98000.00",
      "s": "0.15",
      "r": false,
      "t": { "limit": { "tif": "Gtc" } }
    }
  }
}

batchModify

Modify multiple orders at once

{
  "action": {
    "type": "batchModify",
    "modifies": [
      {
        "oid": 12345,
        "order": { "a": 0, "b": true, "p": "98000.00", "s": "0.1", "r": false, "t": { "limit": { "tif": "Gtc" } } }
      },
      {
        "oid": 12346,
        "order": { "a": 0, "b": false, "p": "99000.00", "s": "0.1", "r": false, "t": { "limit": { "tif": "Gtc" } } }
      }
    ]
  }
}

TWAP Orders

Time-Weighted Average Price orders split large orders into smaller chunks executed over time.

twapOrder

Place a TWAP order

Request

{
  "action": {
    "type": "twapOrder",
    "twap": {
      "a": 0,           // Asset index
      "b": true,        // Buy/sell
      "s": "1.0",       // Total size
      "m": 60,          // Duration in minutes
      "r": false,       // Reduce only
      "t": false        // Randomize timing
    }
  }
}

Response

{
  "status": "ok",
  "response": {
    "type": "twapOrder",
    "data": {
      "twapId": "twap-uuid-here",
      "status": "running"
    }
  }
}

twapCancel

Cancel a running TWAP order

{
  "action": {
    "type": "twapCancel",
    "a": 0,
    "t": "twap-uuid-here"
  }
}

Transfers

usdClassTransfer

Transfer between spot and perp accounts

{
  "action": {
    "type": "usdClassTransfer",
    "amount": "1000.00",
    "toPerp": true    // true = spot to perp, false = perp to spot
  }
}

Dead Man's Switch

scheduleCancel

Schedule automatic cancellation of all orders

Set Schedule

{
  "action": {
    "type": "scheduleCancel",
    "time": 1700000000000    // Unix timestamp (ms)
  }
}

Remove Schedule

{
  "action": {
    "type": "scheduleCancel"
  }
}

Important Notes

  • • All prices and sizes must be strings, not numbers
  • • Asset indices can be found using the meta info request
  • • Market orders use price "0" with IOC time-in-force
  • • Reduce-only orders can only decrease position size
  • • Maximum leverage is 50x for most assets

Next: Account Endpoints

Learn about account management, balance reset, and subscription endpoints.

Account Endpoints Reference