PrimapePrediction API

Introduction

The PrimapePrediction API provides a simple way to interact with our prediction markets from your applications.

Authentication

All API requests require authentication using an API key:


    // Include your API key in the Authorization header
    Authorization: Bearer YOUR_API_KEY
    

Base URL

All API requests should be made to the following base URL:

https://api.primapeprediction.com/v1

Endpoints

Get Markets


    GET /markets
    
    // Query parameters
    status: 'open' | 'resolved' | 'all' (default: 'all')
    limit: number (default: 20)
    offset: number (default: 0)
    
    // Response
    {
      "markets": [
        {
          "id": "market_123",
          "question": "Who will win the 2024 US Presidential Election?",
          "options": ["Democrat", "Republican", "Other"],
          "endTime": 1722556800,
          "resolved": false,
          "totalPool": "1250000000000000000"
        },
        // ...more markets
      ],
      "total": 45,
      "limit": 20,
      "offset": 0
    }
    

Get Market


    GET /markets/:marketId
    
    // Response
    {
      "id": "market_123",
      "question": "Who will win the 2024 US Presidential Election?",
      "options": ["Democrat", "Republican", "Other"],
      "endTime": 1722556800,
      "resolved": false,
      "totalPool": "1250000000000000000",
      "optionPools": [
        "500000000000000000",
        "70000000000000000"
      ]
    }
    

Get User Positions


    GET /users/:address/positions
    
    // Query parameters
    marketId: string (optional - filter by market)
    
    // Response
    {
      "positions": [
        {
          "marketId": "market_123",
          "shares": [
            "100000000000000000",
            "0",
            "0"
          ],
          "invested": "100000000000000000"
        },
        // ...more positions
      ]
    }
    

Error Handling

The API uses standard HTTP status codes to indicate the success or failure of requests:

  • 200 OK: The request was successful.
  • 400 Bad Request: The request was invalid or cannot be served.
  • 401 Unauthorized: Authentication failed or user doesn't have permissions.
  • 404 Not Found: The requested resource does not exist.
  • 500 Internal Server Error: Something went wrong on the server.

Error responses include a message field with more details:


    {
      "error": {
        "code": "invalid_request",
        "message": "Invalid market ID format"
      }
    }
    

Rate Limits

API requests are limited to 100 requests per minute per API key. If you exceed this limit, you'll receive a 429 Too Many Requests response.

Support

If you encounter any issues or have questions about the API, please contact our support team at api-support@primapeprediction.com.