> For the complete documentation index, see [llms.txt](https://docs.variational.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.variational.io/api-documentation/usage.md). Agents can also search and read this documentation through its [MCP server](https://docs.variational.io/~gitbook/mcp).

# Usage

Omni API usage, REST API descriptions, and rate limits/errors.

{% hint style="info" %}
Currently Omni's API is in **early access** and is only available in testnet.
{% endhint %}

### Connecting

```
https://api.omni.testnet.variational.io
```

All endpoints are under `/v1` and need an API key.

### API keys

Create a key from omni in testnet. A key is an Ed25519 key pair:

* The **public key** identifies the key: `0x` followed by 64 hex characters.
* The **private key** signs your requests. Keep it secret.

A key has the `read` scope, and optionally `trade` for placing and cancelling orders. See [Authentication](https://docs.variational.io/api-documentation/authentication.md) section on how to use the API key to sign requests.

### Reading Market Data

List the instruments you can trade and the rules an order must follow: price precision, size step, minimum notional and margin modes. Tickers give the latest mark and index price for one instrument or all of them.

* `GET /v1/instruments`, `GET /v1/instruments/{symbol}`&#x20;
* `GET /v1/tickers`, `GET /v1/tickers/{symbol}`

### Reading Position & Account Information

Read your account summary (equity, unrealized PnL and margin usage) and your open positions, each with its margin mode, leverage and estimated liquidation price. Values are priced at the time of API call.

* `GET /v1/account`
* `GET /v1/positions`, `GET /v1/positions/{symbol}`

### Placing & Managing Orders

Place market, limit, take-profit and stop-loss orders; a market or limit order can carry its own take-profit and stop-loss. Cancel a single order by its ID or your `client_order_id`, or cancel every pending order at once. Note: these endpoints need a key with the `trade` scope.

* `POST /v1/orders`: place an order. We recommend all interactions include a `client_order_id` to identify the order easily.&#x20;
* `DELETE /v1/orders`: cancel an order
* `DELETE /v1/orders/batch`: cancel every pending order (optionally per-instrument)
* `GET /v1/orders`: list your pending orders (optionally `?symbol=`), or look one up with `?client_order_id=`
* `GET /v1/orders/{order_id}`: read one order by its ID
* `GET /v1/orders/history` to view all orders, newest first (paginated)
* `GET /v1/fills` to view all fills, newest first (paginated)

#### Order format for POST /v1/orders

Orders include a JSON body to specify exactly what order to place. For example, a limit order to buy 1 BTC at 10,000 USDC, with a stop-loss attached at 1,000. Note we always recommend including a `client_order_id` set to a unique string, in the example below this is some bot identifier (`my-bot`) with a unique order number (`0001`).

```json
{
  "type": "limit",
  "symbol": "BTC-PERP",
  "side": "buy",
  "size": "1",
  "price": "10000",
  "trigger_by": "mark",
  "max_slippage": "0.01",
  "client_order_id": "my-bot:0001",
  "stop_loss": {
    "trigger_price": "1000",
    "trigger_by": "mark",
    "max_slippage": null
  }
}
```

The API answers `202` with `{"placed": [...]}`: the order, followed by its stop-loss. A `202` means the order was accepted, not that it filled. Then query `GET /v1/orders/{order_id}`, or `GET /v1/orders?client_order_id=my-bot:0001` to see whether it filled, and `GET /v1/fills` for the fill itself.

| Parameter         | Notes                                                                                                         |
| ----------------- | ------------------------------------------------------------------------------------------------------------- |
| `type`            | `market` · `limit` · `take_profit` · `stop_loss`                                                              |
| `symbol`          | The instrument, e.g. `BTC-PERP`, from `GET /v1/instruments`                                                   |
| `side`            | `buy` or `sell`                                                                                               |
| `size`            | Decimal string in base units, e.g. `"0.5"`. Must be a multiple of the instrument's `size_step`                |
| `price`           | Decimal string in USDC. **`limit` only.** Must satisfy the instrument's `price_precision`                     |
| `trigger_price`   | Decimal string in USDC. **`take_profit` and `stop_loss` only**                                                |
| `trigger_by`      | `mark` or `quote`: the price that triggers the order. Required for every type except `market`                 |
| `max_slippage`    | Fraction of the mark price, e.g. `"0.01"` for 1%. Required; may be `null` for no cap, except on `market`      |
| `reduce_only`     | Optional, default `false`. Not accepted on `take_profit` and `stop_loss`, which are always reduce-only        |
| `client_order_id` | Optional. Your ID: up to 36 letters, digits, `_`, `:` or `-`, **never reused on the account**. Used to cancel |
| `take_profit`     | Optional, `market` and `limit` only. An object of `trigger_price`, `trigger_by` and `max_slippage`            |
| `stop_loss`       | Optional, `market` and `limit` only. Same shape as `take_profit`                                              |

### Rate Limits

Each request contributes some "weight" to a user's usage limit. Currently, every user has 60 weight to spend per minute. The minute is a sliding window: weight you spend comes back 60 seconds after you spent it. Most endpoints cost between 1 and 5 weight.

Every response reports your budget in three headers:

* `X-RateLimit-Limit`: your total weight per window.
* `X-RateLimit-Remaining`: the weight you have left.
* `X-RateLimit-Reset`: when your full budget is back, in Unix seconds.

If you go over the limit, the request is refused with `429` and the error code `rate_limited`. The response's `retry_after_ms` field says how long to wait before retrying.

### Errors

Errors are JSON with a stable `error_code`:

```json
{"error_code": "rate_limited", "error_message": "rate limit exceeded", "retry_after_ms": 1500, "request_id": "..."}
```

When `retry_after_ms` is present, wait that long before retrying. Sign the request again when you retry, so it carries a fresh timestamp.
