Skip to main content
Back to App

Get Price History by Slug

GET/v1/markets/slug/:slug/prices-historyPublic

Retrieve historical price data for a specific outcome using the market slug. This endpoint is designed for use with WebSocket signals, which provide slug-based channel names (market:{slug}:price).

#Path Parameters

ParameterTypeRequiredDescription
slugstringYesMarket URL slug (e.g., will-btc-hit-100k)

#Query Parameters

ParameterTypeRequiredDefaultDescription
outcomeIdstringYesOutcome ID to get price history for
startTsnumberNo1 week agoStart unix timestamp (seconds)
endTsnumberNonowEnd unix timestamp (seconds)
fidelitynumberNo1Data fidelity in minutes. Higher values produce fewer data points.

#Response

{
  "history": [
    { "t": 1710000000, "p": 0.67 },
    { "t": 1710000300, "p": 0.68 },
    { "t": 1710000600, "p": 0.665 }
  ]
}

#Response Fields

FieldTypeDescription
historyarrayArray of price points
history[].tnumberUnix timestamp (seconds)
history[].pnumberClosing price for the interval (0-1)

#WebSocket Integration

This endpoint is designed to be called after receiving a WebSocket signal on the market:{slug}:price channel:

// 1. Subscribe to WebSocket channel
socket.emit('join', { channel: 'market:will-btc-hit-100k:price' });
 
// 2. When signal received, fetch updated data using the same slug
socket.on('market:will-btc-hit-100k:price', async (data) => {
  const response = await fetch('/v1/markets/slug/will-btc-hit-100k/prices-history?outcomeId=outcome-uuid-1');
  const priceHistory = await response.json();
});

#Errors

StatusDescription
400Missing outcomeId or outcome does not belong to market
404Market or outcome not found

#Examples

#Last 24 hours with 5-minute fidelity

curl "https://api.conviction.bet/v1/markets/slug/will-btc-hit-100k/prices-history?outcomeId=outcome-uuid-1&startTs=1709913600&endTs=1710000000&fidelity=5"

#Last week with default fidelity

curl "https://api.conviction.bet/v1/markets/slug/will-btc-hit-100k/prices-history?outcomeId=outcome-uuid-1"
Was this page helpful?