---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk-predictions/interfaces/MarketsApi.md
---
[Reference](../../../index.md) / [@getenginex/sdk-predictions](../index.md) / 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`](PredictionEvent.md)>

Gets an event by id or ticker.

#### Parameters

##### input

[`EventRef`](../type-aliases/EventRef.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`PredictionEvent`](PredictionEvent.md)>

#### 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](#listcategories).

***

### getMarket()

> **getMarket**(`input`, `options?`): `Promise`<[`Market`](Market.md)>

Gets a market by id or ticker.

#### Parameters

##### input

[`MarketRef`](../type-aliases/MarketRef.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Market`](Market.md)>

#### 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](#listcategories).

***

### getOrderbook()

> **getOrderbook**(`input`, `options?`): `Promise`<[`Orderbook`](Orderbook.md)>

Orderbook of a market.

#### Parameters

##### input

`depth`: levels per side (gateway default: 10; maximum: 50).

###### depth?

`number`

###### marketId

`string`

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Orderbook`](Orderbook.md)>

#### Example

```ts
const { bids, asks, spread } = await predictions.markets.getOrderbook({ marketId: 'mkt-1', depth: 5 })
```

#### Throws

As in [MarketsApi.getMarket](#getmarket).

***

### getPriceHistory()

> **getPriceHistory**(`input`, `options?`): `Promise`<[`PricePoint`](PricePoint.md)\[]>

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`](../type-aliases/PriceInterval.md)

###### limit?

`number`

###### marketId

`string`

###### side

[`OutcomeSide`](../type-aliases/OutcomeSide.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`PricePoint`](PricePoint.md)\[]>

#### 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](#getmarket).

***

### listCategories()

> **listCategories**(`params?`, `options?`): `Promise`<[`PredictionCategory`](PredictionCategory.md)\[]>

Lists the event categories.

#### Parameters

##### params?

[`NoParams`](../../sdk/type-aliases/NoParams.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`PredictionCategory`](PredictionCategory.md)\[]>

#### 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`](PredictionEvent.md)\[]>

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`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`PredictionEvent`](PredictionEvent.md)\[]>

#### Example

```ts
const events = await predictions.markets.listEvents({ categoryId: 'cat-1' })
```

#### Throws

As in [MarketsApi.listCategories](#listcategories).

***

### listMarkets()

> **listMarkets**(`input`, `options?`): `Promise`<[`Market`](Market.md)\[]>

Lists the markets of an event (all of them, no pagination).

#### Parameters

##### input

###### eventId

`string`

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Market`](Market.md)\[]>

#### 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](#listcategories).
