# Market Data Endpoints

### V2 Aggregated Endpoints (Recommended)

With the introduction of AMM V2, we now provide aggregated endpoints that combine both spot engine and AMM liquidity. These V2 endpoints are recommended for new integrations as they provide more comprehensive market data.

#### V1 vs V2 Interface Differences

| Feature            | V1 Interface            | V2 Interface                     |
| ------------------ | ----------------------- | -------------------------------- |
| **Data Source**    | Spot engine only        | Spot engine + AMM aggregated     |
| **Liquidity**      | Order book only         | Order book + AMM liquidity       |
| **Trades**         | Spot engine trades only | All trades (spot + AMM)          |
| **Klines**         | Spot engine volume only | Combined volume from all sources |
| **Depth**          | Order book depth only   | Merged depth with AMM liquidity  |
| **Performance**    | Standard                | Optimized with AMM integration   |
| **Recommendation** | Legacy support          | **Use V2 for new integrations**  |

**Key Advantages of V2 Interfaces**:

* **Enhanced Liquidity**: Includes AMM pool liquidity mapped to order book
* **Complete Market View**: Shows all trading activity (spot + AMM)
* **Better Price Discovery**: AMM provides additional price levels
* **Unified Data**: Single endpoint for comprehensive market data
* **Future-Proof**: Designed for the new AMM V2 architecture

**Migration Guide**:

* Replace `/klines` with `/klines/v2`
* Replace `/depth` with `/depth/v2`
* Replace `/latest-trades` with `/latest-trades/v2`
* Response format remains the same, but data includes AMM sources

## Get depth

> Get order book by pool id

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/depth":{"get":{"tags":["Market Data endpoints"],"summary":"Get depth","description":"Get order book by pool id","parameters":[{"name":"pool_id","in":"query","description":"pool_id","required":true,"schema":{"type":"string"}},{"name":"precision","in":"query","description":"0.00000001 ~ 10000","schema":{"type":"string"}},{"name":"limit","in":"query","description":"limit","schema":{"type":"integer"}}],"responses":{"200":{"description":"order depth","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"$ref":"#/components/schemas/entity.Depth"}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Depth":{"type":"object","properties":{"asks":{"type":"array","items":{"type":"array","items":{"type":"string"}}},"bids":{"type":"array","items":{"type":"array","items":{"type":"string"}}},"pool_id":{"type":"integer"},"precision":{"type":"string"},"timestamp":{"type":"integer"}}}}}}
```

## Get kline data

> Get kline data by pool id and interval

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/klines":{"get":{"tags":["Market Data endpoints"],"summary":"Get kline data","description":"Get kline data by pool id and interval","parameters":[{"name":"pool_id","in":"query","description":"pool id","required":true,"schema":{"type":"string"}},{"name":"interval","in":"query","description":"interval","required":true,"schema":{"type":"string","enum":["1m","5m","15m","30m","1h","4h","1d","1w","1M"]}},{"name":"start","in":"query","description":"start timestamp","schema":{"type":"integer"}},{"name":"end","in":"query","description":"end timestamp","schema":{"type":"integer"}}],"responses":{"200":{"description":"kline data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.Kline"}}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Kline":{"type":"object","properties":{"close":{"type":"number"},"count":{"type":"integer"},"high":{"type":"number"},"interval":{"type":"string"},"low":{"type":"number"},"open":{"type":"number"},"pool_id":{"type":"integer"},"timestamp":{"type":"string"},"turnover":{"type":"number"},"volume":{"type":"number"}}}}}}
```

## Get latest trades

> Get latest trades

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/latest-trades":{"get":{"tags":["Market Data endpoints"],"summary":"Get latest trades","description":"Get latest trades","parameters":[{"name":"pool_id","in":"query","description":"pool_id","schema":{"type":"string"}},{"name":"limit","in":"query","description":"limit count","schema":{"type":"integer"}}],"responses":{"200":{"description":"trade list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.Trade"}}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Trade":{"type":"object","properties":{"buyer":{"type":"string"},"pool_id":{"type":"integer"},"price":{"type":"string"},"quantity":{"type":"string"},"seller":{"type":"string"},"side":{"$ref":"#/components/schemas/entity.TradeSide"},"traded_at":{"type":"string"}}},"entity.TradeSide":{"type":"string","enum":["buy","sell"]}}}}
```


---

# 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.1dex.com/developer/restful-api-reference/market-data-endpoints.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.
