---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk-predictions/interfaces/OrdersApi.md
---
[Reference](../../../index.md) / [@getenginex/sdk-predictions](../index.md) / OrdersApi

# OrdersApi

Predictions orders. Every method requires a session (`UNAUTHENTICATED` without one, before any
request). Price is an integer in cents (1 to 99) and quantity an integer in contracts: the gateway does not
validate, so the SDK rejects values outside that with `CONFIGURATION_ERROR`, without a request.

## Methods

### amend()

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

Changes the price and/or quantity of an order (the gateway cancels and replaces: the `id` and the position in the
queue may change, so use the returned order). **It is not idempotent**: it sends no key, and repeating
the call after a network error may amend twice. Without `newPrice` or `newQuantity`
it rejects before the request.

#### Parameters

##### input

###### newPrice?

`number`

###### newQuantity?

`number`

###### orderId

`string`

##### options?

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

#### Returns

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

#### Example

```ts
const amended = await predictions.orders.amend({ orderId: 'ord-1', newPrice: 55 })
```

#### Throws

`CONFIGURATION_ERROR` without a request if `newPrice` and `newQuantity` are missing, if
`newPrice` is not an integer from 1 to 99 or `newQuantity` is not an integer greater than zero, and the errors of
[OrdersApi.get](#get).

***

### cancel()

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

Cancels an open order and returns the updated order. It does not use `Idempotency-Key`; canceling again
an already canceled order is decided by the gateway.

#### Parameters

##### input

###### orderId

`string`

##### options?

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

#### Returns

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

#### Example

```ts
const canceled = await predictions.orders.cancel({ orderId: 'ord-1' })
```

#### Throws

As in [OrdersApi.get](#get).

***

### get()

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

Gets one of the user's orders.

#### Parameters

##### input

###### orderId

`string`

##### options?

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

#### Returns

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

#### Example

```ts
const order = await predictions.orders.get({ orderId: 'ord-1' })
```

#### Throws

`CONFIGURATION_ERROR` without a request if `orderId` is empty, has `/`, is `.`
or `..`; `UNAUTHENTICATED`; `ORDER_NOT_FOUND` (the gateway may answer with HTTP 500) and the
network/validation errors of [OrdersApi.list](#list).

***

### list()

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

Lists the user's orders. The gateway ignores filters and pagination: it always returns the first page
of 50.

#### Parameters

##### params?

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

##### options?

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

#### Returns

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

#### Example

```ts
const orders = await predictions.orders.list()
```

#### Throws

`UNAUTHENTICATED` without a session, `NETWORK_ERROR`, `TIMEOUT`, `ABORTED`,
`VALIDATION_ERROR` or `CONFIGURATION_ERROR` (including after `dispose()`).

***

### place()

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

Places an order. **Idempotent**: the same key goes in the `Idempotency-Key` header **and** in
`idempotency_key` in the body (the gateway accepts both), and is reused on the retry after renewing the
session (401). Without `options.idempotencyKey` (or when blank), the SDK generates one per call; a provided
key is trimmed (`trim`) and the same string goes in both places. To repeat an order after
a network error without duplicating it, generate the key **once** per player intent, store it and pass the
same one on every attempt. A new key is a new order. The gateway answers HTTP 200.

`limit` order (default): `price` required, an integer from 1 to 99. `market` order: `price` optional
(omitted it goes as `0`, like the player app; when given, an integer from 0 to 99).

#### Parameters

##### input

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

##### options?

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

#### Returns

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

#### Example

```ts
const key = crypto.randomUUID() // one per "Buy" click, reused across attempts
const order = await predictions.orders.place(
  { marketId: 'mkt-1', side: 'yes', direction: 'buy', price: 60, quantity: 10 },
  { idempotencyKey: key },
)
```

#### Throws

`CONFIGURATION_ERROR` without a request if the input is not an object, `marketId`
is empty, `side`, `direction`, `orderType` or `timeInForce` are not among the accepted values, `price`
or `quantity` are invalid (see above), `postOnly`/`reduceOnly` are not booleans (and after
`dispose()`); `UNAUTHENTICATED` without a session; `KEY_IN_USE` (HTTP 409: the same key is still being
processed, wait and repeat with the same key); `PAYLOAD_MISMATCH` (HTTP 422: the same key with
another order; use a new key for a new order); `INVALID_KEY` (HTTP 400); `NO_LIQUIDITY`,
`MARKET_NOT_OPEN`, `MARKET_NOT_FOUND` (the gateway may answer with HTTP 500),
`INSUFFICIENT_BALANCE`, `KYC_*`, `SELF_EXCLUDED`; `NETWORK_ERROR`, `TIMEOUT`, `ABORTED`,
`VALIDATION_ERROR`; and `CONFIGURATION_ERROR` without Web Crypto (pass your own `idempotencyKey`). Always decide by `code`: `isEnginexError(error, 'NO_LIQUIDITY')`.

***

### placeBatch()

> **placeBatch**(`input`, `options?`): `Promise`<[`OrderResult`](../type-aliases/OrderResult.md)\[]>

Places several orders in one call. **It is not atomic**: each order succeeds or fails on its own, and the
result comes by `index` (the position in the list sent), in order. The batch route does not go through the
gateway's idempotency middleware: there is no `Idempotency-Key` header and `options.idempotencyKey`
is ignored. Each order carries an `idempotency_key` in the body: the `idempotencyKey` you passed in the
order (trimmed; it cannot repeat within the batch) or a generated one, new on every call. **To repeat the batch
safely after a network error, store the keys and resend the same ones per order**; without keys
of your own, do not blindly repeat the batch: check `orders.list()` first. An empty list or an invalid order
rejects before the request (no order goes out). The response is validated in `strict` mode: it must carry
the indexes 0..n-1 once each and `order` on successes, otherwise `VALIDATION_ERROR`.

#### Parameters

##### input

###### orders

[`BatchOrderInput`](../type-aliases/BatchOrderInput.md)\[]

##### options?

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

#### Returns

`Promise`<[`OrderResult`](../type-aliases/OrderResult.md)\[]>

#### Example

```ts
const results = await predictions.orders.placeBatch({
  orders: [
    { marketId: 'mkt-1', side: 'yes', direction: 'buy', price: 60, quantity: 10, idempotencyKey: 'lote-1-a' },
    { marketId: 'mkt-2', side: 'no', direction: 'buy', price: 30, quantity: 5, idempotencyKey: 'lote-1-b' },
  ],
})
for (const r of results) console.log(r.index, r.success ? r.order.id : r.error.message)
```

#### Throws

`CONFIGURATION_ERROR` without a request (empty list, invalid order, `idempotencyKey`
that is not text or is repeated), `UNAUTHENTICATED`, `VALIDATION_ERROR` (incomplete response), `CONFIGURATION_ERROR` without Web
Crypto and the network errors. One order's failures arrive in `results`, not as an exception.
