gRPC API
The Prediction Market API exposes a gRPC interface for high-performance, low-latency integration. The gRPC API provides the same functionality as the REST API using Protocol Buffers.
Default Address: {host}:50055
Package: prediction
Service: PredictionService
Proto Definition
The full .proto file is available at src/proto/prediction.proto in the source repository. Below is a summary of all available RPCs.
Market Operations
CreateMarket
rpc CreateMarket(CreateMarketRequest) returns (MarketResponse);
| Field | Type | Description |
|---|---|---|
operator_id | string | Your operator ID |
category_id | string | Category UUID (optional) |
title | string | Market title |
description | string | Market description |
image_url | string | Image URL |
currency | string | Currency code |
trading_starts_at | int64 | Unix timestamp (ms) |
trading_ends_at | int64 | Unix timestamp (ms) |
outcomes | MarketOutcomeInput[] | Outcome definitions |
GetMarket
rpc GetMarket(GetMarketRequest) returns (MarketResponse);
| Field | Type | Description |
|---|---|---|
id | string | Market UUID |
operator_id | string | Optional — validates ownership if provided |
ListMarkets
rpc ListMarkets(ListMarketsRequest) returns (ListMarketsResponse);
| Field | Type | Description |
|---|---|---|
operator_id | string | Filter by operator |
category_id | string | Filter by category |
status | string[] | Filter by statuses |
search | string | Search title |
cursor | string | Pagination cursor |
limit | int32 | Page size |
UpdateMarket
rpc UpdateMarket(UpdateMarketRequest) returns (MarketResponse);
Market Lifecycle
rpc OpenMarket(MarketActionRequest) returns (MarketResponse);
rpc SuspendMarket(SuspendMarketRequest) returns (MarketResponse);
rpc ResumeMarket(MarketActionRequest) returns (MarketResponse);
rpc CloseMarket(MarketActionRequest) returns (MarketResponse);
rpc CancelMarket(CancelMarketRequest) returns (MarketResponse);
rpc ResolveMarket(ResolveMarketRequest) returns (MarketResponse);
Category Operations
CreateCategory
rpc CreateCategory(CreateCategoryRequest) returns (CategoryResponse);
ListCategories
rpc ListCategories(ListCategoriesRequest) returns (ListCategoriesResponse);
Trading Operations
PlaceOrder
rpc PlaceOrder(PlaceOrderRequest) returns (OrderResultResponse);
| Field | Type | Description |
|---|---|---|
operator_id | string | Your operator ID |
player_id | string | Player identifier |
market_id | string | Market UUID |
outcome_id | string | Outcome UUID |
side | string | BUY or SELL |
type | string | MARKET or LIMIT |
shares | double | Number of shares |
price | double | Limit price (required for LIMIT) |
transaction_id | string | Operator reference key (optional) |
expires_at | int64 | Unix timestamp (ms, optional) |
Response: OrderResultResponse
| Field | Type | Description |
|---|---|---|
success | bool | Whether the order was accepted |
order | Order | The order details |
trades | Trade[] | Executed trades |
status | string | Order status |
filled_shares | string | Shares filled |
avg_fill_price | string | Average execution price |
remaining_shares | string | Shares still in the book |
error_code | string | Error code if failed |
error_message | string | Error details if failed |
CancelOrder
rpc CancelOrder(CancelOrderRequest) returns (OrderResponse);
| Field | Type | Description |
|---|---|---|
operator_id | string | Your operator ID |
order_id | string | Order UUID |
GetOrder
rpc GetOrder(GetOrderRequest) returns (OrderResponse);
ListOrders
rpc ListOrders(ListOrdersRequest) returns (ListOrdersResponse);
| Field | Type | Description |
|---|---|---|
operator_id | string | Your operator ID |
player_id | string | Filter by player (optional) |
market_id | string | Filter by market |
outcome_id | string | Filter by outcome |
side | string | Filter by side |
type | string | Filter by type |
status | string[] | Filter by statuses |
cursor | string | Pagination cursor |
limit | int32 | Page size |
Position & Trade Operations
GetPositions
rpc GetPositions(GetPositionsRequest) returns (GetPositionsResponse);
| Field | Type | Description |
|---|---|---|
operator_id | string | Your operator ID |
market_id | string | Filter by market (optional) |
player_id | string | Filter by player (optional) |
GetTrades
rpc GetTrades(GetTradesRequest) returns (GetTradesResponse);
| Field | Type | Description |
|---|---|---|
operator_id | string | Your operator ID |
market_id | string | Filter by market |
outcome_id | string | Filter by outcome |
cursor | string | Pagination cursor |
limit | int32 | Page size |
Market Data
GetOrderBook
rpc GetOrderBook(GetOrderBookRequest) returns (OrderBookResponse);
| Field | Type | Description |
|---|---|---|
market_id | string | Market UUID |
outcome_id | string | Outcome UUID |
depth | int32 | Number of price levels |
GetMarketPrices
rpc GetMarketPrices(GetMarketPricesRequest) returns (MarketPricesResponse);
Settlement Operations
SettleMarket
rpc SettleMarket(SettleMarketRequest) returns (SettleMarketResponse);
GetSettlementStatus
rpc GetSettlementStatus(GetSettlementStatusRequest) returns (SettlementStatusResponse);
RetrySettlements
rpc RetrySettlements(RetrySettlementsRequest) returns (SettleMarketResponse);
GetOperatorSettlements
rpc GetOperatorSettlements(GetOperatorSettlementsRequest) returns (GetOperatorSettlementsResponse);
| Field | Type | Description |
|---|---|---|
operator_id | string | Your operator ID |
market_id | string | Filter by market (optional) |
player_id | string | Filter by player (optional) |
Health Check
rpc HealthCheck(Empty) returns (HealthResponse);
Response:
| Field | Type | Description |
|---|---|---|
healthy | bool | Service health status |
version | string | Service version |
timestamp | int64 | Unix timestamp |
Message Types
Order
message Order {
string id = 1;
string market_id = 2;
string outcome_id = 3;
string operator_id = 4;
string player_id = 5;
string side = 6;
string type = 7;
string shares = 8;
string price = 9;
string filled_shares = 10;
string avg_fill_price = 11;
string remaining_shares = 12;
string status = 13;
string transaction_id = 14;
int64 expires_at = 15;
int64 created_at = 16;
int64 updated_at = 17;
}
Trade
message Trade {
string id = 1;
string market_id = 2;
string outcome_id = 3;
string buy_order_id = 4;
string sell_order_id = 5;
string buyer_operator_id = 6;
string seller_operator_id = 7;
string price = 8;
string shares = 9;
string buyer_fee = 10;
string seller_fee = 11;
int64 created_at = 12;
}
Position
message Position {
string id = 1;
string market_id = 2;
string outcome_id = 3;
string operator_id = 4;
string player_id = 5;
string shares = 6;
string avg_price = 7;
string total_cost = 8;
string realized_pnl = 9;
int64 created_at = 10;
int64 updated_at = 11;
}
Settlement
message Settlement {
string id = 1;
string position_id = 2;
string market_id = 3;
string outcome_id = 4;
string operator_id = 5;
string player_id = 6;
string shares = 7;
string payout_per_share = 8;
string total_payout = 9;
string transaction_id = 10;
string status = 11;
string error_message = 12;
int64 settled_at = 13;
int64 created_at = 14;
int64 updated_at = 15;
}
Error Handling
gRPC errors are returned in the response message fields error_code and error_message. The success field indicates whether the operation succeeded. Error codes are the same as those documented in the Error Codes reference.