> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0x0.exchange/llms.txt
> Use this file to discover all available pages before exploring further.

# API

All trading interactions happen via the `exchange` namespace.

## Order Management

### `spectre_placeOrder`

Place a new order.

**Parameters:**

* `market` (string): e.g., "BTC-USDC"
* `side` (string): "BUY" or "SELL"
* `type` (string): "LIMIT", "MARKET", "STOP\_LIMIT", "STOP\_MARKET"
* `qty` (float): Quantity of base asset.
* `price` (float, optional): Limit price. Required for LIMIT orders.
* `trigger_price` (float, optional): Trigger price. Required for STOP orders.
* `stealth_data` (object, optional): Privacy metadata (see Privacy & Security).

**Example Request:**

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "spectre_placeOrder",
  "params": {
    "market": "BTC-USDC",
    "side": "BUY",
    "type": "LIMIT",
    "qty": 0.5,
    "price": 65000.00
  },
  "id": 1
}
```

**Example Response:**

```json theme={null}
{
  "jsonrpc": "2.0",
  "result": {
    "order_id": "3af4...",
    "trades": [],
    "status": "OPEN"
  },
  "id": 1
}
```

***

### `spectre_modifyOrder`

Atomically modify an existing order. This is faster than Cancel + Replace and maintains priority if the quantity is decreased.

**Parameters:**

* `market` (string)
* `order_id` (string)
* `new_price` (float, optional)
* `new_qty` (float, optional)

**Example Request:**

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "spectre_modifyOrder",
  "params": {
    "market": "BTC-USDC",
    "order_id": "3af4...",
    "new_price": 65100.00
  },
  "id": 2
}
```

***

### `spectre_cancelOrder`

Cancel an open order.

**Parameters:**

* `market` (string)
* `order_id` (string)

***

## Market Data

### `spectre_getOrderbook`

Get the current snapshot of the orderbook.

**Parameters:**

* `market` (string)

**Returns:**

* `bids`: List of `[price, qty]` tuples.
* `asks`: List of `[price, qty]` tuples.
* `timestamp`: Engine timestamp.

***

## Account Data

### `spectre_getPendingOrders`

Get open orders for a specific market.

**Parameters:**

* `market` (string)
* `offset` (int, default 0): Pagination offset.

### `spectre_getAllPendingOrders`

Get open orders across ALL markets.

### `spectre_closePosition`

Closes an open position.

**Parameters:**

* `position_hash` (string): The unique hash of the position to close.
* `type` (string): "MARKET" or "LIMIT".
* `price` (float): Required if LIMIT.
* `signature` (string): Standard authentication signature.
