# Market Data API

## GET /v1/market/trades

> Get all asset trading pairs

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/trades":{"get":{"tags":["market-api-controller"],"summary":"Get all asset trading pairs","operationId":"trades","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ApiResponseTradingBean"}}}}}}}},"components":{"schemas":{"ApiResponseTradingBean":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the request was successful"},"data":{"$ref":"#/components/schemas/TradingBean"},"error":{"type":"string","description":"Error code if request failed"},"errorField":{"type":"string","description":"Field in error if request failed"},"errorMessage":{"type":"string","description":"Detailed error message if request failed"}}},"TradingBean":{"type":"object","properties":{"currencies":{"type":"array","items":{"$ref":"#/components/schemas/Currency"}},"spotsSymbols":{"type":"array","items":{"$ref":"#/components/schemas/SpotsSymbol"}},"contractsSymbols":{"type":"array","items":{"$ref":"#/components/schemas/ContractsSymbol"}}},"description":"Response data, null if request failed"},"Currency":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}}},"SpotsSymbol":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"startTime":{"type":"integer","format":"int64"},"endTime":{"type":"integer","format":"int64"},"baseName":{"type":"string","description":"Base currency name, e.g., BTC"},"baseMinimumIncrement":{"type":"number","description":"Minimum unit of base currency quantity change, e.g., 0.001, 0.02"},"baseScale":{"type":"integer","description":"Decimal places for base currency quantity","format":"int32"},"baseMaximumQuantity":{"type":"number","description":"Maximum trading quantity of base currency, e.g., 200"},"quoteName":{"type":"string","description":"Quote currency name, e.g., USD"},"quoteMinimumIncrement":{"type":"number","description":"Minimum unit of quote currency price change, e.g., 0.01, 0.5"},"quoteScale":{"type":"integer","description":"Precision of quote currency","format":"int32"}}},"ContractsSymbol":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"startTime":{"type":"integer","format":"int64"},"endTime":{"type":"integer","format":"int64"},"baseName":{"type":"string","description":"Base currency name, e.g., BTC"},"baseMinimumIncrement":{"type":"number","description":"Minimum unit of base currency quantity change, e.g., 0.001, 0.02"},"baseScale":{"type":"integer","description":"Decimal places for base currency quantity","format":"int32"},"baseMaximumQuantity":{"type":"number","description":"Maximum trading quantity of base currency, e.g., 200"},"quoteName":{"type":"string","description":"Quote currency name, e.g., USD"},"quoteMinimumIncrement":{"type":"number","description":"Minimum unit of quote currency price change, e.g., 0.01, 0.5"},"quoteScale":{"type":"integer","description":"Precision of quote currency","format":"int32"},"type":{"type":"string","enum":["FUTURES","PERPETUAL"]},"riskLimit":{"$ref":"#/components/schemas/ContractsRiskLimit"},"settlementFeeRate":{"type":"number"}}},"ContractsRiskLimit":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"initialMarginRate":{"type":"number"},"maintenanceMarginRate":{"type":"number"},"marginRateStep":{"type":"number"},"maxLeverage":{"type":"integer","format":"int32"},"riskLimitBase":{"type":"number"},"riskLimitStep":{"type":"number"},"maxRiskLimitSteps":{"type":"integer","format":"int32"},"maxQuantity":{"type":"number"},"createdAt":{"type":"integer","format":"int64"}}}}}}
```

## GET /v1/market/timestamp

> Get server timestamp

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/timestamp":{"get":{"tags":["market-api-controller"],"summary":"Get server timestamp","operationId":"timestamp","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ApiResponseLong"}}}}}}}},"components":{"schemas":{"ApiResponseLong":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the request was successful"},"data":{"type":"integer","description":"Response data, null if request failed","format":"int64"},"error":{"type":"string","description":"Error code if request failed"},"errorField":{"type":"string","description":"Field in error if request failed"},"errorMessage":{"type":"string","description":"Detailed error message if request failed"}}}}}}
```

## GET /v1/market/ticks/{symbol}

> Get latest trade data for trading pair

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/ticks/{symbol}":{"get":{"tags":["market-api-controller"],"summary":"Get latest trade data for trading pair","operationId":"ticks","parameters":[{"name":"symbol","in":"path","required":true,"schema":{"type":"string"}},{"name":"maxResults","in":"query","required":false,"schema":{"type":"integer","format":"int32","default":100}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"string"}}}}}}}}}
```

## GET /v1/market/prices

> Get market prices of coins (24h)

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/prices":{"get":{"tags":["market-api-controller"],"summary":"Get market prices of coins (24h)","operationId":"prices","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ApiResponseMapStringBigDecimalArray"}}}}}}}},"components":{"schemas":{"ApiResponseMapStringBigDecimalArray":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the request was successful"},"data":{"type":"object","additionalProperties":{"type":"array","description":"Response data, null if request failed","items":{"type":"number","description":"Response data, null if request failed"}},"description":"Response data, null if request failed"},"error":{"type":"string","description":"Error code if request failed"},"errorField":{"type":"string","description":"Field in error if request failed"},"errorMessage":{"type":"string","description":"Detailed error message if request failed"}}}}}}
```

