Prediction Markets API Reference

GraphQL endpoints and realtime channels that power the Shift prediction-markets trading UI — 45 operations across 10 modules. build b77d5b4

Get a Bearer Token

Exchange your platform API key + secret for a JWT via service_signin on the exchange platform, then pass it as Authorization: Bearer <token> on every request and to enable the Try It action below. The prediction-market gateway has no login of its own: it only verifies tokens issued by the platform auth service. Tokens are short-lived; sign in again to refresh.

Bearer access token

Introduction

The Prediction Markets API is a GraphQL API exposed by the prediction_market_gateway service. All requests are sent as POST to /graphql with a JSON body containing query and variables. Authenticated operations require an Authorization: Bearer <token> header; the gateway resolves the user and their permissions from the token (there is no separate user-id header).

Hosts

https://prediction-market-gateway-demo.cryptosrvc.com/graphql GraphQL (queries & mutations).

Subscriptions stream over graphql-ws at wss://prediction-market-gateway-demo.cryptosrvc.com/graphql. See the Real-Time transport guide.

Audiences

This document covers the trader functions that power the consumer trading UI: Markets & Events, Market Prices, Order Book, Price History, Crypto Prices, Trading, Trades, Positions & Portfolio, Balances & Transfers, User Stream, Real-Time (GraphQL Subscriptions). Operator / back-office functions are documented separately in the Prediction Markets Backoffice API.

Authentication & permissions

Market-data reads (markets, events, prices, order books, price history) are public and rate-limited per IP; a token is optional and, when sent, applies the caller's eligibility policy. Trader endpoints require a bearer token whose role grants the listed permission (e.g. create_prediction_order, prediction_positions). Where a trader query accepts user_id, only an admin may use it; a trader always sees their own data. Tokens are verified against the platform auth service (results are briefly cached).

Policies

What a user may trade and on what terms is set by three policies assigned per user: a trading policy (currency, order and volume limits, fees), a risk policy (execution mode, markup, hedge routing) and an eligibility policy (what is visible and tradeable). Users with no assignment fall back to the default policies; anonymous callers see what the default policies allow.

Idempotency

Money-moving mutations (create_order, deposit_to_prediction, withdraw_from_prediction, create_account_transaction) accept an x-idempotency-key header. A repeat with the same key within 5 minutes fails with GQL_ERR.GLOBAL.DUPLICATE_REQUEST instead of executing twice.

Request shape

POST /graphql HTTP/1.1
Host: prediction-market-gateway-demo.cryptosrvc.com
Authorization: Bearer <token>
Content-Type: application/json

{
  "query": "query { markets(pager: { limit: 20 }) { market_id external_id is_active } }",
  "variables": {}
}

Common input types

TypeFieldsNotes
PagerInputlimit: Int, offset: IntDefault 30 / 0
DateRangeInputtime_from: String, time_to: StringYYYY-MM-DD HH:mm:ss, UTC
SortInputdirection: SortDirectionASC / DESC (default DESC). *SortInput variants add property
SerialIdRangeInputserial_id_from: Int, serial_id_to: IntRow-id window

Errors

GraphQL errors are returned in the errors array of the response body with HTTP status 200. Auth, throttle and network errors may return non-200 statuses or surface as GraphQL errors with codes such as THROTTLE.SOFT_LOCK or AUTH_GUARD_TOKEN_EXPIRED.

Markets & Events

Public, filterable, searchable read endpoints that populate the markets dashboard, the event grid, the trending page, the category navigation and the expanded market/event detail views. Sending a bearer token is optional; when present, the caller's eligibility policy filters what is visible and the per-user favourite fields apply. · 10 operations · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

query markets Paginated, filterable list of prediction markets.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
pager PagerInput optional Limit / offset (default 30 / 0)
date_range DateRangeInput optional created_at window
opened_at_range DateRangeInput optional opened_at window
expires_at_range DateRangeInput optional expires_at window
market_id String optional Exact market id
event_id String optional Filter by parent event
market_venue_id String optional Filter by venue
external_id String optional Filter by venue-native id
is_active ToggleSwitch optional on / off
is_closed ToggleSwitch optional on / off
result MarketResult optional yes / no / void
search String optional Case-insensitive text match
sort MarketSortInput optional Sort by created_at / opened_at / expires_at / volume

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
market_id String! Stable market identifier
event_id String Parent event id (nullable)
market_venue_id String! Owning venue id
external_id String! Venue-native id (e.g. Kalshi ticker)
is_active ToggleSwitch! on / off
is_closed ToggleSwitch! on / off
result MarketResult yes / no / void once resolved (nullable)
opened_at String Open time (nullable)
expires_at String Scheduled expiry (nullable)
closed_at String Close time (nullable)
resolved_at String Resolution time (nullable)
created_at String! Row create time
updated_at String! Row update time
image String Image URL — lazy @ResolveField (nullable)
title String Market title — lazy @ResolveField (nullable)
question String Deprecated: Folded into `title` — always null. Use `title`.
outcome_yes String Venue label of the yes side. Null = plain "Yes". — lazy @ResolveField
outcome_no String Venue label of the no side. Null = plain "No". — lazy @ResolveField
floor_strike Float Lower strike ("beat price"), coin USD units. Crypto markets only. — lazy @ResolveField
cap_strike Float Upper strike ("beat price"), coin USD units. Crypto markets only. — lazy @ResolveField
strike_type String greater | greater_or_equal | less | between — how to draw the strike line(s). — lazy @ResolveField
settlement_price Float Underlying price at the market's close — the value its outcome was decided on, in coin USD units. Pair with floor_strike/cap_strike to show what it settled against. Crypto markets only; null until the market has closed. — lazy @ResolveField
volume String Traded volume (decimal string) — lazy @ResolveField (nullable)
opened_at_iso String opened_at as ISO-8601 — lazy @ResolveField
expires_at_iso String expires_at as ISO-8601 — lazy @ResolveField
closed_at_iso String closed_at as ISO-8601 — lazy @ResolveField
resolved_at_iso String resolved_at as ISO-8601 — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

