{
  "openapi": "3.1.0",
  "info": {
    "title": "SnapCount Public Integration API",
    "version": "1.0.0",
    "description": "The supported public integration surface for SnapCount. Counter management, authentication, webhooks, and MCP are not currently public APIs.",
    "contact": {
      "name": "SnapCount Support",
      "email": "viraj@snapcount.app",
      "url": "https://snapcount.app/support"
    }
  },
  "servers": [
    {
      "url": "https://snapcount.app",
      "description": "SnapCount production site"
    }
  ],
  "paths": {
    "/api/oembed": {
      "get": {
        "operationId": "getSnapCountEmbed",
        "summary": "Get embed metadata for a SnapCount live counter",
        "description": "Returns an oEmbed 1.0 rich response containing iframe markup for a SnapCount embed URL.",
        "tags": ["Embedding"],
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "Absolute URL whose path has the form /embed/{sessionId}.",
            "schema": {
              "type": "string",
              "format": "uri",
              "examples": ["https://snapcount.app/embed/example-session"]
            }
          },
          {
            "name": "maxwidth",
            "in": "query",
            "required": false,
            "description": "Maximum iframe width in pixels. The response is capped at 300 pixels.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 300
            }
          },
          {
            "name": "maxheight",
            "in": "query",
            "required": false,
            "description": "Maximum iframe height in pixels. The response is capped at 200 pixels.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SnapCount oEmbed metadata",
            "headers": {
              "Access-Control-Allow-Origin": {
                "schema": {
                  "type": "string",
                  "const": "*"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OEmbedResponse"
                }
              }
            }
          },
          "400": {
            "description": "The url parameter is missing, invalid, or is not a SnapCount embed path.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "OEmbedResponse": {
        "type": "object",
        "required": [
          "type",
          "version",
          "title",
          "provider_name",
          "provider_url",
          "html",
          "width",
          "height"
        ],
        "properties": {
          "type": { "type": "string", "const": "rich" },
          "version": { "type": "string", "const": "1.0" },
          "title": { "type": "string" },
          "author_name": { "type": "string" },
          "author_url": { "type": "string", "format": "uri" },
          "provider_name": { "type": "string", "const": "SnapCount" },
          "provider_url": { "type": "string", "format": "uri" },
          "cache_age": { "type": "integer" },
          "html": { "type": "string" },
          "width": { "type": "integer" },
          "height": { "type": "integer" },
          "thumbnail_url": { "type": "string", "format": "uri" }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": { "type": "string" }
        }
      }
    }
  }
}
