Reference / @getenginex/sdk-predictions / MarketsApi
MarketsApi
Predictions catalog: categories, events, markets, orderbook and price history. All routes are public (they send no token). Prices in whole cents (1 to 99); quantities in contracts. Gateway errors arrive as EnginexError: always decide by code (e.g. MARKET_NOT_FOUND comes with HTTP 500).
Methods
getEvent()
getEvent(
input,options?):Promise<PredictionEvent>
Gets an event by id or ticker.
Parameters
input
options?
Returns
Promise<PredictionEvent>
Example
const event = await predictions.markets.getEvent({ ticker: 'ELEICAO-26OUT' })Throws
CONFIGURATION_ERROR without a request if the id/ticker is empty, has /, is . or .., or if both come (or neither); EVENT_NOT_FOUND (the gateway may answer with HTTP 500) and the errors of MarketsApi.listCategories.
getMarket()
getMarket(
input,options?):Promise<Market>
Gets a market by id or ticker.
Parameters
input
options?
Returns
Promise<Market>
Example
const market = await predictions.markets.getMarket({ marketId: 'mkt-1' })Throws
CONFIGURATION_ERROR without a request if the id/ticker is empty, has /, is . or .., or if both come (or neither); MARKET_NOT_FOUND (with HTTP 500) and the errors of MarketsApi.listCategories.
getOrderbook()
getOrderbook(
input,options?):Promise<Orderbook>
Orderbook of a market.
Parameters
input
depth: levels per side (gateway default: 10; maximum: 50).
depth?
number
marketId
string
options?
Returns
Promise<Orderbook>
Example
const { bids, asks, spread } = await predictions.markets.getOrderbook({ marketId: 'mkt-1', depth: 5 })Throws
As in MarketsApi.getMarket.
getPriceHistory()
getPriceHistory(
input,options?):Promise<PricePoint[]>
Price history (candles) of one side of the market, in cents. side is required.
Parameters
input
interval: default 1h (the gateway uses 1h for values it does not know); limit: points to return (gateway default: 100).
interval?
limit?
number
marketId
string
side
options?
Returns
Promise<PricePoint[]>
Example
const points = await predictions.markets.getPriceHistory({ marketId: 'mkt-1', side: 'yes', interval: '1d' })Throws
CONFIGURATION_ERROR without a request if side is not yes/no, if interval is not one of 1h, 6h, 1d, 1w, 1m, or if the id is invalid; and the errors of MarketsApi.getMarket.
listCategories()
listCategories(
params?,options?):Promise<PredictionCategory[]>
Lists the event categories.
Parameters
params?
options?
Returns
Promise<PredictionCategory[]>
Example
const categories = await predictions.markets.listCategories()Throws
NETWORK_ERROR, TIMEOUT, ABORTED, VALIDATION_ERROR or CONFIGURATION_ERROR (including after dispose()). Identify with isEnginexError(error, code).
listEvents()
listEvents(
params?,options?):Promise<PredictionEvent[]>
Lists events. The gateway always returns page 1 with 50 events and ignores any filter other than categoryId: there is no pagination or filtering by status or search (filter in the app).
Parameters
params?
categoryId restricts to one category.
categoryId?
string
options?
Returns
Promise<PredictionEvent[]>
Example
const events = await predictions.markets.listEvents({ categoryId: 'cat-1' })Throws
As in MarketsApi.listCategories.
listMarkets()
listMarkets(
input,options?):Promise<Market[]>
Lists the markets of an event (all of them, no pagination).
Parameters
input
eventId
string
options?
Returns
Promise<Market[]>
Example
const markets = await predictions.markets.listMarkets({ eventId: 'evt-1' })Throws
CONFIGURATION_ERROR without a request if eventId is empty, has /, is . or ..; and the errors of MarketsApi.listCategories.