# Token

Token price and orderbook operations

## Get latest price

> Get the latest trade price and details for a specific token

```json
{"openapi":"3.0.3","info":{"title":"OPINION Prediction Market OpenAPI","version":"1.0.0"},"tags":[{"name":"Token","description":"Token price and orderbook operations"}],"servers":[{"url":"https://openapi.opinion.trade/openapi","description":"Production server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"apikey","description":"API key for authentication"}},"schemas":{"APIBaseResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response code (0 for success)"},"msg":{"type":"string","description":"Response message"},"result":{"type":"object","description":"Response data"}}},"LatestPriceResponse":{"type":"object","properties":{"tokenId":{"type":"string","description":"Token ID"},"price":{"type":"string","description":"Latest trade price"},"side":{"type":"string","description":"Last trade side (BUY/SELL)"},"size":{"type":"string","description":"Last trade size"},"timestamp":{"type":"integer","format":"int64","description":"Trade timestamp in milliseconds"}}}},"responses":{"BadRequestError":{"description":"Bad request - invalid parameters","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/APIBaseResponse"},{"type":"object","properties":{"code":{},"msg":{}}}]}}}}}},"paths":{"/token/latest-price":{"get":{"tags":["Token"],"summary":"Get latest price","description":"Get the latest trade price and details for a specific token","operationId":"getLatestPrice","parameters":[{"name":"token_id","in":"query","required":true,"description":"Token ID","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/APIBaseResponse"},{"type":"object","properties":{"result":{"$ref":"#/components/schemas/LatestPriceResponse"}}}]}}}},"400":{"$ref":"#/components/responses/BadRequestError"}}}}}}
```

## Get orderbook

> Get the orderbook (market depth) for a specific token

```json
{"openapi":"3.0.3","info":{"title":"OPINION Prediction Market OpenAPI","version":"1.0.0"},"tags":[{"name":"Token","description":"Token price and orderbook operations"}],"servers":[{"url":"https://openapi.opinion.trade/openapi","description":"Production server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"apikey","description":"API key for authentication"}},"schemas":{"APIBaseResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response code (0 for success)"},"msg":{"type":"string","description":"Response message"},"result":{"type":"object","description":"Response data"}}},"OrderbookResponse":{"type":"object","properties":{"market":{"type":"string","description":"Condition ID"},"tokenId":{"type":"string","description":"Token ID"},"timestamp":{"type":"integer","format":"int64","description":"Timestamp in milliseconds"},"bids":{"type":"array","items":{"$ref":"#/components/schemas/OrderbookLevel"},"description":"Buy orders, sorted by price descending"},"asks":{"type":"array","items":{"$ref":"#/components/schemas/OrderbookLevel"},"description":"Sell orders, sorted by price ascending"}}},"OrderbookLevel":{"type":"object","properties":{"price":{"type":"string","description":"Price level"},"size":{"type":"string","description":"Total size at this price level"}}}},"responses":{"BadRequestError":{"description":"Bad request - invalid parameters","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/APIBaseResponse"},{"type":"object","properties":{"code":{},"msg":{}}}]}}}}}},"paths":{"/token/orderbook":{"get":{"tags":["Token"],"summary":"Get orderbook","description":"Get the orderbook (market depth) for a specific token","operationId":"getOrderbook","parameters":[{"name":"token_id","in":"query","required":true,"description":"Token ID","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/APIBaseResponse"},{"type":"object","properties":{"result":{"$ref":"#/components/schemas/OrderbookResponse"}}}]}}}},"400":{"$ref":"#/components/responses/BadRequestError"}}}}}}
```

## Get price history

> Get historical price data for a specific token (Polymarket-compatible format)

```json
{"openapi":"3.0.3","info":{"title":"OPINION Prediction Market OpenAPI","version":"1.0.0"},"tags":[{"name":"Token","description":"Token price and orderbook operations"}],"servers":[{"url":"https://openapi.opinion.trade/openapi","description":"Production server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"apikey","description":"API key for authentication"}},"schemas":{"APIBaseResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response code (0 for success)"},"msg":{"type":"string","description":"Response message"},"result":{"type":"object","description":"Response data"}}},"PriceHistoryResponse":{"type":"object","properties":{"history":{"type":"array","items":{"$ref":"#/components/schemas/PricePoint"},"description":"Historical price data points"}}},"PricePoint":{"type":"object","properties":{"t":{"type":"integer","format":"int64","description":"UTC timestamp in seconds"},"p":{"type":"string","description":"Price"}}}},"responses":{"BadRequestError":{"description":"Bad request - invalid parameters","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/APIBaseResponse"},{"type":"object","properties":{"code":{},"msg":{}}}]}}}}}},"paths":{"/token/price-history":{"get":{"tags":["Token"],"summary":"Get price history","description":"Get historical price data for a specific token (Polymarket-compatible format)","operationId":"getPriceHistory","parameters":[{"name":"token_id","in":"query","required":true,"description":"Token ID","schema":{"type":"string"}},{"name":"interval","in":"query","description":"Price data interval: 1m, 1h, 1d, 1w, max","schema":{"type":"string","default":"1d","enum":["1m","1h","1d","1w","max"]}},{"name":"start_at","in":"query","description":"Start timestamp in Unix seconds","schema":{"type":"integer","format":"int64"}},{"name":"end_at","in":"query","description":"End timestamp in Unix seconds","schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/APIBaseResponse"},{"type":"object","properties":{"result":{"$ref":"#/components/schemas/PriceHistoryResponse"}}}]}}}},"400":{"$ref":"#/components/responses/BadRequestError"}}}}}}
```
