Overview
The /api/price-reference/live-series endpoint provides real-time price snapshots and historical data for price-based prediction markets (e.g., “Will Bitcoin price go up?”). This endpoint integrates with external price oracles to provide accurate opening, closing, and current prices for market resolution.
Request
Query Parameters
The series slug identifier (e.g., btc-usdt-5m, eth-usd-1h, aapl-1d).This slug determines which price feed and interval to use. Available series are configured server-side.
Unix timestamp in milliseconds representing when the event/market closes.This is used to determine the closing price for market resolution.
Unix timestamp in milliseconds representing when the event/market opens.If not provided, defaults to eventEndMs - activeWindowMinutes * 60000.
Duration of the market window in minutes.If not provided, defaults to the interval duration (e.g., 5 minutes for a 5m series, 1440 minutes for a 1d series).
Response
The requested series slug.
The underlying instrument identifier (e.g., BTC-USDT, ETH-USD, AAPL).
The candle interval for this series. Values: 5m, 15m, 1h, 4h, 1d.
Price data source. Values: chainlink, massive.
Interval duration in milliseconds.
Duration of the market window in minutes.
Unix timestamp in milliseconds for the start of the market window.
Unix timestamp in milliseconds for the end of the market window.
Price at the start of the market window, or null if not available.This is the baseline price for “up” vs “down” markets.
Price at the end of the market window, or null if not yet available.Used to determine market resolution.
Most recent settled price from the oracle, or null if not available.
Unix timestamp in milliseconds for the end of the latest price window.
latest_source_timestamp_ms
Unix timestamp in milliseconds from the price source for the latest data point.
Whether the event has passed its end time based on the current server time.
Example Request
curl --request GET \
--url 'https://api.kuest.com/api/price-reference/live-series?seriesSlug=btc-usdt-5m&eventEndMs=1709568000000&eventStartMs=1709564400000' \
--header 'Accept: application/json'
```bash
```javascript JavaScript
const seriesSlug = 'btc-usdt-5m';
const eventEndMs = Date.now() + 3600000; // 1 hour from now
const eventStartMs = Date.now();
const url = new URL('https://api.kuest.com/api/price-reference/live-series');
url.searchParams.append('seriesSlug', seriesSlug);
url.searchParams.append('eventEndMs', eventEndMs);
url.searchParams.append('eventStartMs', eventStartMs);
const response = await fetch(url, {
headers: { 'Accept': 'application/json' }
});
const data = await response.json();
console.log(data);
```bash
```python Python
import requests
import time
url = 'https://api.kuest.com/api/price-reference/live-series'
params = {
'seriesSlug': 'btc-usdt-5m',
'eventEndMs': int((time.time() + 3600) * 1000), # 1 hour from now
'eventStartMs': int(time.time() * 1000)
}
response = requests.get(url, params=params)
data = response.json()
print(data)
```bash
## Example Response
```json
{
"series_slug": "btc-usdt-5m",
"instrument": "BTC-USDT",
"interval": "5m",
"source": "chainlink",
"interval_ms": 300000,
"active_window_minutes": 60,
"event_window_start_ms": 1709564400000,
"event_window_end_ms": 1709568000000,
"opening_price": 67850.25,
"closing_price": null,
"latest_price": 68120.50,
"latest_window_end_ms": 1709566800000,
"latest_source_timestamp_ms": 1709566795000,
"is_event_closed": false
}
```bash
## Error Responses
### 400 Bad Request
```json
{
"error": "seriesSlug is required"
}
```bash
Returned when the `seriesSlug` parameter is missing or empty.
```json
{
"error": "eventEndMs is required and must be a positive unix millisecond timestamp"
}
```bash
Returned when `eventEndMs` is missing, not a number, or not positive.
### 404 Not Found
```json
{
"error": "series_slug not configured in price-reference: btc-usdt-5m"
}
```bash
Returned when the requested series slug is not configured in the price reference system.
### 500 Internal Server Error
```json
{
"error": "Failed to load price reference snapshot"
}
```bash
Returned when the server encounters an error fetching price data from the oracle.
## Price Resolution Logic
### Opening Price
The endpoint determines the opening price using the following fallback strategy:
1. **Preferred**: Most recent settled price at or before `event_window_start_ms` using the preferred interval (5m for daily markets, otherwise the series interval)
2. **Fallback**: Most recent settled price using the series interval
3. **Live**: Opening reference price from the next live window if the start time falls within it
### Closing Price
The closing price is determined by:
1. Most recent settled price at or before `event_window_end_ms` using the series interval
2. Returns `null` if the event hasn't closed yet or if no historical data is available
### Latest Price
The latest price represents the most recent finalized price from the oracle, regardless of the event window.
## Use Cases
### Creating a Price-Based Market
```javascript
// Check if a series is available and get current prices
const response = await fetch(
`https://api.kuest.com/api/price-reference/live-series?` +
`seriesSlug=btc-usdt-5m&eventEndMs=${endTime}`
);
const data = await response.json();
if (data.opening_price) {
console.log(`Market starts at: $${data.opening_price}`);
console.log(`Current price: $${data.latest_price}`);
}
```bash
### Monitoring Market Resolution
```javascript
// Poll this endpoint to check if a market should be resolved
const checkResolution = async () => {
const response = await fetch(
`https://api.kuest.com/api/price-reference/live-series?` +
`seriesSlug=btc-usdt-5m&eventEndMs=${marketEndTime}`
);
const data = await response.json();
if (data.is_event_closed && data.closing_price !== null) {
const priceWentUp = data.closing_price > data.opening_price;
console.log(`Market resolved: Price went ${priceWentUp ? 'UP' : 'DOWN'}`);
console.log(`Opening: $${data.opening_price}, Closing: $${data.closing_price}`);
}
};
```bash
## Notes
- Price data is sourced from external oracles with settlement delays (typically 5-15 minutes).
- The `latest_price` may be behind real-time market prices due to oracle settlement times.
- For daily (`1d`) markets, the opening price uses 5-minute candles for better precision.
- Prices are returned as floating-point numbers in the quote currency (e.g., USD, USDT).
- The endpoint caches the series configuration map for 5 minutes to improve performance.
- Historical price windows are aligned to interval boundaries (e.g., 5-minute boundaries for 5m intervals).
- Opening and closing prices return `null` if no historical data is available at the requested timestamps.