Skip to main content
BETAThe Prediction Market API is currently in beta and subject to breaking changes as we continue to improve the product. If you have any feedback, please reach out in Discord.
This doc covers the data endpoints for querying positions, orders, and transaction history. Use these endpoints to build dashboards, track P&L, and maintain audit trails.

Prerequisite

To query position data, you need:
API REFERENCEFor complete endpoint specifications, see the Prediction API Reference.

Querying Positions

Use GET /positions to retrieve position data with comprehensive P&L information.
ParameterTypeDescription
ownerPubkeystringWallet public key (required)
marketPubkeystringFilter by market account pubkey
marketIdstringFilter by market ID
isYesbooleanFilter by position side
startnumberPagination start index
endnumberPagination end index

PNL Fields

Each position includes detailed P&L metrics:
FieldDescription
totalCostUsdTotal cost basis (entry cost)
avgPriceUsdAverage price per contract
valueUsdCurrent mark-to-market value
markPriceUsdCurrent market price per contract
pnlUsdUnrealized profit/loss
pnlUsdPercentUnrealized P&L as percentage
pnlUsdAfterFeesP&L after estimated fees
pnlUsdAfterFeesPercentP&L after fees as percentage
realizedPnlUsdRealized P&L from closed portions
feesPaidUsdTotal fees paid

Get All Positions

const response = await fetch(
  'https://api.jup.ag/prediction/v1/positions?' + new URLSearchParams({
    ownerPubkey: wallet.publicKey.toString()
  }),
  {
    headers: {
      'x-api-key': 'your-api-key'
    }
  }
);

const positions = await response.json();
const positions = await fetch(
  'https://api.jup.ag/prediction/v1/positions?' + new URLSearchParams({
    ownerPubkey: wallet.publicKey.toString()
  }),
  {
    headers: { 'x-api-key': 'your-api-key' }
  }
).then(r => r.json());

// Calculate totals
let totalValue = 0;
let totalCost = 0;
let totalPnl = 0;

for (const position of positions.data) {
  totalValue += parseInt(position.valueUsd) || 0;
  totalCost += parseInt(position.totalCostUsd) || 0;
  totalPnl += parseInt(position.pnlUsd) || 0;
}

console.log('Portfolio Summary:');
console.log(`Total Value: $${(totalValue / 1_000_000).toFixed(2)}`);
console.log(`Total Cost: $${(totalCost / 1_000_000).toFixed(2)}`);
console.log(`Total P&L: $${(totalPnl / 1_000_000).toFixed(2)}`);

Get a Specific Position

const positionPubkey = 'position-pubkey-789';
const response = await fetch(
  `https://api.jup.ag/prediction/v1/positions/${positionPubkey}`,
  {
    headers: {
      'x-api-key': 'your-api-key'
    }
  }
);

const position = await response.json();

Querying Orders

Use GET /orders to retrieve order history and fill details.
ParameterTypeDescription
ownerPubkeystringWallet public key
startnumberPagination start (or timestamp)
endnumberPagination end (or timestamp)

Order Fill Details

FieldDescription
statuspending, filled, or failed
filledContractsNumber of contracts executed
avgFillPriceUsdAverage execution price
totalCostUsdTotal cost of filled portion
feesPaidUsdFees charged
createdAtUnix timestamp of order creation
filledAtUnix timestamp of fill completion

Get All Orders

const response = await fetch(
  'https://api.jup.ag/prediction/v1/orders?' + new URLSearchParams({
    ownerPubkey: wallet.publicKey.toString()
  }),
  {
    headers: {
      'x-api-key': 'your-api-key'
    }
  }
);

const orders = await response.json();

Get Order Status

Use GET /orders/status/{orderPubkey} for detailed status and event history.
const orderPubkey = 'order-pubkey-123';
const response = await fetch(
  `https://api.jup.ag/prediction/v1/orders/status/${orderPubkey}`,
  {
    headers: {
      'x-api-key': 'your-api-key'
    }
  }
);

const status = await response.json();

Transaction History

Use GET /history to retrieve a complete audit trail of all prediction market activity.
ParameterTypeDescription
ownerPubkeystringWallet public key
positionPubkeystringFilter by specific position
startnumberStart timestamp or index
endnumberEnd timestamp or index
idstringFilter by specific event ID

Event Types

Event TypeDescription
order_createdNew order placed on-chain
order_filledOrder matched and executed
order_failedOrder could not be filled
position_updatedPosition modified by order fill
position_lostMarket resolved against position
payout_claimedWinnings withdrawn

Get Transaction History

const response = await fetch(
  'https://api.jup.ag/prediction/v1/history?' + new URLSearchParams({
    ownerPubkey: wallet.publicKey.toString()
  }),
  {
    headers: {
      'x-api-key': 'your-api-key'
    }
  }
);

const history = await response.json();

What’s Next

Explore social features to view profiles, follow traders, and track leaderboards.