{
  "openapi": "3.0.3",
  "info": {
    "title": "Pandan Screenshot API",
    "description": "Capture website screenshots and generate PDFs programmatically. No API key required for the free tier (100 requests/month).",
    "version": "1.0.0",
    "contact": {
      "name": "Pandan",
      "url": "https://dev.pandan.is"
    },
    "x-logo": {
      "url": "https://og.pandan.is/v1/og?title=Screenshot%20API&subtitle=by%20Pandan&color=%237b2ff7"
    }
  },
  "servers": [
    {
      "url": "https://api.pandan.is",
      "description": "Production"
    }
  ],
  "paths": {
    "/v1/screenshot": {
      "get": {
        "summary": "Capture a screenshot",
        "description": "Takes a screenshot of any URL and returns a PNG image. Supports viewport customization, full-page capture, and custom wait times.",
        "operationId": "captureScreenshot",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "URL to capture",
            "schema": { "type": "string", "format": "uri" },
            "example": "https://example.com"
          },
          {
            "name": "width",
            "in": "query",
            "description": "Viewport width in pixels",
            "schema": { "type": "integer", "default": 1280, "minimum": 320, "maximum": 3840 }
          },
          {
            "name": "height",
            "in": "query",
            "description": "Viewport height in pixels",
            "schema": { "type": "integer", "default": 800, "minimum": 200, "maximum": 2160 }
          },
          {
            "name": "fullPage",
            "in": "query",
            "description": "Capture full scrollable page",
            "schema": { "type": "boolean", "default": false }
          },
          {
            "name": "delay",
            "in": "query",
            "description": "Wait time in ms before capture",
            "schema": { "type": "integer", "default": 0, "maximum": 10000 }
          },
          {
            "name": "format",
            "in": "query",
            "description": "Output format",
            "schema": { "type": "string", "enum": ["png", "jpeg", "webp"], "default": "png" }
          }
        ],
        "responses": {
          "200": {
            "description": "Screenshot image",
            "content": {
              "image/png": {
                "schema": { "type": "string", "format": "binary" }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/v1/pdf": {
      "get": {
        "summary": "Generate PDF from URL",
        "description": "Renders a URL and returns it as a PDF document.",
        "operationId": "generatePdf",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "URL to convert to PDF",
            "schema": { "type": "string", "format": "uri" }
          },
          {
            "name": "format",
            "in": "query",
            "description": "Page format",
            "schema": { "type": "string", "enum": ["A4", "Letter", "Legal"], "default": "A4" }
          }
        ],
        "responses": {
          "200": {
            "description": "PDF document",
            "content": {
              "application/pdf": {
                "schema": { "type": "string", "format": "binary" }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Health check",
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "ok" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" }
        }
      }
    }
  }
}
