{
  "openapi": "3.1.0",
  "info": {
    "title": "SteamTools Public API",
    "version": "1.0.0",
    "description": "Free, unauthenticated HTTP endpoints for searching the Steam catalog and generating SteamTools manifest / Lua pairs."
  },
  "servers": [
    {
      "url": "https://steamtools.games"
    }
  ],
  "paths": {
    "/api/search": {
      "get": {
        "summary": "Search the Steam catalog",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "description": "Free-text search term or numeric App ID. Numeric queries are resolved via the appdetails endpoint so the result is always canonical.",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid query"
          },
          "429": {
            "description": "Rate-limited (one request per 300 ms per IP)"
          }
        }
      }
    },
    "/api/generate": {
      "post": {
        "summary": "Generate the manifest + Lua pair for an App ID",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid App ID or branch"
          },
          "404": {
            "description": "App ID not found in the Steam store"
          },
          "429": {
            "description": "Rate-limited (one request per 1.5 s per IP)"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SearchResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "enum": [
              0,
              -1
            ]
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "results": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "image": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              },
              "source": {
                "type": "string",
                "enum": [
                  "search",
                  "appdetails"
                ]
              }
            }
          }
        }
      },
      "GenerateRequest": {
        "type": "object",
        "required": [
          "appId"
        ],
        "properties": {
          "appId": {
            "type": "string",
            "pattern": "^\\d{1,10}$"
          },
          "branch": {
            "type": "string",
            "enum": [
              "public",
              "beta",
              "beta_1",
              "ptb",
              "experimental",
              "staging"
            ],
            "default": "public"
          }
        }
      },
      "GenerateResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "enum": [
              0,
              -1
            ]
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "appId": {
                "type": "string"
              },
              "branch": {
                "type": "string"
              },
              "gameName": {
                "type": "string"
              },
              "gameImage": {
                "type": "string",
                "format": "uri"
              },
              "manifestUrl": {
                "type": "string",
                "format": "uri"
              },
              "luaUrl": {
                "type": "string",
                "format": "uri"
              },
              "instructions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "generatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      }
    }
  }
}