This version (v0.7) has not been published to npm yet.
Skip to content

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 ​

EventRef

options? ​

CallOptions

Returns ​

Promise<PredictionEvent>

Example ​

ts
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 ​

MarketRef

options? ​

CallOptions

Returns ​

Promise<Market>

Example ​

ts
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? ​

CallOptions

Returns ​

Promise<Orderbook>

Example ​

ts
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? ​

PriceInterval

limit? ​

number

marketId ​

string

side ​

OutcomeSide

options? ​

CallOptions

Returns ​

Promise<PricePoint[]>

Example ​

ts
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? ​

NoParams

options? ​

CallOptions

Returns ​

Promise<PredictionCategory[]>

Example ​

ts
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? ​

CallOptions

Returns ​

Promise<PredictionEvent[]>

Example ​

ts
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? ​

CallOptions

Returns ​

Promise<Market[]>

Example ​

ts
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.