{
  "openapi": "3.1.0",
  "info": {
    "title": "BoardGameIdea API",
    "version": "1.0.0",
    "description": "Predict how players would rate a board game from its rules text alone. Each request is evaluated against a 39-criterion rubric in 8 dimensions, and the overall score uses weights calibrated against real player ratings of published games. The response is the same report the BoardGameIdea website shows. The feedback is AI-generated. Evaluation by game name is not supported."
  },
  "servers": [
    {
      "url": "https://boardgameidea.com/api"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Or send Authorization: Bearer <key>."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "examples": [
                  "invalid_input",
                  "missing_api_key",
                  "invalid_api_key",
                  "revoked_api_key",
                  "quota_exceeded",
                  "not_scorable",
                  "busy",
                  "analysis_failed",
                  "analysis_failed",
                  "unavailable",
                  "not_found",
                  "method_not_allowed",
                  "internal"
                ]
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "ScoreRequest": {
        "type": "object",
        "properties": {
          "rules": {
            "type": "string",
            "minLength": 200,
            "maxLength": 60000,
            "description": "The full rules text of one board game, in any language."
          }
        },
        "required": [
          "rules"
        ]
      },
      "Subcriterion": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "score": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10
          },
          "justification": {
            "type": "string"
          }
        }
      },
      "Dimension": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "score": {
            "type": "number",
            "description": "Average of the subcriterion scores (descriptive)."
          },
          "weight": {
            "type": "number",
            "description": "Share of this dimension in the overall score."
          },
          "subcriteria": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Subcriterion"
            }
          }
        }
      },
      "ScoreResponse": {
        "type": "object",
        "properties": {
          "apiVersion": {
            "type": "string",
            "const": "v1"
          },
          "score": {
            "type": "number",
            "minimum": 1,
            "maximum": 10,
            "description": "Predicted average player rating, 1-10."
          },
          "scale": {
            "type": "object",
            "properties": {
              "min": {
                "type": "integer"
              },
              "max": {
                "type": "integer"
              }
            }
          },
          "verdict": {
            "type": "object",
            "description": "Very promising (7.8+), Promising (7.3–7.8), Has potential (6.8–7.3), Needs work (below 6.8).",
            "properties": {
              "key": {
                "type": "string",
                "enum": [
                  "very-promising",
                  "promising",
                  "potential",
                  "needs-work"
                ]
              },
              "label": {
                "type": "string"
              }
            }
          },
          "playability": {
            "type": "object",
            "description": "Mean of the Accessibility, Pace and Balance dimensions, as a label.",
            "properties": {
              "key": {
                "type": "string",
                "enum": [
                  "most",
                  "right-group",
                  "hard"
                ]
              },
              "label": {
                "type": "string"
              },
              "score": {
                "type": "number"
              }
            }
          },
          "percentile": {
            "type": "integer",
            "minimum": 1,
            "maximum": 99,
            "description": "Share of established published games (each with 500+ player ratings) with a lower average rating."
          },
          "summary": {
            "type": "string"
          },
          "strengths": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "$ref": "#/components/schemas/Point"
            }
          },
          "concerns": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "$ref": "#/components/schemas/Point"
            }
          },
          "dimensions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Dimension"
            }
          },
          "properties": {
            "type": "object",
            "properties": {
              "minPlayers": {
                "type": "integer"
              },
              "maxPlayers": {
                "type": "integer"
              },
              "bestPlayerCount": {
                "type": "string"
              },
              "minPlayTimeMinutes": {
                "type": "integer"
              },
              "maxPlayTimeMinutes": {
                "type": "integer"
              },
              "minAge": {
                "type": "integer"
              },
              "complexity": {
                "type": "number",
                "description": "Complexity on a 1-5 scale (1 very light, 5 very heavy)."
              },
              "gameType": {
                "type": "string"
              },
              "mechanisms": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "description": "Extracted from the rules; 0 or empty when the rules do not say."
          },
          "cached": {
            "type": "boolean",
            "description": "True when the same rules text was scored before and the stored evaluation was reused."
          }
        }
      },
      "Point": {
        "type": "object",
        "properties": {
          "dimension": {
            "type": "string"
          },
          "dimensionLabel": {
            "type": "string"
          },
          "key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "score": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10
          },
          "justification": {
            "type": "string"
          }
        }
      }
    },
    "headers": {
      "X-RateLimit-Limit": {
        "schema": {
          "type": "integer"
        },
        "description": "Requests allowed per UTC day for this key."
      },
      "X-RateLimit-Remaining": {
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Reset": {
        "schema": {
          "type": "integer"
        },
        "description": "Unix time when the daily limit resets (UTC midnight)."
      }
    }
  },
  "paths": {
    "/v1/health": {
      "get": {
        "summary": "Service status",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "apiVersion": {
                      "type": "string"
                    },
                    "docs": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/rubric": {
      "get": {
        "summary": "The scoring rubric: dimensions, subcriteria and what each score means",
        "responses": {
          "200": {
            "description": "The rubric"
          }
        }
      }
    },
    "/v1/score": {
      "post": {
        "summary": "Score a board game from its rules",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScoreRequest"
              }
            },
            "text/plain": {
              "schema": {
                "type": "string",
                "description": "The rules text itself."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The predicted score with its breakdown",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScoreResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input: missing, too short (< 200 characters) or too long (> 60,000) rules, or a game name instead of rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The text could not be analysed (it does not look like the rules of a board game)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Daily limit reached; see Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The analysis could not be completed; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The service is busy or unavailable; see Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}