## GET /v1/market/bars/{symbol}/{type}

> Get K-line data for trading pair

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/bars/{symbol}/{type}":{"get":{"tags":["market-api-controller"],"summary":"Get K-line data for trading pair","operationId":"getBars","parameters":[{"name":"symbol","in":"path","required":true,"schema":{"type":"string"}},{"name":"type","in":"path","required":true,"schema":{"type":"string"}},{"name":"start","in":"query","required":false,"schema":{"type":"integer","format":"int64","default":0}},{"name":"end","in":"query","required":false,"schema":{"type":"integer","format":"int64","default":0}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"string"}}}}}}}}}
```

## GET /v1/market/orderBook/{symbol}

> Get order book for trading pair

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/orderBook/{symbol}":{"get":{"tags":["market-api-controller"],"summary":"Get order book for trading pair","operationId":"depthOfOrderBook","parameters":[{"name":"symbol","in":"path","required":true,"schema":{"type":"string"}},{"name":"depth","in":"query","required":false,"schema":{"type":"integer","format":"int32","default":25}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"string"}}}}}}}}}
```

## GET /v1/market/indexes

> Get latest prices for all indexes

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/indexes":{"get":{"tags":["market-api-controller"],"summary":"Get latest prices for all indexes","operationId":"indexValues","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"string"}}}}}}}}}
```

## GET /v1/market/indexes/{name}

> Get historical prices for an index

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/indexes/{name}":{"get":{"tags":["market-api-controller"],"summary":"Get historical prices for an index","operationId":"indexHistory","parameters":[{"name":"name","in":"path","required":true,"schema":{"type":"string"}},{"name":"start","in":"query","required":false,"schema":{"type":"integer","format":"int64","default":0}},{"name":"end","in":"query","required":false,"schema":{"type":"integer","format":"int64","default":0}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","format":"int32","default":1000}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ApiResponseListNumberArray"}}}}}}}},"components":{"schemas":{"ApiResponseListNumberArray":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the request was successful"},"data":{"type":"array","description":"Response data, null if request failed","items":{"type":"array","description":"Response data, null if request failed","items":{"type":"number","description":"Response data, null if request failed"}}},"error":{"type":"string","description":"Error code if request failed"},"errorField":{"type":"string","description":"Field in error if request failed"},"errorMessage":{"type":"string","description":"Detailed error message if request failed"}}}}}}
```

## GET /v1/market/indexes/indexValue

> Get the value of an index

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/indexes/indexValue":{"get":{"tags":["market-api-controller"],"summary":"Get the value of an index","operationId":"queryIndexValue","parameters":[{"name":"name","in":"query","required":false,"schema":{"type":"string","default":".BTC_FUNDING_8H"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ApiResponseBigDecimal"}}}}}}}},"components":{"schemas":{"ApiResponseBigDecimal":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the request was successful"},"data":{"type":"number","description":"Response data, null if request failed"},"error":{"type":"string","description":"Error code if request failed"},"errorField":{"type":"string","description":"Field in error if request failed"},"errorMessage":{"type":"string","description":"Detailed error message if request failed"}}}}}}
```

## GET /v1/market/indexPrices

> Get latest index prices for perpetual trading

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/indexPrices":{"get":{"tags":["market-api-controller"],"summary":"Get latest index prices for perpetual trading","operationId":"indexPrices","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ApiResponseMapStringBigDecimal"}}}}}}}},"components":{"schemas":{"ApiResponseMapStringBigDecimal":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the request was successful"},"data":{"type":"object","additionalProperties":{"type":"number","description":"Response data, null if request failed"},"description":"Response data, null if request failed"},"error":{"type":"string","description":"Error code if request failed"},"errorField":{"type":"string","description":"Field in error if request failed"},"errorMessage":{"type":"string","description":"Detailed error message if request failed"}}}}}}
```

## GET /v1/market/errorCodes

> Get all error codes

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://dex-api.benpay.com","description":"Default Server URL"}],"paths":{"/v1/market/errorCodes":{"get":{"tags":["market-api-controller"],"summary":"Get all error codes","operationId":"errors","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponseMapApiErrorString"}}}}}}}},"components":{"schemas":{"ApiResponseMapApiErrorString":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the request was successful"},"data":{"type":"object","additionalProperties":{"type":"string","description":"Response data, null if request failed"},"description":"Response data, null if request failed"},"error":{"type":"string","description":"Error code if request failed"},"errorField":{"type":"string","description":"Field in error if request failed"},"errorMessage":{"type":"string","description":"Detailed error message if request failed"}}}}}}
```
