Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/gateio-api/llms.txt

Use this file to discover all available pages before exploring further.

Gate.com options are European-style contracts on crypto underlyings. The SDK exposes every options endpoint through typed methods on RestClient. Public market data is available without credentials; account, order, and position methods require authentication. All request parameter types are defined in src/types/request/options.ts.

Market Data (Public)

Underlyings

An underlying is the asset that an option derives its value from (e.g. BTC_USDT). Start here to discover available option underlyings:
import { RestClient } from 'gateio-api';

const client = new RestClient();

// GET /options/underlyings
const underlyings = await client.getOptionsUnderlyings();
// Returns: [{ name: 'BTC_USDT', index_price: '...' }, ...]

Expiration Times

// GET /options/expirations — available expiry Unix timestamps for an underlying
const expirations = await client.getOptionsExpirationTimes({
  underlying: 'BTC_USDT',
});
// Returns: [1711670400, 1714262400, ...]

Contracts

// All option contracts for an underlying
// GET /options/contracts
const contracts = await client.getOptionsContracts({
  underlying: 'BTC_USDT',
  expiration: 1711670400, // optional: filter by expiry
});

// Single contract details
const contract = await client.getOptionsContract({ contract: 'BTC_USDT-20240328-60000-C' });
Gate.com option contract names follow the format {UNDERLYING}-{EXPIRY_DATE}-{STRIKE}-{TYPE} where type is C (call) or P (put). For example, BTC_USDT-20240328-60000-C is a BTC call option expiring 2024-03-28 with a $60,000 strike.

Order Book

// GET /options/order_book
const book = await client.getOptionsOrderBook({
  contract: 'BTC_USDT-20240328-60000-C',
  interval: '0',   // '0' | '0.1' | '0.01'
  limit: 10,
  with_id: true,
});

Tickers

// All tickers for an underlying
// GET /options/tickers
const tickers = await client.getOptionsTickers({
  underlying: 'BTC_USDT',
});

// Underlying-level ticker (combines calls + puts)
const underlyingTicker = await client.getOptionsUnderlyingTicker({ underlying: 'BTC_USDT' });

Candles

// GET /options/candlesticks
const candles = await client.getOptionsCandles({
  contract: 'BTC_USDT-20240328-60000-C',
  interval: '1h',  // '1m' | '5m' | '15m' | '30m' | '1h'
  limit: 100,
});

Recent Trades

// GET /options/trades
const trades = await client.getOptionsTrades({
  contract: 'BTC_USDT-20240328-60000-C',
  type: 'C',   // 'C' = calls, 'P' = puts (filters by type, not specific contract)
  limit: 50,
});

Account (Authenticated)

const client = new RestClient({ apiKey: '...', apiSecret: '...' });

// GET /options/accounts — options portfolio value and Greeks summary
const optionsAccount = await client.getOptionsAccount();
console.log('Total equity:', optionsAccount.total);
console.log('Delta:', optionsAccount.delta);
console.log('Gamma:', optionsAccount.gamma);

// Account ledger
const changes = await client.getOptionsAccountChange({
  type: 'prem',   // 'dnw' | 'prem' | 'fee' | 'refr' | 'set'
  limit: 100,
  from: Math.floor(Date.now() / 1000) - 86400 * 7,
});

Positions

// All positions for a given underlying
// GET /options/positions
const positions = await client.getOptionsPositionsUnderlying({
  underlying: 'BTC_USDT',
});

// Single position by contract
// GET /options/positions/{contract}
const btcCallPosition = await client.getOptionsPositionContract({
  contract: 'BTC_USDT-20240328-60000-C',
});
console.log('Size:', btcCallPosition.size);
console.log('Entry price:', btcCallPosition.entry_price);

// Closed/liquidated positions
// GET /options/position_close
const closedPositions = await client.getOptionsLiquidation({
  underlying: 'BTC_USDT',
  contract: 'BTC_USDT-20240328-60000-C',
});

Orders

Placing an Order

// POST /options/orders
// Positive size = buy (long), negative size = sell (write)
const order = await client.submitOptionsOrder({
  contract: 'BTC_USDT-20240328-60000-C',
  size: 10,          // 10 contracts
  price: '500',      // option premium in USDT
  tif: 'gtc',        // 'gtc' | 'ioc' | 'poc'
  reduce_only: false,
});

console.log('Order ID:', order.id);
console.log('Status:', order.status);

Querying Orders

// GET /options/orders
const openOrders = await client.getOptionsOrders({
  underlying: 'BTC_USDT',
  status: 'open',
  limit: 20,
});

const finishedOrders = await client.getOptionsOrders({
  contract: 'BTC_USDT-20240328-60000-C',
  status: 'finished',
  limit: 100,
  from: Math.floor(Date.now() / 1000) - 86400 * 30,
});

// Single order by ID
// GET /options/orders/{order_id}
const order = await client.getOptionsOrder({ order_id: 987654321 });

Amending an Order

// PUT /options/orders/{order_id}
await client.amendOptionsOrder({
  order_id: 987654321,
  contract: 'BTC_USDT-20240328-60000-C',
  price: '480',   // new price
  size: 10,       // new size
});

Cancelling Orders

// Cancel a single order
// DELETE /options/orders/{order_id}
await client.cancelOptionsOrder({ order_id: 987654321 });

// Cancel all open orders for an underlying
// DELETE /options/orders
await client.cancelAllOpenOptionsOrders({
  underlying: 'BTC_USDT',
});

Settlement History

// Public settlement records (all users)
// GET /options/settlements
const settlements = await client.getOptionsSettlementHistory({
  underlying: 'BTC_USDT',
  limit: 50,
});

// Your personal settlement history
// GET /options/my_settlements
const mySettlements = await client.getOptionsMySettlements({
  underlying: 'BTC_USDT',
  limit: 50,
  from: Math.floor(Date.now() / 1000) - 86400 * 90, // past 90 days
});

Personal Trade History

// GET /options/my_trades
const myTrades = await client.getOptionsPersonalHistory({
  underlying: 'BTC_USDT',
  limit: 100,
});

Market Maker Protection (MMP)

Market Maker Protection auto-cancels orders when a threshold of volume or delta is breached within a time window — protecting market makers from adverse fills during periods of abnormal activity.
// Configure MMP for an underlying
// POST /options/mmp
await client.setOptionsMMPSettings({
  underlying: 'BTC_USDT',
  window: 5000,          // rolling window in ms (1–5000)
  frozen_period: 10000,  // freeze duration in ms (0 = freeze until manual reset)
  qty_limit: '100',      // max contracts in the window
  delta_limit: '10',     // max net delta in the window
});

// Check current MMP settings
const mmSettings = await client.getOptionsMMPSettings({ underlying: 'BTC_USDT' });

// Manually reset MMP after a trigger
await client.resetOptionsMMPSettings({ underlying: 'BTC_USDT' });
When MMP triggers, all open orders for the protected underlying are cancelled. Ensure you have logic to handle the frozen_period and reset MMP before resuming market making.

Countdown Cancel (Dead-Man’s Switch)

// POST /options/countdown_cancel_all
// All open options orders will be cancelled after 60 s unless renewed
await client.submitOptionsCountdownCancel({
  timeout: 60,
  underlying: 'BTC_USDT',
});

Build docs developers (and LLMs) love