{
  "openapi": "3.1.0",
  "info": {
    "title": "JellyStreamz Public API",
    "version": "1.0.0",
    "description": "Read-only discovery for JellyStreamz releases and the public game metadata catalog, plus OAuth-protected member identity.",
    "termsOfService": "https://jellystreamz.com/terms/",
    "contact": {
      "name": "JellyStreamz",
      "url": "https://jellystreamz.com/contact/",
      "email": "hello@jellystreamz.com"
    }
  },
  "servers": [
    {
      "url": "https://jellystreamz.com"
    }
  ],
  "externalDocs": {
    "description": "JellyStreamz API and agent documentation",
    "url": "https://jellystreamz.com/api/"
  },
  "tags": [
    {
      "name": "Games",
      "description": "Public video game metadata and platform discovery"
    },
    {
      "name": "Releases",
      "description": "JellyStreamz app release and platform information"
    },
    {
      "name": "Identity",
      "description": "OAuth-protected member identity"
    },
    {
      "name": "Operations",
      "description": "Service health"
    }
  ],
  "paths": {
    "/api/v1/agent/games/": {
      "get": {
        "operationId": "searchGames",
        "summary": "Search games or list platforms",
        "tags": ["Games"],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Game title or partial title. Required unless platforms=1.",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "system",
            "in": "query",
            "description": "Optional platform slug.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30,
              "default": 10
            }
          },
          {
            "name": "platforms",
            "in": "query",
            "description": "Set to 1 to list platforms instead of searching.",
            "schema": {
              "type": "string",
              "enum": ["1"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search or platform results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/games/": {
      "get": {
        "operationId": "getOrSearchGameCatalog",
        "summary": "Get a game, search within a platform, or list systems",
        "tags": ["Games"],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "system",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "operationId": "matchRomFiles",
        "summary": "Match client-supplied ROM fingerprints and names",
        "tags": ["Games"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["systemId", "items"],
                "properties": {
                  "systemId": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "maxItems": 100,
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  },
                  "artworkTypes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "ROM match results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/community/": {
      "get": {
        "operationId": "getReleaseFeed",
        "summary": "Get JellyStreamz release and platform availability",
        "tags": ["Releases"],
        "responses": {
          "200": {
            "description": "Release feed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/me/": {
      "get": {
        "operationId": "getAuthorizedMember",
        "summary": "Get the authorizing member's basic account identity",
        "tags": ["Identity"],
        "security": [
          {
            "oauth2": ["profile.read"]
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized member identity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["id", "displayName"],
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "displayName": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or expired bearer token"
          },
          "403": {
            "description": "The token lacks profile.read"
          }
        }
      }
    },
    "/api/health/": {
      "get": {
        "operationId": "getApiHealth",
        "summary": "Get public API health",
        "tags": ["Operations"],
        "responses": {
          "200": {
            "description": "Service is healthy"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "description": "OAuth 2.0 Authorization Code with PKCE.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://jellystreamz.com/oauth/authorize/",
            "tokenUrl": "https://jellystreamz.com/oauth/token/",
            "scopes": {
              "games.read": "Read public game metadata",
              "community.read": "Read public release and community information",
              "profile.read": "Read the authorizing member's basic identity"
            }
          }
        }
      }
    },
    "responses": {
      "InvalidRequest": {
        "description": "Invalid request"
      },
      "NotFound": {
        "description": "Resource not found"
      },
      "Unavailable": {
        "description": "Service temporarily unavailable"
      }
    }
  }
}
