# HTTP API

## Content

* [trades](#trades)
* [orders](#orders)
* [orderbook](#orderbook)
* [fills](#fills)
* [candles](#candles)
* [markets](#markets)
* [user-balances](#user-balances)

## `/trades`

Fetch market trades from recent to oldest.

### Request parameters

<table><thead><tr><th width="173">Parameter</th><th width="231">Required?</th><th>Description</th></tr></thead><tbody><tr><td>market</td><td>required</td><td>a market contract address</td></tr><tr><td>limit</td><td>optional</td><td>max number of trades , default is 100</td></tr></tbody></table>

### Response

An array of [trade](/for-developers/api/common-objects.md#trade) objects.

## `/orders`

Fetch user orders.

### Request parameters

<table><thead><tr><th width="173">Parameter</th><th width="231">Required?</th><th>Description</th></tr></thead><tbody><tr><td>market</td><td>required</td><td>a market contract address</td></tr><tr><td>user</td><td>required</td><td>a user address</td></tr><tr><td>limit</td><td>optional</td><td>max number of orders , default is 100</td></tr></tbody></table>

### Response

An array of [order](/for-developers/api/common-objects.md#order) objects.

## `/orderbook`

Fetch the current state of the market order book.

### Request parameters

<table><thead><tr><th width="173">Parameter</th><th width="231">Required?</th><th>Description</th></tr></thead><tbody><tr><td>market</td><td>required</td><td>a market contract address</td></tr><tr><td>aggregation</td><td>optional</td><td>one of market aggregation, if not set max, aggregation is used</td></tr><tr><td>limit</td><td>optional</td><td>max number of levels in asks and bids , default is 100</td></tr></tbody></table>

### Response

Object with fields:

<table><thead><tr><th width="173">Property</th><th width="231">Type</th><th>Description</th></tr></thead><tbody><tr><td>timestamp</td><td>number represents timestamp</td><td>the update time</td></tr><tr><td>levels</td><td>object with fields"asks" and "bids"</td><td>Each field is a sorted array of order book <a href="/pages/XzTq7I4ynKs738OPF8w2#orderbook-level">level</a> objects; asks are sorted in ascending order by price, and bids are sorted in descending order.</td></tr></tbody></table>

## `/fills`

Get executed parts of user orders.

### Request parameters

<table><thead><tr><th width="173">Parameter</th><th width="231">Required?</th><th>Description</th></tr></thead><tbody><tr><td>market</td><td>required</td><td>a market contract address</td></tr><tr><td>user</td><td>required</td><td>a user address</td></tr><tr><td>limit</td><td>optional</td><td>max number of objects in response, default is 100</td></tr></tbody></table>

### Response

An array of order [fill](broken://pages/2PBdZoCtMHo8UeAejfF4#order-fill) objects descending by a timestamp field.

## `/candles`

Get executed parts of user orders.

### Request parameters

<table><thead><tr><th width="173">Parameter</th><th width="231">Required?</th><th>Description</th></tr></thead><tbody><tr><td>market</td><td>required</td><td>a market contract address</td></tr><tr><td>resolution</td><td>required</td><td>one of <a href="/pages/XzTq7I4ynKs738OPF8w2#candle">candle</a> object resolution</td></tr><tr><td>fromTime</td><td>optional</td><td>a lower bound of candle time</td></tr><tr><td>toTime</td><td>optional</td><td>an upper limit of candle time</td></tr></tbody></table>

### Response

An array of [candle](/for-developers/api/common-objects.md#candle) objects ascending by a time field.

## `/markets`

### Request parameters

<table><thead><tr><th width="173">Parameter</th><th width="231">Required?</th><th>Description</th></tr></thead><tbody><tr><td>market</td><td>optional</td><td>a market contract address</td></tr></tbody></table>

### Response

An array of [market](/for-developers/api/common-objects.md#market) objects.

## `/user-balances`

### Request parameters

<table><thead><tr><th width="173">Parameter</th><th width="231">Required?</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td>required</td><td>a user address</td></tr></tbody></table>

### Response

An object with a key "balances" and a value that is an array of objects:

<table><thead><tr><th width="175">Property</th><th width="152">Type</th><th>Description</th></tr></thead><tbody><tr><td>token</td><td>string</td><td>a token symbol</td></tr><tr><td>tokenAddress</td><td>string</td><td>a token address</td></tr><tr><td>hold</td><td>number</td><td>amount of tokens locked in orders</td></tr><tr><td>total</td><td>number</td><td>amount of hold tokens plus a deposit in market contract</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xpressprotocol.com/for-developers/api/http-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
