Place a Bet

POST /markets/{id}/bets – Place a bet on a market outcome.

  • Request: Provide the market ID in the URL. The JSON body should include the outcome you want to bet on and the amount (and optionally the currency if needed). The request must be signed by the user’s wallet (or the user must have authenticated via an API key tied to their wallet) to ensure the bet is authorized and the funds are available.

POST /markets/market_b7c3d1e0/bets
Content-Type: application/json

{
  "outcome": "No",
  "amount": 10,
  "currency": "SOL"
}

This example means the user is betting 10 SOL on the "No" outcome for market_b7c3d1e0.

  • Response: On success, the API returns a confirmation with the updated state for that market (or at least the parts affected):

{
  "marketId": "market_b7c3d1e0",
  "outcome": "No",
  "amountStaked": 10.0,
  "newTotalStake": {
    "Yes": 150.0,
    "No": 60.0
  },
  "newOdds": {
    "Yes": 0.7143,
    "No": 0.2857
  },
  "transactionId": "5gHk...zFt", 
  "message": "Bet placed successfully."
}

Now the "No" side has a total of 60 SOL (previously 50 + this 10), and the "Yes" side remains 150, so the odds have shifted slightly (Yes down to ~0.714, No up to ~0.286). The response also includes a transactionId for the on-chain transaction that recorded the bet, which can be looked up on Solana’s explorer for verification.

If the request fails (e.g., insufficient funds, invalid outcome name, market already closed), an error is returned:

{
  "error": "Bet placement failed: market is already resolved or closed."
}

or a relevant message.

Note: In a real scenario, placing a bet would involve transferring the amount from the user’s wallet to the smart contract. The API call might return immediately with a pending status while the transaction is confirmed on-chain. A websocket or polling mechanism could be used to confirm when the bet is finalized. The above simplified flow assumes the bet goes through successfully.

Retrieve Results

As mentioned, once a market is resolved, the outcome and payouts are visible via GET /markets/{id}. There may not be a separate “result” endpoint; clients can just fetch the market data to see who won. However, for convenience, an endpoint could exist to specifically fetch resolved outcome and user-specific payout info:

For example, GET /markets/{id}/result might return:

{
  "marketId": "market_b7c3d1e0",
  "winningOutcome": "Yes",
  "resolvedAt": "2025-09-11T00:10:00Z",
  "yourWinnings": 0, 
  "claimable": false
}

Where yourWinnings is what the requesting user won (if the API is authenticated and knows the user’s wallet) and claimable indicates if the user still needs to claim (in Polypump, winnings could be automatically sent, so likely claimable is false and funds were auto-transferred). If the user lost, yourWinnings would be 0 (as in this example).

API Usage Notes: All monetary values are typically given in SOL or in smallest units (LAMPORTS for SOL, or smallest $POLYPUMP unit if applicable). In the examples above, we used floating numbers for readability, but actual API might use strings or integer values (e.g., "15000000000" lamports for 15 SOL) to avoid floating-point issues.

The Polypump API is versioned (hence v1 in the base path), and future changes (v2, etc.) might introduce more complex query capabilities, multi-currency support improvements, and endpoints for historical data or leaderboard stats. Always check the latest API documentation for up-to-date information on parameters and responses.

Last updated