query markets($pager: PagerInput, $date_range: DateRangeInput, $opened_at_range: DateRangeInput, $expires_at_range: DateRangeInput, $market_id: String, $event_id: String, $market_venue_id: String, $external_id: String, $is_active: ToggleSwitch, $is_closed: ToggleSwitch, $result: MarketResult, $search: String, $sort: MarketSortInput) {
  markets(pager: $pager, date_range: $date_range, opened_at_range: $opened_at_range, expires_at_range: $expires_at_range, market_id: $market_id, event_id: $event_id, market_venue_id: $market_venue_id, external_id: $external_id, is_active: $is_active, is_closed: $is_closed, result: $result, search: $search, sort: $sort) {
    market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query markets($pager: PagerInput, $date_range: DateRangeInput, $opened_at_range: DateRangeInput, $expires_at_range: DateRangeInput, $market_id: String, $event_id: String, $market_venue_id: String, $external_id: String, $is_active: ToggleSwitch, $is_closed: ToggleSwitch, $result: MarketResult, $search: String, $sort: MarketSortInput) { markets(pager: $pager, date_range: $date_range, opened_at_range: $opened_at_range, expires_at_range: $expires_at_range, market_id: $market_id, event_id: $event_id, market_venue_id: $market_venue_id, external_id: $external_id, is_active: $is_active, is_closed: $is_closed, result: $result, search: $search, sort: $sort) { market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query markets($pager: PagerInput, $date_range: DateRangeInput, $opened_at_range: DateRangeInput, $expires_at_range: DateRangeInput, $market_id: String, $event_id: String, $market_venue_id: String, $external_id: String, $is_active: ToggleSwitch, $is_closed: ToggleSwitch, $result: MarketResult, $search: String, $sort: MarketSortInput) { markets(pager: $pager, date_range: $date_range, opened_at_range: $opened_at_range, expires_at_range: $expires_at_range, market_id: $market_id, event_id: $event_id, market_venue_id: $market_venue_id, external_id: $external_id, is_active: $is_active, is_closed: $is_closed, result: $result, search: $search, sort: $sort) { market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query markets($pager: PagerInput, $date_range: DateRangeInput, $opened_at_range: DateRangeInput, $expires_at_range: DateRangeInput, $market_id: String, $event_id: String, $market_venue_id: String, $external_id: String, $is_active: ToggleSwitch, $is_closed: ToggleSwitch, $result: MarketResult, $search: String, $sort: MarketSortInput) { markets(pager: $pager, date_range: $date_range, opened_at_range: $opened_at_range, expires_at_range: $expires_at_range, market_id: $market_id, event_id: $event_id, market_venue_id: $market_venue_id, external_id: $external_id, is_active: $is_active, is_closed: $is_closed, result: $result, search: $search, sort: $sort) { market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query market A single market by id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
market_id String! required Market id

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
market_id String! Stable market identifier
event_id String Parent event id (nullable)
market_venue_id String! Owning venue id
external_id String! Venue-native id (e.g. Kalshi ticker)
is_active ToggleSwitch! on / off
is_closed ToggleSwitch! on / off
result MarketResult yes / no / void once resolved (nullable)
opened_at String Open time (nullable)
expires_at String Scheduled expiry (nullable)
closed_at String Close time (nullable)
resolved_at String Resolution time (nullable)
created_at String! Row create time
updated_at String! Row update time
image String Image URL — lazy @ResolveField (nullable)
title String Market title — lazy @ResolveField (nullable)
question String Deprecated: Folded into `title` — always null. Use `title`.
outcome_yes String Venue label of the yes side. Null = plain "Yes". — lazy @ResolveField
outcome_no String Venue label of the no side. Null = plain "No". — lazy @ResolveField
floor_strike Float Lower strike ("beat price"), coin USD units. Crypto markets only. — lazy @ResolveField
cap_strike Float Upper strike ("beat price"), coin USD units. Crypto markets only. — lazy @ResolveField
strike_type String greater | greater_or_equal | less | between — how to draw the strike line(s). — lazy @ResolveField
settlement_price Float Underlying price at the market's close — the value its outcome was decided on, in coin USD units. Pair with floor_strike/cap_strike to show what it settled against. Crypto markets only; null until the market has closed. — lazy @ResolveField
volume String Traded volume (decimal string) — lazy @ResolveField (nullable)
opened_at_iso String opened_at as ISO-8601 — lazy @ResolveField
expires_at_iso String expires_at as ISO-8601 — lazy @ResolveField
closed_at_iso String closed_at as ISO-8601 — lazy @ResolveField
resolved_at_iso String resolved_at as ISO-8601 — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

query market($market_id: String!) {
  market(market_id: $market_id) {
    market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query market($market_id: String!) { market(market_id: $market_id) { market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query market($market_id: String!) { market(market_id: $market_id) { market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query market($market_id: String!) { market(market_id: $market_id) { market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query events Paginated, filterable list of events (tradeable groups of markets).
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
pager PagerInput optional Limit / offset (default 30 / 0)
date_range DateRangeInput optional created_at window
opened_at_range DateRangeInput optional opened_at window
expires_at_range DateRangeInput optional expires_at window
event_id String optional Exact event id
event_ids [String!] optional Restrict the result to these event ids.
market_venue_id String optional Filter by venue
external_id String optional Filter by venue-native id
search String optional Case-insensitive text match
primary_category String optional Filter by primary category
sub_category String optional Filter by sub-category
tags [String!] optional Raw-tag filter (combined per tag_match)
tag_match TagMatch optional any (default) / all
is_active ToggleSwitch optional on / off
is_closed ToggleSwitch optional on / off
is_favourite ToggleSwitch optional Per-user favourites (requires a token)
is_hidden ToggleSwitch optional BO only: `on` lists admin-hidden events. Otherwise they're excluded.
sort EventSortInput optional Sort by created_at / opened_at / expires_at / volume

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
event_id String! Stable event identifier
market_venue_id String! Owning venue id
external_id String Venue-native id (nullable)
title String! Event question / title
primary_category String! Derived primary category
sub_category String! Derived sub-category
is_active ToggleSwitch! on / off
is_closed ToggleSwitch! on / off
opened_at String Open time (nullable)
expires_at String Scheduled expiry (nullable)
closed_at String Close time (nullable)
resolved_at String Resolution time (nullable)
created_at String! Row create time
updated_at String! Row update time
tags [String!]! Raw venue tags — lazy @ResolveField
raw_tags [String!]! Venue tags exactly as received, un-normalized — the corpus categories are derived from. Empty when the venue sent none. — lazy @ResolveField
image String Image URL — lazy @ResolveField (nullable)
description String Event description — lazy @ResolveField (nullable)
price_source CryptoPriceSource Underlying index for crypto events — lazy (nullable)
price_symbol String Underlying symbol (e.g. BTCUSDT) — lazy (nullable)
volume String Traded volume (decimal string) — lazy @ResolveField (nullable)
markets_count Int! Number of markets in the event — lazy @ResolveField
top_markets [EventTopMarket!]! Top-2 markets for the card — lazy @ResolveField
is_favourite ToggleSwitch! Per-caller favourite flag — lazy @ResolveField
hidden HiddenEvent — lazy @ResolveField
opened_at_iso String opened_at as ISO-8601 — lazy @ResolveField
expires_at_iso String expires_at as ISO-8601 — lazy @ResolveField
closed_at_iso String closed_at as ISO-8601 — lazy @ResolveField
resolved_at_iso String resolved_at as ISO-8601 — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

Type · EventTopMarket

FieldTypeDescription
market_id String! Market id
title String Market title (nullable)
image String Market image URL (nullable)
outcome_yes String Venue label of the yes side. Null ⇒ plain "Yes".
outcome_no String Venue label of the no side. Null ⇒ plain "No".
probability Float Yes price on a 0-1 scale. Null once the market is not tradeable.
multiplier_yes Float Payout multiplier for YES (nullable)
multiplier_no Float Payout multiplier for NO (nullable)
result MarketResult Resolved outcome — set for closed markets, null while active.

Type · HiddenEvent

FieldTypeDescription
event_id String! Event id
hidden_by String Admin who hid the event
reason String Why it was hidden (nullable)
created_at String Create time

GraphQL Operation

query events($pager: PagerInput, $date_range: DateRangeInput, $opened_at_range: DateRangeInput, $expires_at_range: DateRangeInput, $event_id: String, $event_ids: [String!], $market_venue_id: String, $external_id: String, $search: String, $primary_category: String, $sub_category: String, $tags: [String!], $tag_match: TagMatch, $is_active: ToggleSwitch, $is_closed: ToggleSwitch, $is_favourite: ToggleSwitch, $is_hidden: ToggleSwitch, $sort: EventSortInput) {
  events(pager: $pager, date_range: $date_range, opened_at_range: $opened_at_range, expires_at_range: $expires_at_range, event_id: $event_id, event_ids: $event_ids, market_venue_id: $market_venue_id, external_id: $external_id, search: $search, primary_category: $primary_category, sub_category: $sub_category, tags: $tags, tag_match: $tag_match, is_active: $is_active, is_closed: $is_closed, is_favourite: $is_favourite, is_hidden: $is_hidden, sort: $sort) {
    event_id market_venue_id external_id title primary_category sub_category is_active is_closed opened_at expires_at closed_at resolved_at created_at updated_at tags raw_tags image description price_source price_symbol volume markets_count top_markets { market_id title image outcome_yes outcome_no probability multiplier_yes multiplier_no result } is_favourite hidden { event_id hidden_by reason created_at }
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query events($pager: PagerInput, $date_range: DateRangeInput, $opened_at_range: DateRangeInput, $expires_at_range: DateRangeInput, $event_id: String, $event_ids: [String!], $market_venue_id: String, $external_id: String, $search: String, $primary_category: String, $sub_category: String, $tags: [String!], $tag_match: TagMatch, $is_active: ToggleSwitch, $is_closed: ToggleSwitch, $is_favourite: ToggleSwitch, $is_hidden: ToggleSwitch, $sort: EventSortInput) { events(pager: $pager, date_range: $date_range, opened_at_range: $opened_at_range, expires_at_range: $expires_at_range, event_id: $event_id, event_ids: $event_ids, market_venue_id: $market_venue_id, external_id: $external_id, search: $search, primary_category: $primary_category, sub_category: $sub_category, tags: $tags, tag_match: $tag_match, is_active: $is_active, is_closed: $is_closed, is_favourite: $is_favourite, is_hidden: $is_hidden, sort: $sort) { event_id market_venue_id external_id title primary_category sub_category is_active is_closed opened_at expires_at closed_at resolved_at created_at updated_at tags raw_tags image description price_source price_symbol volume markets_count top_markets { market_id title image outcome_yes outcome_no probability multiplier_yes multiplier_no result } is_favourite hidden { event_id hidden_by reason created_at } } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query events($pager: PagerInput, $date_range: DateRangeInput, $opened_at_range: DateRangeInput, $expires_at_range: DateRangeInput, $event_id: String, $event_ids: [String!], $market_venue_id: String, $external_id: String, $search: String, $primary_category: String, $sub_category: String, $tags: [String!], $tag_match: TagMatch, $is_active: ToggleSwitch, $is_closed: ToggleSwitch, $is_favourite: ToggleSwitch, $is_hidden: ToggleSwitch, $sort: EventSortInput) { events(pager: $pager, date_range: $date_range, opened_at_range: $opened_at_range, expires_at_range: $expires_at_range, event_id: $event_id, event_ids: $event_ids, market_venue_id: $market_venue_id, external_id: $external_id, search: $search, primary_category: $primary_category, sub_category: $sub_category, tags: $tags, tag_match: $tag_match, is_active: $is_active, is_closed: $is_closed, is_favourite: $is_favourite, is_hidden: $is_hidden, sort: $sort) { event_id market_venue_id external_id title primary_category sub_category is_active is_closed opened_at expires_at closed_at resolved_at created_at updated_at tags raw_tags image description price_source price_symbol volume markets_count top_markets { market_id title image outcome_yes outcome_no probability multiplier_yes multiplier_no result } is_favourite hidden { event_id hidden_by reason created_at } } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query events($pager: PagerInput, $date_range: DateRangeInput, $opened_at_range: DateRangeInput, $expires_at_range: DateRangeInput, $event_id: String, $event_ids: [String!], $market_venue_id: String, $external_id: String, $search: String, $primary_category: String, $sub_category: String, $tags: [String!], $tag_match: TagMatch, $is_active: ToggleSwitch, $is_closed: ToggleSwitch, $is_favourite: ToggleSwitch, $is_hidden: ToggleSwitch, $sort: EventSortInput) { events(pager: $pager, date_range: $date_range, opened_at_range: $opened_at_range, expires_at_range: $expires_at_range, event_id: $event_id, event_ids: $event_ids, market_venue_id: $market_venue_id, external_id: $external_id, search: $search, primary_category: $primary_category, sub_category: $sub_category, tags: $tags, tag_match: $tag_match, is_active: $is_active, is_closed: $is_closed, is_favourite: $is_favourite, is_hidden: $is_hidden, sort: $sort) { event_id market_venue_id external_id title primary_category sub_category is_active is_closed opened_at expires_at closed_at resolved_at created_at updated_at tags raw_tags image description price_source price_symbol volume markets_count top_markets { market_id title image outcome_yes outcome_no probability multiplier_yes multiplier_no result } is_favourite hidden { event_id hidden_by reason created_at } } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query event A single event by id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
event_id String! required Event id

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
event_id String! Stable event identifier
market_venue_id String! Owning venue id
external_id String Venue-native id (nullable)
title String! Event question / title
primary_category String! Derived primary category
sub_category String! Derived sub-category
is_active ToggleSwitch! on / off
is_closed ToggleSwitch! on / off
opened_at String Open time (nullable)
expires_at String Scheduled expiry (nullable)
closed_at String Close time (nullable)
resolved_at String Resolution time (nullable)
created_at String! Row create time
updated_at String! Row update time
tags [String!]! Raw venue tags — lazy @ResolveField
raw_tags [String!]! Venue tags exactly as received, un-normalized — the corpus categories are derived from. Empty when the venue sent none. — lazy @ResolveField
image String Image URL — lazy @ResolveField (nullable)
description String Event description — lazy @ResolveField (nullable)
price_source CryptoPriceSource Underlying index for crypto events — lazy (nullable)
price_symbol String Underlying symbol (e.g. BTCUSDT) — lazy (nullable)
volume String Traded volume (decimal string) — lazy @ResolveField (nullable)
markets_count Int! Number of markets in the event — lazy @ResolveField
top_markets [EventTopMarket!]! Top-2 markets for the card — lazy @ResolveField
is_favourite ToggleSwitch! Per-caller favourite flag — lazy @ResolveField
hidden HiddenEvent — lazy @ResolveField
opened_at_iso String opened_at as ISO-8601 — lazy @ResolveField
expires_at_iso String expires_at as ISO-8601 — lazy @ResolveField
closed_at_iso String closed_at as ISO-8601 — lazy @ResolveField
resolved_at_iso String resolved_at as ISO-8601 — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

Type · EventTopMarket

FieldTypeDescription
market_id String! Market id
title String Market title (nullable)
image String Market image URL (nullable)
outcome_yes String Venue label of the yes side. Null ⇒ plain "Yes".
outcome_no String Venue label of the no side. Null ⇒ plain "No".
probability Float Yes price on a 0-1 scale. Null once the market is not tradeable.
multiplier_yes Float Payout multiplier for YES (nullable)
multiplier_no Float Payout multiplier for NO (nullable)
result MarketResult Resolved outcome — set for closed markets, null while active.

Type · HiddenEvent

FieldTypeDescription
event_id String! Event id
hidden_by String Admin who hid the event
reason String Why it was hidden (nullable)
created_at String Create time

GraphQL Operation

query event($event_id: String!) {
  event(event_id: $event_id) {
    event_id market_venue_id external_id title primary_category sub_category is_active is_closed opened_at expires_at closed_at resolved_at created_at updated_at tags raw_tags image description price_source price_symbol volume markets_count top_markets { market_id title image outcome_yes outcome_no probability multiplier_yes multiplier_no result } is_favourite hidden { event_id hidden_by reason created_at }
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query event($event_id: String!) { event(event_id: $event_id) { event_id market_venue_id external_id title primary_category sub_category is_active is_closed opened_at expires_at closed_at resolved_at created_at updated_at tags raw_tags image description price_source price_symbol volume markets_count top_markets { market_id title image outcome_yes outcome_no probability multiplier_yes multiplier_no result } is_favourite hidden { event_id hidden_by reason created_at } } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query event($event_id: String!) { event(event_id: $event_id) { event_id market_venue_id external_id title primary_category sub_category is_active is_closed opened_at expires_at closed_at resolved_at created_at updated_at tags raw_tags image description price_source price_symbol volume markets_count top_markets { market_id title image outcome_yes outcome_no probability multiplier_yes multiplier_no result } is_favourite hidden { event_id hidden_by reason created_at } } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query event($event_id: String!) { event(event_id: $event_id) { event_id market_venue_id external_id title primary_category sub_category is_active is_closed opened_at expires_at closed_at resolved_at created_at updated_at tags raw_tags image description price_source price_symbol volume markets_count top_markets { market_id title image outcome_yes outcome_no probability multiplier_yes multiplier_no result } is_favourite hidden { event_id hidden_by reason created_at } } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query category_facets Category / sub-category navigation with event counts.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
is_active ToggleSwitch optional on = live events, off = ended, omitted = all

Response

FieldTypeDescription
primary_category String! Category key
sort_order Int! Display order
active_count Int! Rollup of events in the category
sub_categories [SubCategoryFacet!]! Per-sub-category counts

Type · SubCategoryFacet

FieldTypeDescription
sub_category String! Sub-category code
sort_order Int! Display order
active_count Int! Events in the sub-category

GraphQL Operation

query category_facets($is_active: ToggleSwitch) {
  category_facets(is_active: $is_active) {
    primary_category sort_order active_count sub_categories { sub_category sort_order active_count }
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query category_facets($is_active: ToggleSwitch) { category_facets(is_active: $is_active) { primary_category sort_order active_count sub_categories { sub_category sort_order active_count } } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query category_facets($is_active: ToggleSwitch) { category_facets(is_active: $is_active) { primary_category sort_order active_count sub_categories { sub_category sort_order active_count } } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query category_facets($is_active: ToggleSwitch) { category_facets(is_active: $is_active) { primary_category sort_order active_count sub_categories { sub_category sort_order active_count } } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query category_volumes Category / sub-category traded volumes.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (30 req / 60 s).

Inputs

This operation takes no arguments.

Response

FieldTypeDescription
primary_category String! Category key
volume String! Rollup volume (decimal string)
sub_categories [SubCategoryVolume!]! Per-sub-category volumes

Type · SubCategoryVolume

FieldTypeDescription
sub_category String! Sub-category code
volume String! Traded volume (decimal string)

GraphQL Operation

query category_volumes {
  category_volumes {
    primary_category volume sub_categories { sub_category volume }
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query category_volumes { category_volumes { primary_category volume sub_categories { sub_category volume } } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query category_volumes { category_volumes { primary_category volume sub_categories { sub_category volume } } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query category_volumes { category_volumes { primary_category volume sub_categories { sub_category volume } } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query favourite_events_count Number of events the caller has marked as favourite.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Any authenticated user. Rate-limited (60 req / 60 s).

Inputs

NameTypeRequiredDescription
is_active ToggleSwitch optional on / off

Response

Returns Int!.

GraphQL Operation

query favourite_events_count($is_active: ToggleSwitch) {
  favourite_events_count(is_active: $is_active)
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query favourite_events_count($is_active: ToggleSwitch) { favourite_events_count(is_active: $is_active) }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query favourite_events_count($is_active: ToggleSwitch) { favourite_events_count(is_active: $is_active) }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query favourite_events_count($is_active: ToggleSwitch) { favourite_events_count(is_active: $is_active) }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
mutation set_event_favourite Add or remove an event from the caller's favourites.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Mutation
Access Requires a bearer token. Permission: set_prediction_event_favourite. Rate-limited (60 req / 60 s).

Inputs

NameTypeRequiredDescription
event_id String! required Event id
is_favourite ToggleSwitch! required on = favourite, off = un-favourite

Response

Returns Boolean! — true on success; failures surface in the GraphQL errors array.

GraphQL Operation

mutation set_event_favourite($event_id: String!, $is_favourite: ToggleSwitch!) {
  set_event_favourite(event_id: $event_id, is_favourite: $is_favourite)
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"mutation set_event_favourite($event_id: String!, $is_favourite: ToggleSwitch!) { set_event_favourite(event_id: $event_id, is_favourite: $is_favourite) }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """mutation set_event_favourite($event_id: String!, $is_favourite: ToggleSwitch!) { set_event_favourite(event_id: $event_id, is_favourite: $is_favourite) }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `mutation set_event_favourite($event_id: String!, $is_favourite: ToggleSwitch!) { set_event_favourite(event_id: $event_id, is_favourite: $is_favourite) }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
subscription markets_updates Streams the updated market row for the given market_ids (≤50) whenever its result, is_active/is_closed or lifecycle timestamps change.
Transport: WebSocket · graphql-ws  wss://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Subscription
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (30 ops / 60 s, 500 ms min gap).

Inputs

NameTypeRequiredDescription
market_ids [String!]! required Market ids

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
market_id String! Stable market identifier
event_id String Parent event id (nullable)
market_venue_id String! Owning venue id
external_id String! Venue-native id (e.g. Kalshi ticker)
is_active ToggleSwitch! on / off
is_closed ToggleSwitch! on / off
result MarketResult yes / no / void once resolved (nullable)
opened_at String Open time (nullable)
expires_at String Scheduled expiry (nullable)
closed_at String Close time (nullable)
resolved_at String Resolution time (nullable)
created_at String! Row create time
updated_at String! Row update time
image String Image URL — lazy @ResolveField (nullable)
title String Market title — lazy @ResolveField (nullable)
question String Deprecated: Folded into `title` — always null. Use `title`.
outcome_yes String Venue label of the yes side. Null = plain "Yes". — lazy @ResolveField
outcome_no String Venue label of the no side. Null = plain "No". — lazy @ResolveField
floor_strike Float Lower strike ("beat price"), coin USD units. Crypto markets only. — lazy @ResolveField
cap_strike Float Upper strike ("beat price"), coin USD units. Crypto markets only. — lazy @ResolveField
strike_type String greater | greater_or_equal | less | between — how to draw the strike line(s). — lazy @ResolveField
settlement_price Float Underlying price at the market's close — the value its outcome was decided on, in coin USD units. Pair with floor_strike/cap_strike to show what it settled against. Crypto markets only; null until the market has closed. — lazy @ResolveField
volume String Traded volume (decimal string) — lazy @ResolveField (nullable)
opened_at_iso String opened_at as ISO-8601 — lazy @ResolveField
expires_at_iso String expires_at as ISO-8601 — lazy @ResolveField
closed_at_iso String closed_at as ISO-8601 — lazy @ResolveField
resolved_at_iso String resolved_at as ISO-8601 — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

subscription markets_updates($market_ids: [String!]!) {
  markets_updates(market_ids: $market_ids) {
    market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume
  }
}

Subscribe (graphql-ws)

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://prediction-market-gateway-demo.cryptosrvc.com/graphql",
  // Authorization is optional for this public realtime channel:
  connectionParams: { Authorization: "Bearer YOUR_TOKEN" },
});

const unsubscribe = client.subscribe(
  { query: `subscription markets_updates($market_ids: [String!]!) { markets_updates(market_ids: $market_ids) { market_id event_id market_venue_id external_id is_active is_closed result opened_at expires_at closed_at resolved_at created_at updated_at image title outcome_yes outcome_no floor_strike cap_strike strike_type settlement_price volume } }` },
  {
    next: (msg) => console.log(msg.data),
    error: (err) => console.error(err),
    complete: () => console.log("complete"),
  },
);
Note This operation streams over the graphql-ws WebSocket — see Real-Time transport.

Try It

Subscriptions are delivered over WebSocket (wss://, graphql-ws protocol). Try It opens a WebSocket to this operation's endpoint and streams updates below; click Stop to end it.

Authenticate at the top of the page to try this

Market Prices

Latest best bid/ask per market, available as a one-shot query and as a live stream. Registering a market here also keeps its price warm server-side. · 2 operations · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

query markets_prices Registers markets for pricing and returns their latest value. Accepts either market_ids (≤10) or an event_id (all of that event’s markets).
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
market_ids [String!] optional 1–10 market ids
event_id String optional All markets of this event (alternative to market_ids)

Response

FieldTypeDescription
market_id String! Market id
yes OutcomePrice! Best bid/ask (+ multiplier) for the YES outcome
no OutcomePrice! Best bid/ask (+ multiplier) for the NO outcome
ts String! ISO timestamp the price was fetched
multiplier Float Gross payout per 1 staked on this side (1 / ask). — lazy @ResolveField

Type · OutcomePrice

FieldTypeDescription
bid Float Best price to sell
ask Float Best price to buy

GraphQL Operation

query markets_prices($market_ids: [String!], $event_id: String) {
  markets_prices(market_ids: $market_ids, event_id: $event_id) {
    market_id yes { bid ask } no { bid ask } ts multiplier
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query markets_prices($market_ids: [String!], $event_id: String) { markets_prices(market_ids: $market_ids, event_id: $event_id) { market_id yes { bid ask } no { bid ask } ts multiplier } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query markets_prices($market_ids: [String!], $event_id: String) { markets_prices(market_ids: $market_ids, event_id: $event_id) { market_id yes { bid ask } no { bid ask } ts multiplier } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query markets_prices($market_ids: [String!], $event_id: String) { markets_prices(market_ids: $market_ids, event_id: $event_id) { market_id yes { bid ask } no { bid ask } ts multiplier } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
subscription markets_prices Streams price updates for the given market_ids (≤10) or for all markets of an event_id.
Transport: WebSocket · graphql-ws  wss://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Subscription
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (30 ops / 60 s, 500 ms min gap).

Inputs

NameTypeRequiredDescription
market_ids [String!] optional 1–10 market ids
event_id String optional All markets of this event (alternative to market_ids)

Response

FieldTypeDescription
market_id String! Market id
yes OutcomePrice! Best bid/ask (+ multiplier) for the YES outcome
no OutcomePrice! Best bid/ask (+ multiplier) for the NO outcome
ts String! ISO timestamp the price was fetched
multiplier Float Gross payout per 1 staked on this side (1 / ask). — lazy @ResolveField

Type · OutcomePrice

FieldTypeDescription
bid Float Best price to sell
ask Float Best price to buy

GraphQL Operation

subscription markets_prices($market_ids: [String!], $event_id: String) {
  markets_prices(market_ids: $market_ids, event_id: $event_id) {
    market_id yes { bid ask } no { bid ask } ts multiplier
  }
}

Subscribe (graphql-ws)

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://prediction-market-gateway-demo.cryptosrvc.com/graphql",
  // Authorization is optional for this public realtime channel:
  connectionParams: { Authorization: "Bearer YOUR_TOKEN" },
});

const unsubscribe = client.subscribe(
  { query: `subscription markets_prices($market_ids: [String!], $event_id: String) { markets_prices(market_ids: $market_ids, event_id: $event_id) { market_id yes { bid ask } no { bid ask } ts multiplier } }` },
  {
    next: (msg) => console.log(msg.data),
    error: (err) => console.error(err),
    complete: () => console.log("complete"),
  },
);
Note This operation streams over the graphql-ws WebSocket — see Real-Time transport.

Try It

Subscriptions are delivered over WebSocket (wss://, graphql-ws protocol). Try It opens a WebSocket to this operation's endpoint and streams updates below; click Stop to end it.

Authenticate at the top of the page to try this

Order Book

Order-book depth for a single market outcome: a one-shot snapshot query and a live stream. · 2 operations · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

query orderbook Current order-book snapshot for a market outcome.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
market_id String! required Market id
outcome_side OutcomeSide! required yes / no

Response

FieldTypeDescription
market_id String! Market id
outcome_side OutcomeSide! yes / no
buy [OrderbookLevel!]! Bid levels (price, quantity)
sell [OrderbookLevel!]! Ask levels (price, quantity)
ts String! Epoch-ms timestamp
ts_iso String! ISO timestamp
best_bid Float Best bid (nullable)
best_ask Float Best ask (nullable)
total_volume Float Aggregate book volume (nullable)

Type · OrderbookLevel

FieldTypeDescription
price Float! Level price
quantity Float! Shares available at this price

GraphQL Operation

query orderbook($market_id: String!, $outcome_side: OutcomeSide!) {
  orderbook(market_id: $market_id, outcome_side: $outcome_side) {
    market_id outcome_side buy { price quantity } sell { price quantity } ts best_bid best_ask total_volume
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query orderbook($market_id: String!, $outcome_side: OutcomeSide!) { orderbook(market_id: $market_id, outcome_side: $outcome_side) { market_id outcome_side buy { price quantity } sell { price quantity } ts best_bid best_ask total_volume } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query orderbook($market_id: String!, $outcome_side: OutcomeSide!) { orderbook(market_id: $market_id, outcome_side: $outcome_side) { market_id outcome_side buy { price quantity } sell { price quantity } ts best_bid best_ask total_volume } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query orderbook($market_id: String!, $outcome_side: OutcomeSide!) { orderbook(market_id: $market_id, outcome_side: $outcome_side) { market_id outcome_side buy { price quantity } sell { price quantity } ts best_bid best_ask total_volume } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
subscription orderbook Stream order-book snapshots for a market outcome on every change.
Transport: WebSocket · graphql-ws  wss://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Subscription
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (30 ops / 60 s, 500 ms min gap).

Inputs

NameTypeRequiredDescription
market_id String! required Market id
outcome_side OutcomeSide! required yes / no

Response

FieldTypeDescription
market_id String! Market id
outcome_side OutcomeSide! yes / no
buy [OrderbookLevel!]! Bid levels (price, quantity)
sell [OrderbookLevel!]! Ask levels (price, quantity)
ts String! Epoch-ms timestamp
ts_iso String! ISO timestamp
best_bid Float Best bid (nullable)
best_ask Float Best ask (nullable)
total_volume Float Aggregate book volume (nullable)

Type · OrderbookLevel

FieldTypeDescription
price Float! Level price
quantity Float! Shares available at this price

GraphQL Operation

subscription orderbook($market_id: String!, $outcome_side: OutcomeSide!) {
  orderbook(market_id: $market_id, outcome_side: $outcome_side) {
    market_id outcome_side buy { price quantity } sell { price quantity } ts best_bid best_ask total_volume
  }
}

Subscribe (graphql-ws)

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://prediction-market-gateway-demo.cryptosrvc.com/graphql",
  // Authorization is optional for this public realtime channel:
  connectionParams: { Authorization: "Bearer YOUR_TOKEN" },
});

const unsubscribe = client.subscribe(
  { query: `subscription orderbook($market_id: String!, $outcome_side: OutcomeSide!) { orderbook(market_id: $market_id, outcome_side: $outcome_side) { market_id outcome_side buy { price quantity } sell { price quantity } ts best_bid best_ask total_volume } }` },
  {
    next: (msg) => console.log(msg.data),
    error: (err) => console.error(err),
    complete: () => console.log("complete"),
  },
);
Note This operation streams over the graphql-ws WebSocket — see Real-Time transport.

Try It

Subscriptions are delivered over WebSocket (wss://, graphql-ws protocol). Try It opens a WebSocket to this operation's endpoint and streams updates below; click Stop to end it.

Authenticate at the top of the page to try this

Price History

Probability / price curves for the market and event charts, plus a live tick stream to extend them. · 5 operations · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

query market_price_history Returns price points for the given market/side over the given range.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
market_id String! required Market id
side OutcomeSide optional yes (default) / no
range PriceHistoryRange! required hour / hour6 / day / week / month / all
max_points Int optional Cap on the points returned per market, thinned by dropping whole buckets. Omit for the full stored series.

Response

FieldTypeDescription
market_id String! Market id
points [PricePoint!]! Price points (ts, price, multiplier)
market_title String Market title (name). — lazy @ResolveField
multiplier Float Gross payout per 1 staked at this price (1 / price). — lazy @ResolveField

Type · PricePoint

FieldTypeDescription
ts Int! Unix timestamp (seconds)
price Float! YES / NO price at ts (0–1)

GraphQL Operation

query market_price_history($market_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) {
  market_price_history(market_id: $market_id, side: $side, range: $range, max_points: $max_points) {
    market_id points { ts price } market_title multiplier
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query market_price_history($market_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { market_price_history(market_id: $market_id, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query market_price_history($market_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { market_price_history(market_id: $market_id, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query market_price_history($market_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { market_price_history(market_id: $market_id, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query markets_price_history Returns price points for each of the given markets over the given range, in the order the market_ids were passed.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
market_ids [String!]! required Market ids
side OutcomeSide optional yes / no
range PriceHistoryRange! required hour / hour6 / day / week / month / all
max_points Int optional Cap on the points returned per market, thinned by dropping whole buckets. Omit for the full stored series.

Response

FieldTypeDescription
market_id String! Market id
points [PricePoint!]! Price points (ts, price, multiplier)
market_title String Market title (name). — lazy @ResolveField
multiplier Float Gross payout per 1 staked at this price (1 / price). — lazy @ResolveField

Type · PricePoint

FieldTypeDescription
ts Int! Unix timestamp (seconds)
price Float! YES / NO price at ts (0–1)

GraphQL Operation

query markets_price_history($market_ids: [String!]!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) {
  markets_price_history(market_ids: $market_ids, side: $side, range: $range, max_points: $max_points) {
    market_id points { ts price } market_title multiplier
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query markets_price_history($market_ids: [String!]!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { markets_price_history(market_ids: $market_ids, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query markets_price_history($market_ids: [String!]!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { markets_price_history(market_ids: $market_ids, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query markets_price_history($market_ids: [String!]!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { markets_price_history(market_ids: $market_ids, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query event_price_history Returns per-market price history for every market that belongs to the given event.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
event_id String! required Event id
side OutcomeSide optional yes (default) / no
range PriceHistoryRange! required hour / hour6 / day / week / month / all
max_points Int optional Cap on the points returned per market, thinned by dropping whole buckets. Omit for the full stored series.

Response

FieldTypeDescription
market_id String! Market id
points [PricePoint!]! Price points (ts, price, multiplier)
market_title String Market title (name). — lazy @ResolveField
multiplier Float Gross payout per 1 staked at this price (1 / price). — lazy @ResolveField

Type · PricePoint

FieldTypeDescription
ts Int! Unix timestamp (seconds)
price Float! YES / NO price at ts (0–1)

GraphQL Operation

query event_price_history($event_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) {
  event_price_history(event_id: $event_id, side: $side, range: $range, max_points: $max_points) {
    market_id points { ts price } market_title multiplier
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query event_price_history($event_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { event_price_history(event_id: $event_id, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query event_price_history($event_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { event_price_history(event_id: $event_id, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query event_price_history($event_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { event_price_history(event_id: $event_id, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query event_top_markets_price_history Price history for the most-likely (highest yes-probability) markets of an event, ordered by likelihood. Returns each market_id so the client can feed them into market_price_history_updates for live updates.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
event_id String! required Event id
side OutcomeSide optional yes (default) / no
range PriceHistoryRange! required hour / hour6 / day / week / month / all
max_points Int optional Cap on the points returned per market, thinned by dropping whole buckets. Omit for the full stored series.

Response

FieldTypeDescription
market_id String! Market id
points [PricePoint!]! Price points (ts, price, multiplier)
market_title String Market title (name). — lazy @ResolveField
multiplier Float Gross payout per 1 staked at this price (1 / price). — lazy @ResolveField

Type · PricePoint

FieldTypeDescription
ts Int! Unix timestamp (seconds)
price Float! YES / NO price at ts (0–1)

GraphQL Operation

query event_top_markets_price_history($event_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) {
  event_top_markets_price_history(event_id: $event_id, side: $side, range: $range, max_points: $max_points) {
    market_id points { ts price } market_title multiplier
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query event_top_markets_price_history($event_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { event_top_markets_price_history(event_id: $event_id, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query event_top_markets_price_history($event_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { event_top_markets_price_history(event_id: $event_id, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query event_top_markets_price_history($event_id: String!, $side: OutcomeSide, $range: PriceHistoryRange!, $max_points: Int) { event_top_markets_price_history(event_id: $event_id, side: $side, range: $range, max_points: $max_points) { market_id points { ts price } market_title multiplier } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
subscription market_price_history_updates Streams the latest live price point per market for the given market_ids/side. One emit per market per pricing tick; pair with the market_price_history query for the historical curve.
Transport: WebSocket · graphql-ws  wss://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Subscription
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (30 ops / 60 s, 500 ms min gap).

Inputs

NameTypeRequiredDescription
market_ids [String!]! required 1–50 market ids
side OutcomeSide optional yes (default) / no

Response

FieldTypeDescription
market_id String! Market id
side OutcomeSide! yes / no
ts Int! Epoch-seconds tick timestamp
price Float! Latest price

GraphQL Operation

subscription market_price_history_updates($market_ids: [String!]!, $side: OutcomeSide) {
  market_price_history_updates(market_ids: $market_ids, side: $side) {
    market_id side ts price
  }
}

Subscribe (graphql-ws)

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://prediction-market-gateway-demo.cryptosrvc.com/graphql",
  // Authorization is optional for this public realtime channel:
  connectionParams: { Authorization: "Bearer YOUR_TOKEN" },
});

const unsubscribe = client.subscribe(
  { query: `subscription market_price_history_updates($market_ids: [String!]!, $side: OutcomeSide) { market_price_history_updates(market_ids: $market_ids, side: $side) { market_id side ts price } }` },
  {
    next: (msg) => console.log(msg.data),
    error: (err) => console.error(err),
    complete: () => console.log("complete"),
  },
);
Note This operation streams over the graphql-ws WebSocket — see Real-Time transport.

Try It

Subscriptions are delivered over WebSocket (wss://, graphql-ws protocol). Try It opens a WebSocket to this operation's endpoint and streams updates below; click Stop to end it.

Authenticate at the top of the page to try this

Crypto Prices

Underlying spot candles for crypto price-tracking events (e.g. "BTC above X at 15:00") and the display precision per coin. · 3 operations · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

query crypto_price_history Historical underlying-price candles for a crypto price-tracking event over the given range. Empty for non-crypto events.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — no token required. Rate-limited (120 req / 60 s).

Inputs

NameTypeRequiredDescription
event_id String! required Event id
range CryptoPriceRange! required hour / hour6 / day / week / month / all

Response

FieldTypeDescription
ts Int! Candle open time (epoch seconds)
open Float! Open price
high Float! High price
low Float! Low price
close Float! Close price
volume Float Candle volume (nullable)
closed Boolean! Finalized (false = still forming)

GraphQL Operation

query crypto_price_history($event_id: String!, $range: CryptoPriceRange!) {
  crypto_price_history(event_id: $event_id, range: $range) {
    ts open high low close volume closed
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query crypto_price_history($event_id: String!, $range: CryptoPriceRange!) { crypto_price_history(event_id: $event_id, range: $range) { ts open high low close volume closed } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query crypto_price_history($event_id: String!, $range: CryptoPriceRange!) { crypto_price_history(event_id: $event_id, range: $range) { ts open high low close volume closed } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query crypto_price_history($event_id: String!, $range: CryptoPriceRange!) { crypto_price_history(event_id: $event_id, range: $range) { ts open high low close volume closed } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
subscription crypto_price_history_updates Streams live OHLC candles (forming + closed) for a crypto price-tracking event. Pair with the crypto_price_history query for backfill.
Transport: WebSocket · graphql-ws  wss://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Subscription
Access Public — no token required. Rate-limited (30 ops / 60 s, 500 ms min gap).

Inputs

NameTypeRequiredDescription
event_id String! required Event id
range CryptoPriceRange! required hour / hour6 / day / week / month / all

Response

FieldTypeDescription
ts Int! Candle open time (epoch seconds)
open Float! Open price
high Float! High price
low Float! Low price
close Float! Close price
volume Float Candle volume (nullable)
closed Boolean! Finalized (false = still forming)

GraphQL Operation

subscription crypto_price_history_updates($event_id: String!, $range: CryptoPriceRange!) {
  crypto_price_history_updates(event_id: $event_id, range: $range) {
    ts open high low close volume closed
  }
}

Subscribe (graphql-ws)

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://prediction-market-gateway-demo.cryptosrvc.com/graphql",
  // Authorization is optional for this public realtime channel:
  connectionParams: { Authorization: "Bearer YOUR_TOKEN" },
});

const unsubscribe = client.subscribe(
  { query: `subscription crypto_price_history_updates($event_id: String!, $range: CryptoPriceRange!) { crypto_price_history_updates(event_id: $event_id, range: $range) { ts open high low close volume closed } }` },
  {
    next: (msg) => console.log(msg.data),
    error: (err) => console.error(err),
    complete: () => console.log("complete"),
  },
);
Note This operation streams over the graphql-ws WebSocket — see Real-Time transport.

Try It

Subscriptions are delivered over WebSocket (wss://, graphql-ws protocol). Try It opens a WebSocket to this operation's endpoint and streams updates below; click Stop to end it.

Authenticate at the top of the page to try this
query crypto_price_precisions Display precision per underlying coin for crypto binary options (charts / beat price)
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — no token required.

Inputs

This operation takes no arguments.

Response

FieldTypeDescription
currency_id String! Coin (e.g. BTC)
precision Int! Decimal places to display

GraphQL Operation

query crypto_price_precisions {
  crypto_price_precisions {
    currency_id precision
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query crypto_price_precisions { crypto_price_precisions { currency_id precision } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query crypto_price_precisions { crypto_price_precisions { currency_id precision } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query crypto_price_precisions { crypto_price_precisions { currency_id precision } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this

Trading

Everything the trade ticket needs: limits, the MAX amount, a pre-trade estimate, order placement and the caller's open / closed orders. · 10 operations · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

query order_limitations Returns order limitations (sizing, tradeability, max buy amount, trading currency) for a market. max_order_amount is null for unauthenticated requests.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites). Rate-limited (60 req / 60 s).

Inputs

NameTypeRequiredDescription
market_id String! required Market id

Response

FieldTypeDescription
market_id String! Market id
tradeable Boolean! Whether the market currently accepts orders
min_size Float Minimum order size in shares, if defined (nullable)
max_order_amount Float Trading policy's maximum buy amount. null when the policy sets no maximum.
currency_id String The trading policy's currency: min_size, max_order_amount and order amounts are denominated in it. The default policy's currency for unauthenticated requests.

GraphQL Operation

query order_limitations($market_id: String!) {
  order_limitations(market_id: $market_id) {
    market_id tradeable min_size max_order_amount currency_id
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query order_limitations($market_id: String!) { order_limitations(market_id: $market_id) { market_id tradeable min_size max_order_amount currency_id } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query order_limitations($market_id: String!) { order_limitations(market_id: $market_id) { market_id tradeable min_size max_order_amount currency_id } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query order_limitations($market_id: String!) { order_limitations(market_id: $market_id) { market_id tradeable min_size max_order_amount currency_id } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query max_order_amount Largest buy amount whose amount + fee fits the free balance (MAX button)
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: estimate_prediction_order.

Inputs

This operation takes no arguments.

Response

FieldTypeDescription
amount Float! Largest buy amount whose amount + fee fits the free balance
currency_id String! Currency id

GraphQL Operation

query max_order_amount {
  max_order_amount {
    amount currency_id
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query max_order_amount { max_order_amount { amount currency_id } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query max_order_amount { max_order_amount { amount currency_id } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query max_order_amount { max_order_amount { amount currency_id } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query estimate_order Pre-trade estimate (price, shares, notional, fee, total) for a prospective order. Nothing is placed or locked.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: estimate_prediction_order.

Inputs

NameTypeRequiredDescription
market_id String! required Market id
outcome_side OutcomeSide! required yes / no
side Side! required buy / sell
shares Float optional Share quantity. Required for sell; for buy pass shares OR amount
amount Float optional Buy only: notional to spend (shares = amount / price)
fee_included ToggleSwitch optional Buy only. off: total = amount + fee. on: total = amount, fee carved out of it. (default off)

Response

FieldTypeDescription
market_id String! Market id
outcome_side OutcomeSide! yes / no
side Side! buy / sell
shares Float! Share quantity
price Float! Resolved price (ask for buy, bid for sell)
notional Float! shares × price
fee Float! Estimated taker fee
fee_currency_id String! Currency the fee is charged in
total Float! buy: notional + fee; sell: notional − fee

GraphQL Operation

query estimate_order($market_id: String!, $outcome_side: OutcomeSide!, $side: Side!, $shares: Float, $amount: Float, $fee_included: ToggleSwitch) {
  estimate_order(market_id: $market_id, outcome_side: $outcome_side, side: $side, shares: $shares, amount: $amount, fee_included: $fee_included) {
    market_id outcome_side side shares price notional fee fee_currency_id total
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query estimate_order($market_id: String!, $outcome_side: OutcomeSide!, $side: Side!, $shares: Float, $amount: Float, $fee_included: ToggleSwitch) { estimate_order(market_id: $market_id, outcome_side: $outcome_side, side: $side, shares: $shares, amount: $amount, fee_included: $fee_included) { market_id outcome_side side shares price notional fee fee_currency_id total } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query estimate_order($market_id: String!, $outcome_side: OutcomeSide!, $side: Side!, $shares: Float, $amount: Float, $fee_included: ToggleSwitch) { estimate_order(market_id: $market_id, outcome_side: $outcome_side, side: $side, shares: $shares, amount: $amount, fee_included: $fee_included) { market_id outcome_side side shares price notional fee fee_currency_id total } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query estimate_order($market_id: String!, $outcome_side: OutcomeSide!, $side: Side!, $shares: Float, $amount: Float, $fee_included: ToggleSwitch) { estimate_order(market_id: $market_id, outcome_side: $outcome_side, side: $side, shares: $shares, amount: $amount, fee_included: $fee_included) { market_id outcome_side side shares price notional fee fee_currency_id total } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
mutation create_order Send an `x-idempotency-key` header to make a retry safe: a second call with the same key within 5 minutes fails with GQL_ERR.GLOBAL.DUPLICATE_REQUEST instead of placing a second order.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Mutation
Access Requires a bearer token. Permission: create_prediction_order. Send an x-idempotency-key header to make a retry safe (a repeat within 5 min fails with DUPLICATE_REQUEST).

Inputs

NameTypeRequiredDescription
market_id String! required Market id
outcome_side OutcomeSide! required yes / no
side Side! required buy / sell
shares Float optional Share quantity. Required for sell; for buy pass shares OR amount
amount Float optional Buy only: notional to spend (shares = amount / price)
position_id String optional Sell only: the exact position to exit. Without it the sell takes the position held in the current policy currency, else the oldest.
fee_included ToggleSwitch optional Buy only. off: debit amount + fee. on: debit exactly amount — the fee is carved out of it and shares are bought with the rest. (default off)

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
order_id String! Stable order id
user_id String! Owning user id
currency_id String! Currency id
side Side! buy / sell
market_id String! Market id
event_id String Parent event id (denormalized, nullable)
outcome_side OutcomeSide! yes / no
status OrderStatus! new / pending / completed / cancelled / rejected / expired
executed_quantity Float! Shares filled
remaining_quantity Float! Shares still open
price Float Order price (nullable)
amount Float Buy orders: exact currency amount locked and spent; shares are derived from it at fill price. Null for sells.
shares Float! Requested shares
version Int! Optimistic-lock version
message String Free-text reason stamped when the order is cancelled or rejected.
created_at String! Create time
updated_at String! Update time
fee OrderFeeResult Fee transaction of the fill; null until the order fills or when no fee applied. — lazy @ResolveField
market_title String Title of the related market. — lazy @ResolveField
outcome_label String Venue label of the side ordered. Null = plain Yes/No. — lazy @ResolveField
event_title String Title of the related event. — lazy @ResolveField
event_image String Image URL of the related event. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

Type · OrderFeeResult

FieldTypeDescription
account_transaction_id String! Fee ledger item id
parent_transaction_id String! Groups this item with the fill it belongs to.
amount Float! Fee charged
currency_id String! Fee currency
created_at String! Create time

GraphQL Operation

mutation create_order($market_id: String!, $outcome_side: OutcomeSide!, $side: Side!, $shares: Float, $amount: Float, $position_id: String, $fee_included: ToggleSwitch) {
  create_order(market_id: $market_id, outcome_side: $outcome_side, side: $side, shares: $shares, amount: $amount, position_id: $position_id, fee_included: $fee_included) {
    order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"mutation create_order($market_id: String!, $outcome_side: OutcomeSide!, $side: Side!, $shares: Float, $amount: Float, $position_id: String, $fee_included: ToggleSwitch) { create_order(market_id: $market_id, outcome_side: $outcome_side, side: $side, shares: $shares, amount: $amount, position_id: $position_id, fee_included: $fee_included) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """mutation create_order($market_id: String!, $outcome_side: OutcomeSide!, $side: Side!, $shares: Float, $amount: Float, $position_id: String, $fee_included: ToggleSwitch) { create_order(market_id: $market_id, outcome_side: $outcome_side, side: $side, shares: $shares, amount: $amount, position_id: $position_id, fee_included: $fee_included) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `mutation create_order($market_id: String!, $outcome_side: OutcomeSide!, $side: Side!, $shares: Float, $amount: Float, $position_id: String, $fee_included: ToggleSwitch) { create_order(market_id: $market_id, outcome_side: $outcome_side, side: $side, shares: $shares, amount: $amount, position_id: $position_id, fee_included: $fee_included) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query open_orders The caller's orders that are still working (new / pending). Admins may pass user_id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_orders.

Inputs

NameTypeRequiredDescription
pager PagerInput optional Limit / offset
date_range DateRangeInput optional created_at window
user_id String optional Admin-only cross-user filter
market_id String optional Filter by market
event_id String optional Parent event id (denormalized, nullable)
side Side optional buy / sell
status OrderStatus optional Filter by status
search String optional Case-insensitive text match

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
order_id String! Stable order id
user_id String! Owning user id
currency_id String! Currency id
side Side! buy / sell
market_id String! Market id
event_id String Parent event id (denormalized, nullable)
outcome_side OutcomeSide! yes / no
status OrderStatus! new / pending / completed / cancelled / rejected / expired
executed_quantity Float! Shares filled
remaining_quantity Float! Shares still open
price Float Order price (nullable)
amount Float Buy orders: exact currency amount locked and spent; shares are derived from it at fill price. Null for sells.
shares Float! Requested shares
version Int! Optimistic-lock version
message String Free-text reason stamped when the order is cancelled or rejected.
created_at String! Create time
updated_at String! Update time
fee OrderFeeResult Fee transaction of the fill; null until the order fills or when no fee applied. — lazy @ResolveField
market_title String Title of the related market. — lazy @ResolveField
outcome_label String Venue label of the side ordered. Null = plain Yes/No. — lazy @ResolveField
event_title String Title of the related event. — lazy @ResolveField
event_image String Image URL of the related event. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

Type · OrderFeeResult

FieldTypeDescription
account_transaction_id String! Fee ledger item id
parent_transaction_id String! Groups this item with the fill it belongs to.
amount Float! Fee charged
currency_id String! Fee currency
created_at String! Create time

GraphQL Operation

query open_orders($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $side: Side, $status: OrderStatus, $search: String) {
  open_orders(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, side: $side, status: $status, search: $search) {
    order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query open_orders($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $side: Side, $status: OrderStatus, $search: String) { open_orders(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, side: $side, status: $status, search: $search) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query open_orders($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $side: Side, $status: OrderStatus, $search: String) { open_orders(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, side: $side, status: $status, search: $search) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query open_orders($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $side: Side, $status: OrderStatus, $search: String) { open_orders(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, side: $side, status: $status, search: $search) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query closed_orders The caller's finished orders (completed / cancelled / rejected / expired). Admins may pass user_id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_orders.

Inputs

NameTypeRequiredDescription
pager PagerInput optional Limit / offset
date_range DateRangeInput optional created_at window
user_id String optional Admin-only cross-user filter
market_id String optional Filter by market
event_id String optional Parent event id (denormalized, nullable)
side Side optional buy / sell
status OrderStatus optional Filter by status
search String optional Case-insensitive text match

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
order_id String! Stable order id
user_id String! Owning user id
currency_id String! Currency id
side Side! buy / sell
market_id String! Market id
event_id String Parent event id (denormalized, nullable)
outcome_side OutcomeSide! yes / no
status OrderStatus! new / pending / completed / cancelled / rejected / expired
executed_quantity Float! Shares filled
remaining_quantity Float! Shares still open
price Float Order price (nullable)
amount Float Buy orders: exact currency amount locked and spent; shares are derived from it at fill price. Null for sells.
shares Float! Requested shares
version Int! Optimistic-lock version
message String Free-text reason stamped when the order is cancelled or rejected.
created_at String! Create time
updated_at String! Update time
fee OrderFeeResult Fee transaction of the fill; null until the order fills or when no fee applied. — lazy @ResolveField
market_title String Title of the related market. — lazy @ResolveField
outcome_label String Venue label of the side ordered. Null = plain Yes/No. — lazy @ResolveField
event_title String Title of the related event. — lazy @ResolveField
event_image String Image URL of the related event. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

Type · OrderFeeResult

FieldTypeDescription
account_transaction_id String! Fee ledger item id
parent_transaction_id String! Groups this item with the fill it belongs to.
amount Float! Fee charged
currency_id String! Fee currency
created_at String! Create time

GraphQL Operation

query closed_orders($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $side: Side, $status: OrderStatus, $search: String) {
  closed_orders(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, side: $side, status: $status, search: $search) {
    order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query closed_orders($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $side: Side, $status: OrderStatus, $search: String) { closed_orders(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, side: $side, status: $status, search: $search) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query closed_orders($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $side: Side, $status: OrderStatus, $search: String) { closed_orders(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, side: $side, status: $status, search: $search) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query closed_orders($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $side: Side, $status: OrderStatus, $search: String) { closed_orders(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, side: $side, status: $status, search: $search) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query order A single order by id (the caller's own; any order for an admin).
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_orders.

Inputs

NameTypeRequiredDescription
order_id String! required Order id

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
order_id String! Stable order id
user_id String! Owning user id
currency_id String! Currency id
side Side! buy / sell
market_id String! Market id
event_id String Parent event id (denormalized, nullable)
outcome_side OutcomeSide! yes / no
status OrderStatus! new / pending / completed / cancelled / rejected / expired
executed_quantity Float! Shares filled
remaining_quantity Float! Shares still open
price Float Order price (nullable)
amount Float Buy orders: exact currency amount locked and spent; shares are derived from it at fill price. Null for sells.
shares Float! Requested shares
version Int! Optimistic-lock version
message String Free-text reason stamped when the order is cancelled or rejected.
created_at String! Create time
updated_at String! Update time
fee OrderFeeResult Fee transaction of the fill; null until the order fills or when no fee applied. — lazy @ResolveField
market_title String Title of the related market. — lazy @ResolveField
outcome_label String Venue label of the side ordered. Null = plain Yes/No. — lazy @ResolveField
event_title String Title of the related event. — lazy @ResolveField
event_image String Image URL of the related event. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

Type · OrderFeeResult

FieldTypeDescription
account_transaction_id String! Fee ledger item id
parent_transaction_id String! Groups this item with the fill it belongs to.
amount Float! Fee charged
currency_id String! Fee currency
created_at String! Create time

GraphQL Operation

query order($order_id: String!) {
  order(order_id: $order_id) {
    order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query order($order_id: String!) { order(order_id: $order_id) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query order($order_id: String!) { order(order_id: $order_id) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query order($order_id: String!) { order(order_id: $order_id) { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity price amount shares version message created_at updated_at fee { account_transaction_id parent_transaction_id amount currency_id created_at } market_title outcome_label event_title event_image } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query prediction_market_currency The caller's trading currency (their assigned trading policy, or the default policy when unauthenticated) and its display precision
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — works anonymously; when a bearer token is sent the caller's policies apply (eligibility filter, trading currency, favourites).

Inputs

This operation takes no arguments.

Response

FieldTypeDescription
currency_id String! Trading currency of the caller's trading policy
precision Int! Display precision of that currency

GraphQL Operation

query prediction_market_currency {
  prediction_market_currency {
    currency_id precision
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query prediction_market_currency { prediction_market_currency { currency_id precision } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query prediction_market_currency { prediction_market_currency { currency_id precision } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query prediction_market_currency { prediction_market_currency { currency_id precision } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query user_limitations Current user's limitations: eligibility to trade and the volume limits of their trading policy
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Any authenticated user.

Inputs

This operation takes no arguments.

Response

FieldTypeDescription
trading_enabled Boolean! Whether the current user's trading policy allows placing orders.
volume_limits UserVolumeLimitsResult! The user's daily/weekly/monthly volume limits, usage and remaining.

Type · UserVolumeLimitsResult

FieldTypeDescription
currency_id String! Currency the limits are denominated in
daily VolumeLimitUsage! Daily limit usage (nullable = not enforced)
weekly VolumeLimitUsage! Weekly limit usage (nullable = not enforced)
monthly VolumeLimitUsage! Monthly limit usage (nullable = not enforced)

GraphQL Operation

query user_limitations {
  user_limitations {
    trading_enabled volume_limits { currency_id daily { limit used remaining } weekly { limit used remaining } monthly { limit used remaining } }
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query user_limitations { user_limitations { trading_enabled volume_limits { currency_id daily { limit used remaining } weekly { limit used remaining } monthly { limit used remaining } } } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query user_limitations { user_limitations { trading_enabled volume_limits { currency_id daily { limit used remaining } weekly { limit used remaining } monthly { limit used remaining } } } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query user_limitations { user_limitations { trading_enabled volume_limits { currency_id daily { limit used remaining } weekly { limit used remaining } monthly { limit used remaining } } } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query single_side_per_market_enabled on = a buy is rejected while the user holds shares on the other side of the same market; off = holding yes + no together is allowed
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Public — no token required.

Inputs

This operation takes no arguments.

Response

Returns ToggleSwitch!.

GraphQL Operation

query single_side_per_market_enabled {
  single_side_per_market_enabled
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query single_side_per_market_enabled { single_side_per_market_enabled }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query single_side_per_market_enabled { single_side_per_market_enabled }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query single_side_per_market_enabled { single_side_per_market_enabled }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this

Trades

Individual fills. Each order produces one or more trades. · 2 operations · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

query trades Paginated list of the caller's fills. Admins may pass user_id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_trades.

Inputs

NameTypeRequiredDescription
pager PagerInput optional Limit / offset
date_range DateRangeInput optional created_at window
user_id String optional Admin-only cross-user filter
market_id String optional Filter by market
order_id String optional Filter by order

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
trade_id String! Stable trade (fill) id
user_id String! Owning user id
currency_id String! Settlement currency
shares Float! Shares filled
price Float! Fill price
amount Float! Money that moved for this fill, in currency_id.
order_id String! Parent order id
market_id String! Market id
event_id String Parent event id (denormalized, nullable)
side Side! buy / sell
outcome_side OutcomeSide! yes / no
created_at String! Create time
updated_at String! Update time
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

query trades($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $order_id: String) {
  trades(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, order_id: $order_id) {
    trade_id user_id currency_id shares price amount order_id market_id event_id side outcome_side created_at updated_at
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query trades($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $order_id: String) { trades(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, order_id: $order_id) { trade_id user_id currency_id shares price amount order_id market_id event_id side outcome_side created_at updated_at } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query trades($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $order_id: String) { trades(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, order_id: $order_id) { trade_id user_id currency_id shares price amount order_id market_id event_id side outcome_side created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query trades($pager: PagerInput, $date_range: DateRangeInput, $user_id: String, $market_id: String, $order_id: String) { trades(pager: $pager, date_range: $date_range, user_id: $user_id, market_id: $market_id, order_id: $order_id) { trade_id user_id currency_id shares price amount order_id market_id event_id side outcome_side created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query trade A single fill by id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_trades.

Inputs

NameTypeRequiredDescription
trade_id String! required Trade id

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
trade_id String! Stable trade (fill) id
user_id String! Owning user id
currency_id String! Settlement currency
shares Float! Shares filled
price Float! Fill price
amount Float! Money that moved for this fill, in currency_id.
order_id String! Parent order id
market_id String! Market id
event_id String Parent event id (denormalized, nullable)
side Side! buy / sell
outcome_side OutcomeSide! yes / no
created_at String! Create time
updated_at String! Update time
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

query trade($trade_id: String!) {
  trade(trade_id: $trade_id) {
    trade_id user_id currency_id shares price amount order_id market_id event_id side outcome_side created_at updated_at
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query trade($trade_id: String!) { trade(trade_id: $trade_id) { trade_id user_id currency_id shares price amount order_id market_id event_id side outcome_side created_at updated_at } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query trade($trade_id: String!) { trade(trade_id: $trade_id) { trade_id user_id currency_id shares price amount order_id market_id event_id side outcome_side created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query trade($trade_id: String!) { trade(trade_id: $trade_id) { trade_id user_id currency_id shares price amount order_id market_id event_id side outcome_side created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this

Positions & Portfolio

Holdings per market outcome with live mark-to-bid P&L, portfolio totals, and the realtime streams that keep the portfolio page current. · 6 operations · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

query open_user_positions The caller's open (pending / active) positions, with live P&L fields. Admins may pass user_id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_positions.

Inputs

NameTypeRequiredDescription
pager PagerInput optional Limit / offset (default 30 / 0)
date_range DateRangeInput optional created_at window
updated_at_range DateRangeInput optional updated_at window
user_id String optional Owning user id
market_id String optional Market id
event_id String optional Parent event id (nullable)
currency_id String optional Settlement currency
outcome_side OutcomeSide optional yes / no
search String optional Case-insensitive text match
status PositionStatus optional pending / active / completed / rejected
sort UserPositionSortInput optional Sort direction / property

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
position_id String! Stable position id
user_id String! Owning user id
currency_id String! Settlement currency
avg_price Float! Average entry price
invested Float Cost basis (shares × avg_price) (nullable)
settled_shares Float Shares paid out at settlement (nullable until settled)
realized_pnl Float! Realized profit / loss
status PositionStatus! pending / active / completed / rejected
market_id String! Market id
event_id String Parent event id (nullable) — lazy @ResolveField
market_venue_id String! Market venue id
outcome_side OutcomeSide! yes / no
created_at String! Create time
updated_at String! Update time
shares Float! Held shares while active; shares at settlement once completed — lazy @ResolveField
mark_price Float Current best bid for the side held — what a share would fetch if sold now. null when the market is unpriced. — lazy @ResolveField
unrealized_pnl Float Mark-to-bid P&L of held shares, in currency_id. 0 once closed; null while open but the market is unpriced. — lazy @ResolveField
total_pnl Float realized_pnl + unrealized_pnl. null while open but the market is unpriced. — lazy @ResolveField
unrealized_roi Float Unrealized P&L ÷ invested (fraction; 0.1 = 10%). null when no held shares or unpriced. — lazy @ResolveField
total_pnl_roi Float total_pnl ÷ the position cost basis (invested) — fraction; 0.1 = 10%. null when there is no cost basis (e.g. closed by selling to zero) or the market is unpriced. — lazy @ResolveField
market_title String Related market title — lazy @ResolveField (nullable)
outcome_label String Venue label of the side held. Null = plain Yes/No. — lazy @ResolveField
market_image String Image URL of the related market. — lazy @ResolveField
event_title String Related event title — lazy @ResolveField (nullable)
event_image String Image URL of the related event. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

query open_user_positions($pager: PagerInput, $date_range: DateRangeInput, $updated_at_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $currency_id: String, $outcome_side: OutcomeSide, $search: String, $status: PositionStatus, $sort: UserPositionSortInput) {
  open_user_positions(pager: $pager, date_range: $date_range, updated_at_range: $updated_at_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, currency_id: $currency_id, outcome_side: $outcome_side, search: $search, status: $status, sort: $sort) {
    position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query open_user_positions($pager: PagerInput, $date_range: DateRangeInput, $updated_at_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $currency_id: String, $outcome_side: OutcomeSide, $search: String, $status: PositionStatus, $sort: UserPositionSortInput) { open_user_positions(pager: $pager, date_range: $date_range, updated_at_range: $updated_at_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, currency_id: $currency_id, outcome_side: $outcome_side, search: $search, status: $status, sort: $sort) { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query open_user_positions($pager: PagerInput, $date_range: DateRangeInput, $updated_at_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $currency_id: String, $outcome_side: OutcomeSide, $search: String, $status: PositionStatus, $sort: UserPositionSortInput) { open_user_positions(pager: $pager, date_range: $date_range, updated_at_range: $updated_at_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, currency_id: $currency_id, outcome_side: $outcome_side, search: $search, status: $status, sort: $sort) { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query open_user_positions($pager: PagerInput, $date_range: DateRangeInput, $updated_at_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $currency_id: String, $outcome_side: OutcomeSide, $search: String, $status: PositionStatus, $sort: UserPositionSortInput) { open_user_positions(pager: $pager, date_range: $date_range, updated_at_range: $updated_at_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, currency_id: $currency_id, outcome_side: $outcome_side, search: $search, status: $status, sort: $sort) { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query closed_user_positions The caller's closed (settled / sold-out) positions. Admins may pass user_id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_positions.

Inputs

NameTypeRequiredDescription
pager PagerInput optional Limit / offset (default 30 / 0)
date_range DateRangeInput optional created_at window
updated_at_range DateRangeInput optional updated_at window
user_id String optional Owning user id
market_id String optional Market id
event_id String optional Parent event id (nullable)
currency_id String optional Settlement currency
outcome_side OutcomeSide optional yes / no
search String optional Case-insensitive text match
status PositionStatus optional pending / active / completed / rejected
sort UserPositionSortInput optional Sort direction / property

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
position_id String! Stable position id
user_id String! Owning user id
currency_id String! Settlement currency
avg_price Float! Average entry price
invested Float Cost basis (shares × avg_price) (nullable)
settled_shares Float Shares paid out at settlement (nullable until settled)
realized_pnl Float! Realized profit / loss
status PositionStatus! pending / active / completed / rejected
market_id String! Market id
event_id String Parent event id (nullable) — lazy @ResolveField
market_venue_id String! Market venue id
outcome_side OutcomeSide! yes / no
created_at String! Create time
updated_at String! Update time
shares Float! Held shares while active; shares at settlement once completed — lazy @ResolveField
mark_price Float Current best bid for the side held — what a share would fetch if sold now. null when the market is unpriced. — lazy @ResolveField
unrealized_pnl Float Mark-to-bid P&L of held shares, in currency_id. 0 once closed; null while open but the market is unpriced. — lazy @ResolveField
total_pnl Float realized_pnl + unrealized_pnl. null while open but the market is unpriced. — lazy @ResolveField
unrealized_roi Float Unrealized P&L ÷ invested (fraction; 0.1 = 10%). null when no held shares or unpriced. — lazy @ResolveField
total_pnl_roi Float total_pnl ÷ the position cost basis (invested) — fraction; 0.1 = 10%. null when there is no cost basis (e.g. closed by selling to zero) or the market is unpriced. — lazy @ResolveField
market_title String Related market title — lazy @ResolveField (nullable)
outcome_label String Venue label of the side held. Null = plain Yes/No. — lazy @ResolveField
market_image String Image URL of the related market. — lazy @ResolveField
event_title String Related event title — lazy @ResolveField (nullable)
event_image String Image URL of the related event. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

query closed_user_positions($pager: PagerInput, $date_range: DateRangeInput, $updated_at_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $currency_id: String, $outcome_side: OutcomeSide, $search: String, $status: PositionStatus, $sort: UserPositionSortInput) {
  closed_user_positions(pager: $pager, date_range: $date_range, updated_at_range: $updated_at_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, currency_id: $currency_id, outcome_side: $outcome_side, search: $search, status: $status, sort: $sort) {
    position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query closed_user_positions($pager: PagerInput, $date_range: DateRangeInput, $updated_at_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $currency_id: String, $outcome_side: OutcomeSide, $search: String, $status: PositionStatus, $sort: UserPositionSortInput) { closed_user_positions(pager: $pager, date_range: $date_range, updated_at_range: $updated_at_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, currency_id: $currency_id, outcome_side: $outcome_side, search: $search, status: $status, sort: $sort) { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query closed_user_positions($pager: PagerInput, $date_range: DateRangeInput, $updated_at_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $currency_id: String, $outcome_side: OutcomeSide, $search: String, $status: PositionStatus, $sort: UserPositionSortInput) { closed_user_positions(pager: $pager, date_range: $date_range, updated_at_range: $updated_at_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, currency_id: $currency_id, outcome_side: $outcome_side, search: $search, status: $status, sort: $sort) { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query closed_user_positions($pager: PagerInput, $date_range: DateRangeInput, $updated_at_range: DateRangeInput, $user_id: String, $market_id: String, $event_id: String, $currency_id: String, $outcome_side: OutcomeSide, $search: String, $status: PositionStatus, $sort: UserPositionSortInput) { closed_user_positions(pager: $pager, date_range: $date_range, updated_at_range: $updated_at_range, user_id: $user_id, market_id: $market_id, event_id: $event_id, currency_id: $currency_id, outcome_side: $outcome_side, search: $search, status: $status, sort: $sort) { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query user_position A single position by id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_positions.

Inputs

NameTypeRequiredDescription
position_id String! required Position id

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
position_id String! Stable position id
user_id String! Owning user id
currency_id String! Settlement currency
avg_price Float! Average entry price
invested Float Cost basis (shares × avg_price) (nullable)
settled_shares Float Shares paid out at settlement (nullable until settled)
realized_pnl Float! Realized profit / loss
status PositionStatus! pending / active / completed / rejected
market_id String! Market id
event_id String Parent event id (nullable) — lazy @ResolveField
market_venue_id String! Market venue id
outcome_side OutcomeSide! yes / no
created_at String! Create time
updated_at String! Update time
shares Float! Held shares while active; shares at settlement once completed — lazy @ResolveField
mark_price Float Current best bid for the side held — what a share would fetch if sold now. null when the market is unpriced. — lazy @ResolveField
unrealized_pnl Float Mark-to-bid P&L of held shares, in currency_id. 0 once closed; null while open but the market is unpriced. — lazy @ResolveField
total_pnl Float realized_pnl + unrealized_pnl. null while open but the market is unpriced. — lazy @ResolveField
unrealized_roi Float Unrealized P&L ÷ invested (fraction; 0.1 = 10%). null when no held shares or unpriced. — lazy @ResolveField
total_pnl_roi Float total_pnl ÷ the position cost basis (invested) — fraction; 0.1 = 10%. null when there is no cost basis (e.g. closed by selling to zero) or the market is unpriced. — lazy @ResolveField
market_title String Related market title — lazy @ResolveField (nullable)
outcome_label String Venue label of the side held. Null = plain Yes/No. — lazy @ResolveField
market_image String Image URL of the related market. — lazy @ResolveField
event_title String Related event title — lazy @ResolveField (nullable)
event_image String Image URL of the related event. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

query user_position($position_id: String!) {
  user_position(position_id: $position_id) {
    position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query user_position($position_id: String!) { user_position(position_id: $position_id) { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query user_position($position_id: String!) { user_position(position_id: $position_id) { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query user_position($position_id: String!) { user_position(position_id: $position_id) { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id market_venue_id outcome_side created_at updated_at shares mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi market_title outcome_label market_image event_title event_image } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query user_positions_stats Portfolio totals: position count, invested, current value, realized / unrealized / total P&L and ROI. Admins may pass user_id.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_positions.

Inputs

NameTypeRequiredDescription
user_id String optional Admin only: whose portfolio

Response

FieldTypeDescription
total_positions Int! Count of positions
total_shares Float! Sum of shares held
total_open_positions_invested Float! Cost basis of currently-held shares (open positions only).
total_current_value Float! Live value of open positions: total_open_positions_invested + total_unrealized_pnl (an unpriced market is valued at cost).
total_realized_pnl Float! Total realized P&L
total_unrealized_pnl Float! Mark-to-bid P&L of open positions. Unpriced markets contribute 0.
total_pnl Float! total_realized_pnl + total_unrealized_pnl.
total_unrealized_roi Float total_unrealized_pnl ÷ total_open_positions_invested (fraction; null when no open basis).

GraphQL Operation

query user_positions_stats($user_id: String) {
  user_positions_stats(user_id: $user_id) {
    total_positions total_shares total_open_positions_invested total_current_value total_realized_pnl total_unrealized_pnl total_pnl total_unrealized_roi
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query user_positions_stats($user_id: String) { user_positions_stats(user_id: $user_id) { total_positions total_shares total_open_positions_invested total_current_value total_realized_pnl total_unrealized_pnl total_pnl total_unrealized_roi } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query user_positions_stats($user_id: String) { user_positions_stats(user_id: $user_id) { total_positions total_shares total_open_positions_invested total_current_value total_realized_pnl total_unrealized_pnl total_pnl total_unrealized_roi } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query user_positions_stats($user_id: String) { user_positions_stats(user_id: $user_id) { total_positions total_shares total_open_positions_invested total_current_value total_realized_pnl total_unrealized_pnl total_pnl total_unrealized_roi } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
subscription user_positions_stats Live portfolio totals of the caller's positions — same shape and math as the user_positions_stats query.
Transport: WebSocket · graphql-ws  wss://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Subscription
Access Requires a bearer token. Any authenticated user. Pass the token in connectionParams.Authorization.

Inputs

This operation takes no arguments.

Response

FieldTypeDescription
total_positions Int! Count of positions
total_shares Float! Sum of shares held
total_open_positions_invested Float! Cost basis of currently-held shares (open positions only).
total_current_value Float! Live value of open positions: total_open_positions_invested + total_unrealized_pnl (an unpriced market is valued at cost).
total_realized_pnl Float! Total realized P&L
total_unrealized_pnl Float! Mark-to-bid P&L of open positions. Unpriced markets contribute 0.
total_pnl Float! total_realized_pnl + total_unrealized_pnl.
total_unrealized_roi Float total_unrealized_pnl ÷ total_open_positions_invested (fraction; null when no open basis).

GraphQL Operation

subscription user_positions_stats {
  user_positions_stats {
    total_positions total_shares total_open_positions_invested total_current_value total_realized_pnl total_unrealized_pnl total_pnl total_unrealized_roi
  }
}

Subscribe (graphql-ws)

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://prediction-market-gateway-demo.cryptosrvc.com/graphql",
  // Required: this stream is per user.
  connectionParams: { Authorization: "Bearer YOUR_TOKEN" },
});

const unsubscribe = client.subscribe(
  { query: `subscription user_positions_stats { user_positions_stats { total_positions total_shares total_open_positions_invested total_current_value total_realized_pnl total_unrealized_pnl total_pnl total_unrealized_roi } }` },
  {
    next: (msg) => console.log(msg.data),
    error: (err) => console.error(err),
    complete: () => console.log("complete"),
  },
);
Note This operation streams over the graphql-ws WebSocket — see Real-Time transport.

Try It

Subscriptions are delivered over WebSocket (wss://, graphql-ws protocol). Try It opens a WebSocket to this operation's endpoint and streams updates below; click Stop to end it.

Authenticate at the top of the page to try this
subscription user_positions_pnl Live mark-to-bid P&L of the caller's open positions, narrowed by event_id / position_ids. Static fields (shares, avg_price, status) arrive through `user_update`.
Transport: WebSocket · graphql-ws  wss://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Subscription
Access Requires a bearer token. Any authenticated user. Pass the token in connectionParams.Authorization.

Inputs

NameTypeRequiredDescription
event_id String optional Only the caller's positions in this event (event page).
position_ids [String!] optional Only these positions — the rows currently on screen (portfolio page). Max 100.

Response

FieldTypeDescription
position_id String! Position id
mark_price Float Current best bid for the side held (nullable when unpriced)
unrealized_pnl Float Mark-to-bid P&L of held shares
total_pnl Float realized_pnl + unrealized_pnl
unrealized_roi Float unrealized_pnl ÷ invested (fraction)
total_pnl_roi Float total_pnl ÷ invested (fraction)

GraphQL Operation

subscription user_positions_pnl($event_id: String, $position_ids: [String!]) {
  user_positions_pnl(event_id: $event_id, position_ids: $position_ids) {
    position_id mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi
  }
}

Subscribe (graphql-ws)

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://prediction-market-gateway-demo.cryptosrvc.com/graphql",
  // Required: this stream is per user.
  connectionParams: { Authorization: "Bearer YOUR_TOKEN" },
});

const unsubscribe = client.subscribe(
  { query: `subscription user_positions_pnl($event_id: String, $position_ids: [String!]) { user_positions_pnl(event_id: $event_id, position_ids: $position_ids) { position_id mark_price unrealized_pnl total_pnl unrealized_roi total_pnl_roi } }` },
  {
    next: (msg) => console.log(msg.data),
    error: (err) => console.error(err),
    complete: () => console.log("complete"),
  },
);
Note This operation streams over the graphql-ws WebSocket — see Real-Time transport.

Try It

Subscriptions are delivered over WebSocket (wss://, graphql-ws protocol). Try It opens a WebSocket to this operation's endpoint and streams updates below; click Stop to end it.

Authenticate at the top of the page to try this

Balances & Transfers

Prediction balances are held on the prediction ledger, separate from exchange wallets. Money moves in and out with deposit / withdraw; every movement is a ledger item. · 4 operations · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

query accounts Prediction balances: the caller's own, or any user's for an admin.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_accounts.

Inputs

NameTypeRequiredDescription
user_id String optional Admin only
account_id String optional Stable account id (one per user and currency)
currency_id String optional Currency id
hide_zero_balances ToggleSwitch optional on / off (default off)
pager PagerInput optional Limit / offset (default 30 / 0)
sort SortInput optional Sort direction / property

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
account_id String! Stable account id (one per user and currency)
user_id String! User id
currency_id String! Currency id
balance Float! Total prediction balance, including money held by open buy orders
version Int! Optimistic-lock version
created_at String! Create time
updated_at String! Update time
free_balance Float! balance - money held by open buy orders. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

query accounts($user_id: String, $account_id: String, $currency_id: String, $hide_zero_balances: ToggleSwitch, $pager: PagerInput, $sort: SortInput) {
  accounts(user_id: $user_id, account_id: $account_id, currency_id: $currency_id, hide_zero_balances: $hide_zero_balances, pager: $pager, sort: $sort) {
    account_id user_id currency_id balance version created_at updated_at free_balance
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query accounts($user_id: String, $account_id: String, $currency_id: String, $hide_zero_balances: ToggleSwitch, $pager: PagerInput, $sort: SortInput) { accounts(user_id: $user_id, account_id: $account_id, currency_id: $currency_id, hide_zero_balances: $hide_zero_balances, pager: $pager, sort: $sort) { account_id user_id currency_id balance version created_at updated_at free_balance } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query accounts($user_id: String, $account_id: String, $currency_id: String, $hide_zero_balances: ToggleSwitch, $pager: PagerInput, $sort: SortInput) { accounts(user_id: $user_id, account_id: $account_id, currency_id: $currency_id, hide_zero_balances: $hide_zero_balances, pager: $pager, sort: $sort) { account_id user_id currency_id balance version created_at updated_at free_balance } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query accounts($user_id: String, $account_id: String, $currency_id: String, $hide_zero_balances: ToggleSwitch, $pager: PagerInput, $sort: SortInput) { accounts(user_id: $user_id, account_id: $account_id, currency_id: $currency_id, hide_zero_balances: $hide_zero_balances, pager: $pager, sort: $sort) { account_id user_id currency_id balance version created_at updated_at free_balance } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
query account_transactions Prediction ledger statement: the caller's own items, or any user's for an admin.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Query
Access Requires a bearer token. Permission: prediction_transactions.

Inputs

NameTypeRequiredDescription
account_transaction_id String optional Stable ledger item id
parent_transaction_id String optional Groups the legs of one business action (nullable)
client_transaction_id String optional Caller-supplied id (nullable)
account_id String optional Account id
user_id String optional User id
currency_id String optional Currency id
transaction_class AccountTransactionClass optional trade / fee / payment / reward / conversion / manual / referral_reward / wallet_transfer / u2u_transfer
type AccountTransactionType optional debit / credit
order_id String optional Order id
trade_id String optional Trade id
position_id String optional Position id
market_id String optional Market id
event_id String optional Event id
created_by String optional Admin who posted a manual item (nullable)
pager PagerInput optional Limit / offset (default 30 / 0)
date_range DateRangeInput optional created_at window
sort SortInput optional Sort direction / property
search String optional An id, or an event / market title

Response

FieldTypeDescription
serial_id Float Internal row id (nullable)
account_transaction_id String! Stable ledger item id
parent_transaction_id String! Groups the legs of one business action (nullable)
client_transaction_id String Caller-supplied id (nullable)
account_id String! Account id
user_id String! User id
currency_id String! Currency id
transaction_class AccountTransactionClass! trade / fee / payment / reward / conversion / manual / referral_reward / wallet_transfer / u2u_transfer
type AccountTransactionType! debit / credit
amount Float! Amount in currency_id
post_balance Float! Account balance after this item
order_id String Order id
trade_id String Trade id
position_id String Position id
market_id String Market id
event_id String Event id
comment String Free-text comment (nullable)
created_by String Admin who posted a manual item (nullable)
created_at String! Create time
created_at_iso String created_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

query account_transactions($account_transaction_id: String, $parent_transaction_id: String, $client_transaction_id: String, $account_id: String, $user_id: String, $currency_id: String, $transaction_class: AccountTransactionClass, $type: AccountTransactionType, $order_id: String, $trade_id: String, $position_id: String, $market_id: String, $event_id: String, $created_by: String, $pager: PagerInput, $date_range: DateRangeInput, $sort: SortInput, $search: String) {
  account_transactions(account_transaction_id: $account_transaction_id, parent_transaction_id: $parent_transaction_id, client_transaction_id: $client_transaction_id, account_id: $account_id, user_id: $user_id, currency_id: $currency_id, transaction_class: $transaction_class, type: $type, order_id: $order_id, trade_id: $trade_id, position_id: $position_id, market_id: $market_id, event_id: $event_id, created_by: $created_by, pager: $pager, date_range: $date_range, sort: $sort, search: $search) {
    account_transaction_id parent_transaction_id client_transaction_id account_id user_id currency_id transaction_class type amount post_balance order_id trade_id position_id market_id event_id comment created_by created_at
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"query account_transactions($account_transaction_id: String, $parent_transaction_id: String, $client_transaction_id: String, $account_id: String, $user_id: String, $currency_id: String, $transaction_class: AccountTransactionClass, $type: AccountTransactionType, $order_id: String, $trade_id: String, $position_id: String, $market_id: String, $event_id: String, $created_by: String, $pager: PagerInput, $date_range: DateRangeInput, $sort: SortInput, $search: String) { account_transactions(account_transaction_id: $account_transaction_id, parent_transaction_id: $parent_transaction_id, client_transaction_id: $client_transaction_id, account_id: $account_id, user_id: $user_id, currency_id: $currency_id, transaction_class: $transaction_class, type: $type, order_id: $order_id, trade_id: $trade_id, position_id: $position_id, market_id: $market_id, event_id: $event_id, created_by: $created_by, pager: $pager, date_range: $date_range, sort: $sort, search: $search) { account_transaction_id parent_transaction_id client_transaction_id account_id user_id currency_id transaction_class type amount post_balance order_id trade_id position_id market_id event_id comment created_by created_at } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """query account_transactions($account_transaction_id: String, $parent_transaction_id: String, $client_transaction_id: String, $account_id: String, $user_id: String, $currency_id: String, $transaction_class: AccountTransactionClass, $type: AccountTransactionType, $order_id: String, $trade_id: String, $position_id: String, $market_id: String, $event_id: String, $created_by: String, $pager: PagerInput, $date_range: DateRangeInput, $sort: SortInput, $search: String) { account_transactions(account_transaction_id: $account_transaction_id, parent_transaction_id: $parent_transaction_id, client_transaction_id: $client_transaction_id, account_id: $account_id, user_id: $user_id, currency_id: $currency_id, transaction_class: $transaction_class, type: $type, order_id: $order_id, trade_id: $trade_id, position_id: $position_id, market_id: $market_id, event_id: $event_id, created_by: $created_by, pager: $pager, date_range: $date_range, sort: $sort, search: $search) { account_transaction_id parent_transaction_id client_transaction_id account_id user_id currency_id transaction_class type amount post_balance order_id trade_id position_id market_id event_id comment created_by created_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `query account_transactions($account_transaction_id: String, $parent_transaction_id: String, $client_transaction_id: String, $account_id: String, $user_id: String, $currency_id: String, $transaction_class: AccountTransactionClass, $type: AccountTransactionType, $order_id: String, $trade_id: String, $position_id: String, $market_id: String, $event_id: String, $created_by: String, $pager: PagerInput, $date_range: DateRangeInput, $sort: SortInput, $search: String) { account_transactions(account_transaction_id: $account_transaction_id, parent_transaction_id: $parent_transaction_id, client_transaction_id: $client_transaction_id, account_id: $account_id, user_id: $user_id, currency_id: $currency_id, transaction_class: $transaction_class, type: $type, order_id: $order_id, trade_id: $trade_id, position_id: $position_id, market_id: $market_id, event_id: $event_id, created_by: $created_by, pager: $pager, date_range: $date_range, sort: $sort, search: $search) { account_transaction_id parent_transaction_id client_transaction_id account_id user_id currency_id transaction_class type amount post_balance order_id trade_id position_id market_id event_id comment created_by created_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
mutation deposit_to_prediction Move money from a vakotrade wallet into the prediction balance. Returns the account after the credit. TRANSFER_PENDING = vakotrade did not answer; the balance updates once it is confirmed. An admin passes `user_id` and acts on that user's behalf. Send an `x-idempotency-key` header to make a retry safe.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Mutation
Access Requires a bearer token. Permission: transfer_prediction_funds. Send an x-idempotency-key header to make a retry safe (a repeat within 5 min fails with DUPLICATE_REQUEST).

Inputs

NameTypeRequiredDescription
amount Float! required Floored to the currency precision.
currency_id String! required Currency id
wallet_id String optional The vakotrade wallet the money comes from / goes to. (default WALLET_ID_MAIN)
user_id String optional Admin only, required: whose money moves. A trader's own id is always used.

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
account_id String! Stable account id (one per user and currency)
user_id String! User id
currency_id String! Currency id
balance Float! Total prediction balance, including money held by open buy orders
version Int! Optimistic-lock version
created_at String! Create time
updated_at String! Update time
free_balance Float! balance - money held by open buy orders. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

mutation deposit_to_prediction($amount: Float!, $currency_id: String!, $wallet_id: String, $user_id: String) {
  deposit_to_prediction(amount: $amount, currency_id: $currency_id, wallet_id: $wallet_id, user_id: $user_id) {
    account_id user_id currency_id balance version created_at updated_at free_balance
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"mutation deposit_to_prediction($amount: Float!, $currency_id: String!, $wallet_id: String, $user_id: String) { deposit_to_prediction(amount: $amount, currency_id: $currency_id, wallet_id: $wallet_id, user_id: $user_id) { account_id user_id currency_id balance version created_at updated_at free_balance } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """mutation deposit_to_prediction($amount: Float!, $currency_id: String!, $wallet_id: String, $user_id: String) { deposit_to_prediction(amount: $amount, currency_id: $currency_id, wallet_id: $wallet_id, user_id: $user_id) { account_id user_id currency_id balance version created_at updated_at free_balance } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `mutation deposit_to_prediction($amount: Float!, $currency_id: String!, $wallet_id: String, $user_id: String) { deposit_to_prediction(amount: $amount, currency_id: $currency_id, wallet_id: $wallet_id, user_id: $user_id) { account_id user_id currency_id balance version created_at updated_at free_balance } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this
mutation withdraw_from_prediction Move free prediction balance back to a vakotrade wallet. Returns the account after the debit. TRANSFER_PENDING = vakotrade did not answer; the money is debited and either lands in the wallet or comes back once it is confirmed. An admin passes `user_id` and acts on that user's behalf. Send an `x-idempotency-key` header to make a retry safe.
Endpoint: POST https://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Mutation
Access Requires a bearer token. Permission: transfer_prediction_funds. Send an x-idempotency-key header to make a retry safe (a repeat within 5 min fails with DUPLICATE_REQUEST).

Inputs

NameTypeRequiredDescription
amount Float! required Floored to the currency precision.
currency_id String! required Currency id
wallet_id String optional The vakotrade wallet the money comes from / goes to. (default WALLET_ID_MAIN)
user_id String optional Admin only, required: whose money moves. A trader's own id is always used.

Response

FieldTypeDescription
serial_id Int Internal row id (nullable)
account_id String! Stable account id (one per user and currency)
user_id String! User id
currency_id String! Currency id
balance Float! Total prediction balance, including money held by open buy orders
version Int! Optimistic-lock version
created_at String! Create time
updated_at String! Update time
free_balance Float! balance - money held by open buy orders. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

GraphQL Operation

mutation withdraw_from_prediction($amount: Float!, $currency_id: String!, $wallet_id: String, $user_id: String) {
  withdraw_from_prediction(amount: $amount, currency_id: $currency_id, wallet_id: $wallet_id, user_id: $user_id) {
    account_id user_id currency_id balance version created_at updated_at free_balance
  }
}

Code Examples

curl -X POST 'https://prediction-market-gateway-demo.cryptosrvc.com/graphql' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"query":"mutation withdraw_from_prediction($amount: Float!, $currency_id: String!, $wallet_id: String, $user_id: String) { withdraw_from_prediction(amount: $amount, currency_id: $currency_id, wallet_id: $wallet_id, user_id: $user_id) { account_id user_id currency_id balance version created_at updated_at free_balance } }","variables":{}}'
import requests

url = "https://prediction-market-gateway-demo.cryptosrvc.com/graphql"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "query": """mutation withdraw_from_prediction($amount: Float!, $currency_id: String!, $wallet_id: String, $user_id: String) { withdraw_from_prediction(amount: $amount, currency_id: $currency_id, wallet_id: $wallet_id, user_id: $user_id) { account_id user_id currency_id balance version created_at updated_at free_balance } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://prediction-market-gateway-demo.cryptosrvc.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${YOUR_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: `mutation withdraw_from_prediction($amount: Float!, $currency_id: String!, $wallet_id: String, $user_id: String) { withdraw_from_prediction(amount: $amount, currency_id: $currency_id, wallet_id: $wallet_id, user_id: $user_id) { account_id user_id currency_id balance version created_at updated_at free_balance } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);

Try It

Authenticate at the top of the page to try this

User Stream

One authenticated realtime channel that pushes everything that changes for the caller: order and position updates, ledger items, balances, volume-limit usage and user-facing notifications. · 1 operation · service: https://prediction-market-gateway-demo.cryptosrvc.com/graphql

subscription user_update Per-user event stream. Each message carries exactly the parts that changed (order, position, account, account_transaction, volume_limits, notification); the rest are null.
Transport: WebSocket · graphql-ws  wss://prediction-market-gateway-demo.cryptosrvc.com/graphql
Type: Subscription
Access Requires a bearer token. Any authenticated user. Pass the token in connectionParams.Authorization.

Inputs

This operation takes no arguments.

Response

FieldTypeDescription
notification UserUpdateNotification User-facing notification (nullable)
order Order The order that changed (nullable)
position UserPosition The position that changed (nullable)
account_transaction AccountTransaction A ledger item on the caller: post_balance is the new balance.
account Account The account whose balance changed (nullable)
volume_limits UserVolumeLimitsResult Updated volume-limit usage (nullable)

Type · UserUpdateNotification

FieldTypeDescription
title String Notification title
body String! Notification body
class UserUpdateNotificationClass! success / error / info
reference_nr String Related reference (e.g. order id)
code String Notification trigger code
vars JSONObject Template variables (JSON object)

Type · Order

FieldTypeDescription
serial_id Int Internal row id (nullable)
order_id String! Stable order id
user_id String! Owning user id
currency_id String! Currency id
side Side! buy / sell
market_id String! Market id
event_id String Parent event id (denormalized, nullable)
outcome_side OutcomeSide! yes / no
status OrderStatus! new / pending / completed / cancelled / rejected / expired
executed_quantity Float! Shares filled
remaining_quantity Float! Shares still open
price Float Order price (nullable)
amount Float Buy orders: exact currency amount locked and spent; shares are derived from it at fill price. Null for sells.
shares Float! Requested shares
version Int! Optimistic-lock version
message String Free-text reason stamped when the order is cancelled or rejected.
created_at String! Create time
updated_at String! Update time
fee OrderFeeResult Fee transaction of the fill; null until the order fills or when no fee applied. — lazy @ResolveField
market_title String Title of the related market. — lazy @ResolveField
outcome_label String Venue label of the side ordered. Null = plain Yes/No. — lazy @ResolveField
event_title String Title of the related event. — lazy @ResolveField
event_image String Image URL of the related event. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

Type · UserPosition

FieldTypeDescription
serial_id Int Internal row id (nullable)
position_id String! Stable position id
user_id String! Owning user id
currency_id String! Settlement currency
avg_price Float! Average entry price
invested Float Cost basis (shares × avg_price) (nullable)
settled_shares Float Shares paid out at settlement (nullable until settled)
realized_pnl Float! Realized profit / loss
status PositionStatus! pending / active / completed / rejected
market_id String! Market id
event_id String Parent event id (nullable) — lazy @ResolveField
market_venue_id String! Market venue id
outcome_side OutcomeSide! yes / no
created_at String! Create time
updated_at String! Update time
shares Float! Held shares while active; shares at settlement once completed — lazy @ResolveField
mark_price Float Current best bid for the side held — what a share would fetch if sold now. null when the market is unpriced. — lazy @ResolveField
unrealized_pnl Float Mark-to-bid P&L of held shares, in currency_id. 0 once closed; null while open but the market is unpriced. — lazy @ResolveField
total_pnl Float realized_pnl + unrealized_pnl. null while open but the market is unpriced. — lazy @ResolveField
unrealized_roi Float Unrealized P&L ÷ invested (fraction; 0.1 = 10%). null when no held shares or unpriced. — lazy @ResolveField
total_pnl_roi Float total_pnl ÷ the position cost basis (invested) — fraction; 0.1 = 10%. null when there is no cost basis (e.g. closed by selling to zero) or the market is unpriced. — lazy @ResolveField
market_title String Related market title — lazy @ResolveField (nullable)
outcome_label String Venue label of the side held. Null = plain Yes/No. — lazy @ResolveField
market_image String Image URL of the related market. — lazy @ResolveField
event_title String Related event title — lazy @ResolveField (nullable)
event_image String Image URL of the related event. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

Type · AccountTransaction

FieldTypeDescription
serial_id Float Internal row id (nullable)
account_transaction_id String! Stable ledger item id
parent_transaction_id String! Groups the legs of one business action (nullable)
client_transaction_id String Caller-supplied id (nullable)
account_id String! Account id
user_id String! User id
currency_id String! Currency id
transaction_class AccountTransactionClass! trade / fee / payment / reward / conversion / manual / referral_reward / wallet_transfer / u2u_transfer
type AccountTransactionType! debit / credit
amount Float! Amount in currency_id
post_balance Float! Account balance after this item
order_id String Order id
trade_id String Trade id
position_id String Position id
market_id String Market id
event_id String Event id
comment String Free-text comment (nullable)
created_by String Admin who posted a manual item (nullable)
created_at String! Create time
created_at_iso String created_at as ISO-8601 — lazy @ResolveField

Type · Account

FieldTypeDescription
serial_id Int Internal row id (nullable)
account_id String! Stable account id (one per user and currency)
user_id String! User id
currency_id String! Currency id
balance Float! Total prediction balance, including money held by open buy orders
version Int! Optimistic-lock version
created_at String! Create time
updated_at String! Update time
free_balance Float! balance - money held by open buy orders. — lazy @ResolveField
created_at_iso String created_at as ISO-8601 — lazy @ResolveField
updated_at_iso String updated_at as ISO-8601 — lazy @ResolveField

Type · UserVolumeLimitsResult

FieldTypeDescription
currency_id String! Currency the limits are denominated in
daily VolumeLimitUsage! Daily limit usage (nullable = not enforced)
weekly VolumeLimitUsage! Weekly limit usage (nullable = not enforced)
monthly VolumeLimitUsage! Monthly limit usage (nullable = not enforced)

GraphQL Operation

subscription user_update {
  user_update {
    notification { title body class reference_nr code vars } order { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity } position { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id } account_transaction { account_transaction_id parent_transaction_id client_transaction_id account_id user_id currency_id transaction_class type amount post_balance } account { account_id user_id currency_id balance version created_at updated_at free_balance } volume_limits { currency_id daily { limit used remaining } weekly { limit used remaining } monthly { limit used remaining } }
  }
}

Subscribe (graphql-ws)

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://prediction-market-gateway-demo.cryptosrvc.com/graphql",
  // Required: this stream is per user.
  connectionParams: { Authorization: "Bearer YOUR_TOKEN" },
});

const unsubscribe = client.subscribe(
  { query: `subscription user_update { user_update { notification { title body class reference_nr code vars } order { order_id user_id currency_id side market_id event_id outcome_side status executed_quantity remaining_quantity } position { position_id user_id currency_id avg_price invested settled_shares realized_pnl status market_id event_id } account_transaction { account_transaction_id parent_transaction_id client_transaction_id account_id user_id currency_id transaction_class type amount post_balance } account { account_id user_id currency_id balance version created_at updated_at free_balance } volume_limits { currency_id daily { limit used remaining } weekly { limit used remaining } monthly { limit used remaining } } } }` },
  {
    next: (msg) => console.log(msg.data),
    error: (err) => console.error(err),
    complete: () => console.log("complete"),
  },
);
Note This operation streams over the graphql-ws WebSocket — see Real-Time transport.

Try It

Subscriptions are delivered over WebSocket (wss://, graphql-ws protocol). Try It opens a WebSocket to this operation's endpoint and streams updates below; click Stop to end it.

Authenticate at the top of the page to try this

Real-Time (GraphQL Subscriptions)

Live data streams via GraphQL subscriptions over the graphql-ws protocol on the same /graphql endpoint (WebSocket upgrade). Public channels: markets_updates, markets_prices, orderbook, market_price_history_updates and crypto_price_history_updates. Per-user channels (token required): user_update, user_positions_stats and user_positions_pnl. Each is documented in its group above.

graphql-ws transport

Connect to wss://prediction-market-gateway-demo.cryptosrvc.com/graphql with the graphql-ws sub-protocol. Subscribe operations are rate-limited (30 ops / 60 s, with a 500 ms minimum gap) and the number of open subscriptions per caller is capped. Pass the bearer token in connectionParams.Authorization: the gateway forwards connectionParams as the connection's request headers. It is optional for public channels (it applies the caller's eligibility policy) and required for the per-user channels.

Connect & subscribe (browser)

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://prediction-market-gateway-demo.cryptosrvc.com/graphql",
  connectionParams: { Authorization: "Bearer YOUR_TOKEN" }, // optional for public channels
});

client.subscribe(
  { query: `subscription { orderbook(market_id: "MKT-123", outcome_side: yes) { best_bid best_ask buy { price quantity } sell { price quantity } ts_iso } }` },
  { next: (m) => console.log(m.data), error: console.error, complete: () => {} },
);

Raw protocol

The client sends a connection_init frame, then a subscribe frame carrying the GraphQL document; the server streams next frames and a final complete.

{ "id": "1", "type": "subscribe", "payload": { "query": "subscription { markets_prices(market_ids: [\"MKT-123\"]) { market_id yes { bid ask } no { bid ask } ts } }" } }