{
  "openapi": "3.0.3",
  "info": {
    "title": "MHGU Relink Public API",
    "version": "1.0.0",
    "description": "Read-only JSON API for MHGU Hub, MH3U Revival and the PPSSPP relay. No authentication is required for v1. CORS is enabled."
  },
  "servers": [
    { "url": "/" }
  ],
  "paths": {
    "/api/v1": {
      "get": {
        "summary": "API index",
        "operationId": "getApiIndex",
        "responses": { "200": { "description": "Endpoint index", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Object" } } } } }
      }
    },
    "/api/v1/overview": {
      "get": {
        "summary": "Combined service, hub, MH3U and relay overview",
        "operationId": "getOverview",
        "responses": { "200": { "description": "Overview", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Overview" } } } } }
      }
    },
    "/api/v1/services": {
      "get": {
        "summary": "Service health list",
        "operationId": "getServices",
        "responses": { "200": { "description": "Service health", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Object" } } } } }
      }
    },
    "/api/v1/hub": {
      "get": {
        "summary": "MHGU hub statistics and public rooms",
        "operationId": "getHub",
        "responses": {
          "200": { "description": "Hub list", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Hub" } } } },
          "503": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/api/v1/mh3u": {
      "get": {
        "summary": "MH3U public summary",
        "operationId": "getMh3u",
        "responses": {
          "200": { "description": "MH3U summary", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Mh3uSummary" } } } },
          "503": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/api/v1/mh3u/status": {
      "get": {
        "summary": "MH3U status",
        "operationId": "getMh3uStatus",
        "responses": {
          "200": { "description": "MH3U status", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Object" } } } },
          "503": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/api/v1/mh3u/players": {
      "get": {
        "summary": "MH3U online players (public view)",
        "operationId": "getMh3uPlayers",
        "responses": {
          "200": { "description": "MH3U players", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Object" } } } },
          "503": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/api/v1/mh3u/rooms": {
      "get": {
        "summary": "MH3U rooms",
        "operationId": "getMh3uRooms",
        "responses": {
          "200": { "description": "MH3U rooms", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Object" } } } },
          "503": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/api/v1/mh3u/halls": {
      "get": {
        "summary": "MH3U halls",
        "operationId": "getMh3uHalls",
        "responses": {
          "200": { "description": "MH3U halls", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Object" } } } },
          "503": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/api/v1/mh3u/stats": {
      "get": {
        "summary": "MH3U capacity statistics",
        "operationId": "getMh3uStats",
        "responses": {
          "200": { "description": "MH3U stats", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Object" } } } },
          "503": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/api/v1/ppsspp": {
      "get": {
        "summary": "PPSSPP relay games",
        "operationId": "getPpsspp",
        "responses": {
          "200": { "description": "Relay games", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Object" } } } },
          "503": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/api/v1/health": {
      "get": {
        "summary": "Lightweight health check",
        "operationId": "getHealth",
        "responses": { "200": { "description": "Health", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Object" } } } } }
      }
    },
    "/api/v1/openapi.json": {
      "get": {
        "summary": "This OpenAPI document",
        "operationId": "getOpenApi",
        "responses": { "200": { "description": "OpenAPI document" } }
      }
    }
  },
  "components": {
    "responses": {
      "Unavailable": {
        "description": "Upstream service unavailable",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      }
    },
    "schemas": {
      "Object": { "type": "object", "additionalProperties": true },
      "Error": {
        "type": "object",
        "properties": { "error": { "type": "string" } }
      },
      "Service": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "subtitle": { "type": "string" },
          "category": { "type": "string" },
          "status": { "type": "string", "enum": ["online", "degraded", "offline"] },
          "endpoint": { "type": "string" },
          "latency_ms": { "type": "integer", "nullable": true },
          "detail": { "type": "string" }
        }
      },
      "Overview": {
        "type": "object",
        "properties": {
          "version": { "type": "string" },
          "generated_at": { "type": "integer" },
          "services": { "type": "array", "items": { "$ref": "#/components/schemas/Service" } },
          "hub": { "type": "object", "nullable": true },
          "mh3u": { "$ref": "#/components/schemas/Mh3uSummary" },
          "ppsspp": { "type": "object" },
          "system": { "type": "object" }
        }
      },
      "Hub": {
        "type": "object",
        "properties": {
          "uptime": { "type": "integer" },
          "conns": { "type": "integer" },
          "players": { "type": "integer" },
          "hubs": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
          "hunter_searches": { "type": "array", "items": { "type": "object" } },
          "peers": { "type": "array", "items": { "type": "object" } }
        }
      },
      "Mh3uSummary": {
        "type": "object",
        "properties": {
          "server": { "type": "string" },
          "public_address": { "type": "string" },
          "uptime_s": { "type": "number" },
          "online": { "type": "integer" },
          "rooms": { "type": "integer" },
          "halls": { "type": "integer" },
          "connections": { "type": "integer" },
          "caps": { "type": "object", "nullable": true }
        }
      }
    }
  }
}
