Skip to main content
POST
https://api.pmx.trade
/
v2
/
markets
/
{slug}
/
trade
/
buy
curl -X POST "https://api.pmx.trade/v2/markets/btc-100k-march/trade/buy" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "wallet": "YourWalletPubkey...",
    "amount": 10,
    "side": "YES"
  }'
{
  "success": false,
  "error": {
    "code": "PAYMENT_REQUIRED",
    "message": "Payment required to execute buy"
  },
  "payment": {
    "x402Version": 1,
    "accepts": [
      {
        "network": "solana-mainnet",
        "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
        "amount": "10000000",
        "payTo": "YesOptionWallet..."
      }
    ],
    "payTo": "YesOptionWallet..."
  },
  "quote": {
    "side": "YES",
    "amount": 10,
    "issuedAt": "2026-01-15T10:00:00Z",
    "expiresAt": "2026-01-15T10:02:00Z",
    "ttlMs": 120000
  },
  "marketSlug": "btc-100k-march"
}
Buying shares uses a two-step X.402 payment flow:
  1. Step 1: Submit buy request to get payment requirements (returns 402)
  2. Step 2: Complete the USDC payment and submit again with X-PAYMENT header (returns 200)
slug
string
required
The market slug (e.g., btc-100k-march)

Request Body

wallet
string
required
Your Solana wallet address (must match payment sender)
amount
number
required
USDC amount to spend (0.01 - 1,000,000)
side
string
required
Side to buy: YES or NO

Step 1: Get Quote

curl -X POST "https://api.pmx.trade/v2/markets/btc-100k-march/trade/buy" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "wallet": "YourWalletPubkey...",
    "amount": 10,
    "side": "YES"
  }'
{
  "success": false,
  "error": {
    "code": "PAYMENT_REQUIRED",
    "message": "Payment required to execute buy"
  },
  "payment": {
    "x402Version": 1,
    "accepts": [
      {
        "network": "solana-mainnet",
        "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
        "amount": "10000000",
        "payTo": "YesOptionWallet..."
      }
    ],
    "payTo": "YesOptionWallet..."
  },
  "quote": {
    "side": "YES",
    "amount": 10,
    "issuedAt": "2026-01-15T10:00:00Z",
    "expiresAt": "2026-01-15T10:02:00Z",
    "ttlMs": 120000
  },
  "marketSlug": "btc-100k-march"
}

Step 2: Execute Trade

After making the USDC payment to the payTo address:
# Create payment payload
PAYMENT_PAYLOAD=$(echo -n '{
  "x402Version": 1,
  "network": "solana-mainnet",
  "txHash": "YOUR_USDC_TX_SIGNATURE",
  "amount": 10,
  "payer": "YourWalletPubkey...",
  "payTo": "YesOptionWallet...",
  "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "networkId": "solana-mainnet",
  "quoteIssuedAt": "2026-01-15T10:00:00Z"
}' | base64)

curl -X POST "https://api.pmx.trade/v2/markets/btc-100k-march/trade/buy" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: $PAYMENT_PAYLOAD" \
  -d '{
    "wallet": "YourWalletPubkey...",
    "amount": 10,
    "side": "YES"
  }'
{
  "success": true,
  "data": {
    "slug": "btc-100k-march",
    "action": "buy",
    "side": "YES",
    "amount": 10,
    "paymentTxHash": "YOUR_USDC_TX_SIGNATURE",
    "tokenTransferTxHash": "PLATFORM_TOKEN_TX_SIGNATURE",
    "wallet": "YourWalletPubkey..."
  }
}

Payment Payload Fields (X-PAYMENT header)

The X-PAYMENT header must contain a base64-encoded JSON object:
FieldTypeDescription
x402VersionnumberProtocol version (use 1)
networkstringNetwork identifier (e.g., solana-mainnet)
txHashstringYour USDC payment transaction signature
amountnumberUSDC amount paid
payerstringYour wallet address (must match wallet in body)
payTostringRecipient from quote response
assetstringUSDC token mint address
networkIdstringNetwork identifier
quoteIssuedAtstringISO 8601 timestamp from quote response
Quotes expire after 2 minutes (ttlMs). If your quote expires, request a new one before executing the trade.
The platform automatically transfers outcome tokens to your wallet after payment verification. The number of tokens received is calculated as: amount / target_price (typically $0.0005 per token).