{
  "openapi": "3.1.0",
  "info": {
    "title": "OddsLab Calculation API for AI Agents",
    "description": "Mathematical calculation API for sports betting strategies: Dutching (profit equalization across multiple outcomes), Surebets arbitrage detection, and stake sizing. Provided by OddsLab (https://www.oddslab.online).",
    "version": "1.0.0",
    "contact": {
      "name": "OddsLab Support",
      "url": "https://www.oddslab.online",
      "email": "contact@oddslab.online"
    }
  },
  "servers": [
    {
      "url": "https://www.oddslab.online",
      "description": "Production server"
    }
  ],
  "paths": {
    "/api/v1/calculate/dutching": {
      "get": {
        "operationId": "calculateDutchingGet",
        "summary": "Calculate Dutching stakes and profits via URL query parameters",
        "description": "Computes exact stake distribution across 2 or more betting odds so that net profit is equalized regardless of outcome. Detects surebets and returns ROI.",
        "parameters": [
          {
            "name": "odds",
            "in": "query",
            "required": true,
            "description": "Comma-separated list of odds in decimal (e.g. '2.10,1.95') or American (e.g. '+150,-110') format.",
            "schema": {
              "type": "string",
              "example": "2.10,1.95"
            }
          },
          {
            "name": "totalStake",
            "in": "query",
            "required": false,
            "description": "Total investment bankroll to distribute (default: 100).",
            "schema": {
              "type": "number",
              "default": 100,
              "example": 100
            }
          },
          {
            "name": "commissions",
            "in": "query",
            "required": false,
            "description": "Optional comma-separated commission percentages per bookmaker (e.g. '0,2.5').",
            "schema": {
              "type": "string",
              "example": "0,0"
            }
          },
          {
            "name": "roundStakes",
            "in": "query",
            "required": false,
            "description": "Whether to round stakes to whole integer values.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful calculation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DutchingResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: Invalid or missing parameters"
          }
        }
      },
      "post": {
        "operationId": "calculateDutchingPost",
        "summary": "Calculate Dutching stakes with structured JSON payload",
        "description": "Allows advanced parameters including per-selection commissions and freebet indicators.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DutchingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful calculation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DutchingResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: Invalid payload"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DutchingRequest": {
        "type": "object",
        "required": ["odds"],
        "properties": {
          "odds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of odds (decimal or American)",
            "example": ["2.10", "1.95"]
          },
          "totalStake": {
            "type": "number",
            "description": "Total investment bankroll",
            "default": 100,
            "example": 100
          },
          "commissions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Commission percentages per selection"
          },
          "freebets": {
            "type": "array",
            "items": {
              "type": "boolean"
            },
            "description": "Flags indicating if a selection is an SNR Free Bet"
          },
          "roundStakes": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "DutchingResponse": {
        "type": "object",
        "properties": {
          "platform": {
            "type": "string",
            "example": "OddsLab"
          },
          "totalInvested": {
            "type": "number",
            "example": 100
          },
          "totalProfit": {
            "type": "number",
            "example": 1.11
          },
          "roiPercent": {
            "type": "number",
            "example": 1.11
          },
          "isSurebet": {
            "type": "boolean",
            "example": true
          },
          "marketMarginPercent": {
            "type": "number",
            "example": -1.1
          },
          "totalImpliedProbability": {
            "type": "number",
            "example": 98.9
          },
          "selections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "selectionNumber": { "type": "integer" },
                "odd": { "type": "string" },
                "decimalMultiplier": { "type": "number" },
                "stake": { "type": "number" },
                "profitIfWins": { "type": "number" },
                "isFreebet": { "type": "boolean" },
                "commissionPercent": { "type": "number" }
              }
            }
          },
          "documentation": {
            "type": "string",
            "example": "https://www.oddslab.online/llms.txt"
          }
        }
      }
    }
  }
}
