{
  "openapi": "3.0.3",
  "info": {
    "title": "BotVisibility API",
    "description": "Scan any URL to check AI agent readiness",
    "version": "1.0.0",
    "contact": {
      "name": "Joey Janisheck",
      "url": "https://janisheck.com"
    }
  },
  "servers": [
    { "url": "https://botvisibility.com" }
  ],
  "paths": {
    "/api/scan": {
      "get": {
        "operationId": "scanUrl",
        "summary": "Scan a URL for agent readiness. Returns JSON when format=json or Accept: application/json, otherwise SSE stream.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": { "type": "string" },
            "description": "The URL to scan (e.g. example.com or https://example.com)"
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "enum": ["json"] },
            "description": "Set to 'json' to get JSON response instead of SSE stream. Recommended for agents."
          }
        ],
        "responses": {
          "200": {
            "description": "Scan results. JSON when format=json or Accept: application/json, SSE stream otherwise.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScanResult"
                }
              },
              "text/event-stream": {
                "schema": { "type": "string" }
              }
            }
          },
          "400": {
            "description": "Invalid URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "scanUrlPost",
        "summary": "Scan a URL for agent readiness (JSON response via POST body)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["url"],
                "properties": {
                  "url": { "type": "string", "format": "uri" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scan results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": { "type": "string" },
                    "timestamp": { "type": "string", "format": "date-time" },
                    "currentLevel": { "type": "integer" },
                    "checks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": { "type": "string" },
                          "name": { "type": "string" },
                          "passed": { "type": "boolean" },
                          "status": { "type": "string", "enum": ["pass", "fail", "partial", "na"] },
                          "level": { "type": "integer" },
                          "message": { "type": "string" }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/badge": {
      "get": {
        "operationId": "getBadge",
        "summary": "Generate an SVG badge showing a site's BotVisibility score and level",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": { "type": "string" },
            "description": "The domain to generate a badge for (e.g. example.com)"
          }
        ],
        "responses": {
          "200": {
            "description": "SVG badge image",
            "content": {
              "image/svg+xml": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/api/screenshot": {
      "get": {
        "operationId": "getScreenshot",
        "summary": "Get a cached screenshot of a scanned site",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": { "type": "string" },
            "description": "The URL to get a screenshot for (e.g. example.com)"
          }
        ],
        "responses": {
          "200": {
            "description": "Screenshot image",
            "content": {
              "image/png": {
                "schema": { "type": "string", "format": "binary" }
              }
            }
          },
          "404": {
            "description": "No screenshot available for this URL"
          }
        }
      }
    },
    "/.well-known/api-catalog": {
      "get": {
        "operationId": "getApiCatalog",
        "summary": "RFC 9727 API catalog linkset for API discovery",
        "responses": {
          "200": {
            "description": "Linkset describing available APIs",
            "content": {
              "application/linkset+json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/api/mcp": {
      "post": {
        "operationId": "mcpServer",
        "summary": "Model Context Protocol server (Streamable HTTP transport). Tools: scan_url, get_check_definitions, get_check, get_showcase, compare_sites.",
        "description": "MCP-compliant endpoint. Use an MCP client (Claude Desktop, Cursor, etc.) to interact with this endpoint. See /.well-known/mcp.json for the manifest.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "type": "object" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP response",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ScanResult": {
        "type": "object",
        "properties": {
          "url": { "type": "string" },
          "timestamp": { "type": "string", "format": "date-time" },
          "currentLevel": { "type": "integer", "description": "Highest achieved level (0-3)" },
          "levels": {
            "type": "array",
            "description": "Progress breakdown per level",
            "items": {
              "type": "object",
              "properties": {
                "level": {
                  "type": "object",
                  "properties": {
                    "number": { "type": "integer" },
                    "name": { "type": "string" },
                    "description": { "type": "string" }
                  }
                },
                "passed": { "type": "integer" },
                "failed": { "type": "integer" },
                "na": { "type": "integer" },
                "total": { "type": "integer" },
                "complete": { "type": "boolean" }
              }
            }
          },
          "checks": {
            "type": "array",
            "description": "All 48 web check results (L1-L4); Level 5 Agent-Native checks are CLI-only",
            "items": {
              "type": "object",
              "properties": {
                "id": { "type": "string", "description": "e.g. 1.1, 2.3, 3.7, 4.10" },
                "name": { "type": "string" },
                "passed": { "type": "boolean" },
                "status": { "type": "string", "enum": ["pass", "fail", "partial", "na"] },
                "level": { "type": "integer" },
                "category": { "type": "string" },
                "message": { "type": "string" },
                "recommendation": { "type": "string" },
                "details": { "type": "string" },
                "foundAt": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Optional API key for higher rate limits. Public access is available without a key."
      }
    }
  },
  "security": [
    {},
    { "apiKey": [] }
  ]
}
