{
  "openapi": "3.0.3",
  "info": {
    "title": "Spindora GEO Analysis API",
    "version": "1.0.0",
    "description": "Analyze how AI crawlers (ChatGPT, Perplexity, Gemini, Claude) read your website. One AI profile per request. Async: POST /analyze returns task_id, poll GET /result/{task_id}. Requires X-Spindora-Key (sp_geo_*). Monthly user-level quota. No visual snapshots via API. Mandatory attribution: Powered by Spindora.",
    "contact": {
      "url": "https://www.spindorai.com/developers/geo-analysis-api"
    }
  },
  "servers": [
    {
      "url": "https://www.spindorai.com/api/public-geo-analysis"
    }
  ],
  "security": [{ "SpindoraApiKey": [] }],
  "components": {
    "securitySchemes": {
      "SpindoraApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Spindora-Key",
        "description": "API key from https://www.spindorai.com/api-keys (GEO Analysis tab, prefix sp_geo_). Alternative: Authorization: Bearer sp_geo_..."
      }
    },
    "schemas": {
      "GeoAnalyzeRequest": {
        "type": "object",
        "required": ["url"],
        "properties": {
          "url": { "type": "string", "format": "uri", "example": "https://example.com" },
          "profiles": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1,
            "items": { "type": "string", "enum": ["chatgpt", "perplexity", "gemini", "claude"] },
            "default": ["chatgpt"],
            "description": "Exactly one AI profile per analysis."
          },
          "language": { "type": "string", "enum": ["tr", "en"], "default": "tr" },
          "locale": { "type": "string", "enum": ["tr", "en"], "default": "tr" }
        }
      },
      "GeoQueuedResponse": {
        "type": "object",
        "properties": {
          "task_id": { "type": "string" },
          "message": { "type": "string" },
          "mode": { "type": "string", "example": "api" },
          "attribution": { "type": "object" }
        }
      },
      "GeoProfileResult": {
        "type": "object",
        "properties": {
          "profile": { "type": "string" },
          "geo_score": { "type": "integer" },
          "ai_readability_score": { "type": "integer" },
          "expertise_score": { "type": "integer" },
          "schema_score": { "type": "integer" },
          "crawlable": { "type": "boolean" },
          "recommendations": { "type": "array", "items": { "type": "string" } },
          "found_schemas": { "type": "array", "items": { "type": "string" } },
          "missing_schemas": { "type": "array", "items": { "type": "string" } }
        }
      },
      "GeoResult": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean" },
          "url": { "type": "string" },
          "profiles": { "type": "array", "items": { "$ref": "#/components/schemas/GeoProfileResult" } },
          "average_geo_score": { "type": "integer" },
          "average_ai_readability_score": { "type": "integer" },
          "average_expertise_score": { "type": "integer" },
          "visual_snapshot_data_url": { "type": "string", "nullable": true, "description": "Always null via API" },
          "visual_snapshots_data_urls": { "type": "array", "items": { "type": "string" }, "description": "Always empty via API" },
          "attribution": { "type": "object" }
        }
      }
    }
  },
  "paths": {
    "/analyze": {
      "post": {
        "summary": "Queue GEO analysis",
        "operationId": "analyzeGeo",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GeoAnalyzeRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/GeoQueuedResponse" }
              }
            }
          },
          "401": { "description": "Invalid API key" },
          "403": { "description": "Plan expired" },
          "429": { "description": "Monthly quota exceeded" }
        }
      }
    },
    "/result/{task_id}": {
      "get": {
        "summary": "Poll analysis result",
        "operationId": "getGeoResult",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Result ready",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/GeoResult" }
              }
            }
          },
          "202": { "description": "Still processing" },
          "401": { "description": "Invalid API key" },
          "500": { "description": "Analysis failed" }
        }
      }
    }
  },
  "x-spindora-notes": [
    "Create keys at https://www.spindorai.com/api-keys → GEO Analiz API tab.",
    "Monthly plans: Free 50, Starter 100, Pro 200, Pro+ 400, Enterprise 800 (user-level, shared across keys).",
    "Poll GET /result/{task_id} every 2–3 seconds until HTTP 200.",
    "Show Powered by Spindora attribution near results."
  ]
}
