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

# createPredictionsQueries()

> **createPredictionsQueries**(`predictions`): [`PredictionsQueries`](../interfaces/PredictionsQueries.md)

Creates the query factories for prediction markets: one per read method, with the same name and the
same input as the method (`q.markets.getMarket({ marketId })`). Each call returns
`{ queryKey, queryFn }`, compatible with TanStack Query v5's `useQuery`/`prefetchQuery`/`fetchQuery`.
It makes no request.

* Reads without a session (`markets.*`, `comments.list`): key
  `['enginex', 'public', namespace, method, input?]`.
* Player reads (`comments.listMine`, `orders.*`, `portfolio.*`): key
  `['enginex', 'user', userId, namespace, method, input?]`, with the session's `userId` when the factory
  is called; without a session, `'anonymous'` and the `queryFn` rejects with `UNAUTHENTICATED` without a request (the
  same if the session switches user before the `fetch`).
* `queryFn` forwards the context's `signal`: canceling the query aborts the `fetch`.
* None carries `staleTime`.

## Parameters

### predictions

[`PredictionsClient`](../../interfaces/PredictionsClient.md)

The object returned by `createPredictions(enginex)` (the object itself, not a copy).

## Returns

[`PredictionsQueries`](../interfaces/PredictionsQueries.md)

## Example

```ts
import { useQuery } from '@tanstack/react-query'
import { createPredictionsQueries } from '@getenginex/sdk-predictions/query'

const q = createPredictionsQueries(predictions)
const market = useQuery(q.markets.getMarket({ marketId: 'mkt-1' }))
```

## Throws

`CONFIGURATION_ERROR` if `predictions` did not come from `createPredictions` (e.g.
a `{ ...predictions }` copy). Identify with `isEnginexError(error, 'CONFIGURATION_ERROR')`.
