Markets
The Markets API provides access to prediction market data, including market listings with filtering and pagination options.
Get Markets List
Retrieve a paginated list of markets with filtering options.
Get list of markets (paginated, status=live, sorted by createdAt, supports partial name search via ?search=)
Page number
1
Example: 1
Pattern: ^\d+$
Page size
20
Example: 20
Pattern: ^\d+$
Sort by createdAt
desc
Example: desc
Possible values: Comma-separated list of statuses (e.g. live,approved,closed)
live,approved
Example: live,approved
Partial name search for market (case-insensitive, matches any part of the name)
List of markets
Bad request
Internal server error
GET /api/v1/markets HTTP/1.1
Host:
Accept: */*
{
"items": [
{
"id": "market-uuid",
"name": "Market Name",
"slug": "market-name",
"categoryId": "text",
"type": "text",
"rules": "text",
"status": "text",
"tradingStatus": "text",
"expiresAt": "2024-08-05T12:00:00Z",
"contractAddress": "text",
"volume": "text",
"views": "text",
"coverImageUrl": "text",
"createdAt": "2024-08-05T12:00:00Z",
"outcomes": [
{
"id": "outcome-uuid",
"name": "Yes",
"volume": "text",
"lastPrice": "text",
"positionId": "text"
}
]
}
],
"total": 100,
"page": 1,
"pageSize": 20
}
Get Market Detail
Retrieve detailed information about a specific market by its ID.
Market ID
market-uuid
Market detail
Bad request
Market not found
Internal server error
GET /api/v1/markets/{marketId} HTTP/1.1
Host:
Accept: */*
{
"id": "market-uuid",
"name": "Market Name",
"slug": "market-name",
"categoryId": "text",
"type": "text",
"rules": "text",
"status": "text",
"tradingStatus": "text",
"expiresAt": "2024-08-05T12:00:00Z",
"contractAddress": "text",
"volume": "text",
"views": "text",
"coverImageUrl": "text",
"createdAt": "2024-08-05T12:00:00Z",
"outcomes": [
{
"id": "outcome-uuid",
"name": "Yes",
"volume": "text",
"lastPrice": "text",
"positionId": "text"
}
]
}
Market Status
Markets can have the following statuses:
live
Market is open for trading
active
Market is active but may have trading restrictions
closed
Market is closed for trading
disputing
Market resolution is being disputed
resolved
Market has been resolved
resolution_proposed
Resolution has been proposed, awaiting confirmation
Code Examples
Fetch Active Markets
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'https://engine.xmarket.app/api/v1';
async function getActiveMarkets() {
const response = await fetch(
`${BASE_URL}/markets?status=live&pageSize=50`,
{
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
}
}
);
const data = await response.json();
return data.items;
}
Get Market Detail
async function getMarketDetail(marketId) {
const response = await fetch(
`${BASE_URL}/markets/${marketId}`,
{
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
}
}
);
if (!response.ok) {
throw new Error(`Market not found: ${response.status}`);
}
const market = await response.json();
console.log(`Market: ${market.name}`);
console.log(`Status: ${market.status}`);
console.log(`Outcomes: ${market.outcomes.length}`);
return market;
}
// Example usage
const market = await getMarketDetail('market-uuid-here');
Filter Markets by Status
async function getMarketsByStatus(status) {
const response = await fetch(
`${BASE_URL}/markets?status=${status}&page=1&pageSize=100`,
{
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
}
}
);
const data = await response.json();
console.log(`Found ${data.total} ${status} markets`);
return data.items;
}
// Get all resolved markets
const resolvedMarkets = await getMarketsByStatus('resolved');
// Get markets in dispute
const disputingMarkets = await getMarketsByStatus('disputing');
Best Practices
Caching: Cache market data appropriately as metadata doesn't change frequently
Pagination: Use pagination for large result sets to improve performance
Error Handling: Implement retry logic for transient network errors
Rate Limiting: Respect API rate limits (100 req/min, 20 req/sec burst)
Data Validation: Always validate market and outcome IDs before using them
Related Documentation
Orderbook API - Get orderbook data for markets
Orders API - Create and manage orders
Quick Start - Get started with the API
Last updated
Was this helpful?