{
  "openapi": "3.1.0",
  "info": {
    "title": "RacingPulse API",
    "description": "Global horse racing intelligence — live odds, going conditions, form analysis, arbitrage detection, speed ratings, and betting systems for 35 racecourses. All endpoints require x402 payment (USDC on Base mainnet) via the PAYMENT-SIGNATURE header.",
    "version": "1.0.0",
    "contact": {
      "url": "https://racingpulse.vercel.app",
      "email": "info@theaslangroupllc.com"
    }
  },
  "servers": [{ "url": "https://racingpulse.vercel.app" }],
  "paths": {
    "/api/scanner": {
      "get": {
        "summary": "Arbitrage scanner — scan all active racing sports for guaranteed-profit opportunities",
        "operationId": "scanner",
        "parameters": [
          { "name": "regions", "in": "query", "schema": { "type": "string", "default": "uk,au,us,eu" } }
        ],
        "responses": {
          "200": { "description": "Arbitrage scan results" },
          "402": { "description": "x402 payment required" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    },
    "/api/arbitrage": {
      "get": {
        "summary": "Live arbitrage — filtered guaranteed-profit opportunities for a specific racing jurisdiction",
        "operationId": "arbitrage",
        "parameters": [
          { "name": "sport", "in": "query", "schema": { "type": "string", "enum": ["horse_racing_uk", "horse_racing_au", "horse_racing_us", "horse_racing_za"] } },
          { "name": "min_profit", "in": "query", "schema": { "type": "number", "default": 0 }, "description": "Minimum profit % filter" },
          { "name": "regions", "in": "query", "schema": { "type": "string", "default": "uk,au,us,eu" } }
        ],
        "responses": {
          "200": { "description": "Arbitrage opportunities with stake allocations" },
          "402": { "description": "x402 payment required" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    },
    "/api/card": {
      "get": {
        "summary": "Race card — complete meeting briefing with runners, odds, going, and news",
        "operationId": "card",
        "parameters": [
          { "name": "track", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Track name e.g. ascot, cheltenham, flemington" },
          { "name": "date", "in": "query", "schema": { "type": "string", "format": "date" } }
        ],
        "responses": {
          "200": { "description": "Race card with going and news" },
          "402": { "description": "x402 payment required" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    },
    "/api/going": {
      "get": {
        "summary": "Going conditions — live ground conditions derived from 7-day precipitation data",
        "operationId": "going",
        "parameters": [
          { "name": "track", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Track name, or 'all' for summary of top 12 tracks" }
        ],
        "responses": {
          "200": { "description": "Going conditions with trend and moisture index" },
          "402": { "description": "x402 payment required" },
          "404": { "description": "Track not found — returns list of available tracks" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    },
    "/api/form": {
      "get": {
        "summary": "Form guide — deep horse form analysis with trainer stats and going preferences",
        "operationId": "form",
        "parameters": [
          { "name": "horse", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Horse name" },
          { "name": "trainer", "in": "query", "schema": { "type": "string" }, "description": "Trainer name (optional)" }
        ],
        "responses": {
          "200": { "description": "Complete form analysis" },
          "400": { "description": "Missing required horse parameter" },
          "402": { "description": "x402 payment required" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    },
    "/api/ratings": {
      "get": {
        "summary": "Speed ratings — official rating, RPR, Timeform, and going-adjusted performance ratings",
        "operationId": "ratings",
        "parameters": [
          { "name": "horse", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Horse name" }
        ],
        "responses": {
          "200": { "description": "Speed ratings with going-adjusted breakdown" },
          "400": { "description": "Missing required horse parameter" },
          "402": { "description": "x402 payment required" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    },
    "/api/systems": {
      "get": {
        "summary": "Betting systems — statistically-backed angles, trainer/jockey combos, draw bias",
        "operationId": "systems",
        "parameters": [
          { "name": "filter", "in": "query", "schema": { "type": "string" }, "description": "e.g. 'Ascot sprints', 'novice hurdlers', 'flat handicaps'" }
        ],
        "responses": {
          "200": { "description": "Betting systems with strike rates and ROI" },
          "402": { "description": "x402 payment required" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    },
    "/api/trends": {
      "get": {
        "summary": "Race trends — historical patterns, draw bias, trainer records, value and fade angles",
        "operationId": "trends",
        "parameters": [
          { "name": "race", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Race or meeting name e.g. 'Cheltenham Gold Cup', 'Royal Ascot'" }
        ],
        "responses": {
          "200": { "description": "Historical trends with confidence levels" },
          "402": { "description": "x402 payment required" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    },
    "/api/track": {
      "get": {
        "summary": "Track profile — complete racecourse intelligence with live going conditions",
        "operationId": "track",
        "parameters": [
          { "name": "track", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Track name e.g. ascot, cheltenham, flemington" }
        ],
        "responses": {
          "200": { "description": "Track profile with draw bias and current going" },
          "402": { "description": "x402 payment required" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    },
    "/api/calculator": {
      "get": {
        "summary": "Betting calculator — arbitrage stakes (Kelly), expected value, and profit calculations",
        "operationId": "calculator",
        "parameters": [
          { "name": "mode", "in": "query", "required": true, "schema": { "type": "string", "enum": ["arb", "ev"] } },
          { "name": "bankroll", "in": "query", "schema": { "type": "number" }, "description": "Total bankroll (arb mode)" },
          { "name": "odds", "in": "query", "schema": { "type": "string" }, "description": "Comma-separated runner odds e.g. 3.5,2.1 (arb mode)" },
          { "name": "single_odds", "in": "query", "schema": { "type": "number" }, "description": "Decimal odds for single selection (ev mode)" },
          { "name": "true_prob", "in": "query", "schema": { "type": "number" }, "description": "Your estimated true win probability 0-1 (ev mode)" },
          { "name": "stake", "in": "query", "schema": { "type": "number" }, "description": "Stake amount (ev mode)" }
        ],
        "responses": {
          "200": { "description": "Calculation results" },
          "400": { "description": "Missing or invalid parameters" },
          "402": { "description": "x402 payment required" }
        },
        "x-payment": { "amount": "70000", "asset": "USDC", "network": "eip155:8453" }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "x402": {
        "type": "apiKey",
        "in": "header",
        "name": "PAYMENT-SIGNATURE",
        "description": "x402 micropayment signature. USDC on Base mainnet. Send request without header to receive 402 with payment requirements."
      }
    }
  },
  "security": [{ "x402": [] }]
}
