{
    "openapi": "3.1.0",
    "info": {
        "title": "Scrnify Capture API",
        "version": "0.1.0-beta",
        "description": "Capture screenshots and short videos from a URL. The API is in open beta and may change before its stable release.",
        "contact": {
            "name": "Scrnify support",
            "email": "support@scrnify.com"
        }
    },
    "servers": [
        {
            "url": "https://api.scrnify.com",
            "description": "Production"
        }
    ],
    "security": [
        {
            "apiKey": []
        }
    ],
    "paths": {
        "/capture": {
            "get": {
                "operationId": "captureUrl",
                "summary": "Capture a URL",
                "description": "Creates an image or video capture. By default, the response redirects to the generated file. Set `output=json` to receive the request ID and file URL as JSON. Signed API keys also require `signature` and a non-zero `cache_ttl`.",
                "tags": ["Capture"],
                "parameters": [
                    {
                        "name": "url",
                        "in": "query",
                        "required": true,
                        "description": "URL of the web page to capture.",
                        "schema": {
                            "type": "string",
                            "format": "uri"
                        },
                        "example": "https://example.com"
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "description": "Capture type.",
                        "schema": {
                            "type": "string",
                            "enum": ["image", "video"],
                            "default": "image"
                        }
                    },
                    {
                        "name": "format",
                        "in": "query",
                        "description": "Output format. Image captures support `webp`, `png`, and `jpeg`. Video captures support `mp4`, `webm`, and `gif`. Defaults to `webp` for images and `mp4` for videos.",
                        "schema": {
                            "type": "string",
                            "enum": ["webp", "png", "jpeg", "mp4", "webm", "gif"]
                        }
                    },
                    {
                        "name": "width",
                        "in": "query",
                        "description": "Viewport width in pixels.",
                        "schema": {
                            "type": "integer",
                            "format": "int64",
                            "minimum": 1,
                            "default": 1920
                        }
                    },
                    {
                        "name": "height",
                        "in": "query",
                        "description": "Viewport height in pixels. Full-page image captures determine output height from page content.",
                        "schema": {
                            "type": "integer",
                            "format": "int64",
                            "minimum": 1,
                            "default": 1080
                        }
                    },
                    {
                        "name": "fullPage",
                        "in": "query",
                        "description": "Capture full page height. Applies to image captures.",
                        "schema": {
                            "type": "boolean",
                            "default": false
                        }
                    },
                    {
                        "name": "selector",
                        "in": "query",
                        "description": "CSS selector for an element-only image capture.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "main"
                    },
                    {
                        "name": "quality",
                        "in": "query",
                        "description": "JPEG image quality.",
                        "schema": {
                            "type": "integer",
                            "format": "int64",
                            "minimum": 0,
                            "maximum": 100,
                            "default": 100
                        }
                    },
                    {
                        "name": "duration",
                        "in": "query",
                        "description": "Video duration in seconds.",
                        "schema": {
                            "type": "integer",
                            "format": "int64",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "waitUntil",
                        "in": "query",
                        "description": "Browser lifecycle event to wait for before capture.",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "firstPaint",
                                "firstContentfulPaint",
                                "firstImagePaint",
                                "firstMeaningfulPaintCandidate",
                                "firstMeaningfulPaint",
                                "DOMContentLoaded",
                                "load",
                                "networkIdle",
                                "networkAlmostIdle"
                            ],
                            "default": "firstMeaningfulPaint"
                        }
                    },
                    {
                        "name": "userAgent",
                        "in": "query",
                        "description": "Custom browser User-Agent value.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "blockCookieDefault",
                        "in": "query",
                        "description": "Enable built-in cookie notice blocking filters.",
                        "schema": {
                            "type": "boolean",
                            "default": false
                        }
                    },
                    {
                        "name": "blockFilter",
                        "in": "query",
                        "description": "Custom request-blocking rules using Adblock Plus/uBlock Origin filter syntax.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "cache_ttl",
                        "in": "query",
                        "description": "Cache duration in seconds. Values above 30 days are capped. Required and non-zero for signed API keys.",
                        "schema": {
                            "type": "integer",
                            "format": "int64",
                            "minimum": 0,
                            "maximum": 2592000,
                            "default": 0
                        }
                    },
                    {
                        "name": "signature",
                        "in": "query",
                        "description": "Hex-encoded HMAC-SHA256 signature of the remaining query string. Required for signed API keys.",
                        "schema": {
                            "type": "string",
                            "pattern": "^[a-fA-F0-9]{64}$"
                        }
                    },
                    {
                        "name": "output",
                        "in": "query",
                        "description": "Choose a redirect to the generated file or a JSON response containing its URL.",
                        "schema": {
                            "type": "string",
                            "enum": ["file", "json"],
                            "default": "file"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Capture created. Returned when `output=json`.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/CaptureResponse"
                                }
                            }
                        }
                    },
                    "307": {
                        "description": "Redirect to the generated or cached capture file.",
                        "headers": {
                            "Location": {
                                "description": "Generated capture file URL.",
                                "schema": {
                                    "type": "string",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Missing or invalid query parameter. Signed requests without a cache TTL also return this status."
                    },
                    "401": {
                        "description": "Invalid API key or request signature."
                    },
                    "402": {
                        "description": "Billing is required after free usage is exhausted.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorResponse"
                                }
                            },
                            "text/plain": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Account capture rate limit reached.",
                        "headers": {
                            "Retry-After": {
                                "description": "Seconds to wait before retrying.",
                                "schema": {
                                    "type": "integer",
                                    "minimum": 1
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Capture service or internal server error."
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "apiKey": {
                "type": "apiKey",
                "in": "query",
                "name": "key",
                "description": "A 32-character Scrnify API key."
            }
        },
        "schemas": {
            "CaptureResponse": {
                "type": "object",
                "required": ["request_id", "file"],
                "properties": {
                    "request_id": {
                        "type": "string",
                        "description": "Unique capture request ID."
                    },
                    "file": {
                        "type": "string",
                        "format": "uri",
                        "description": "Generated capture file URL."
                    }
                },
                "additionalProperties": false
            },
            "ErrorResponse": {
                "type": "object",
                "required": ["error", "message"],
                "properties": {
                    "error": {
                        "type": "string"
                    },
                    "message": {
                        "type": "string"
                    }
                },
                "additionalProperties": false
            }
        }
    },
    "externalDocs": {
        "description": "Scrnify API documentation",
        "url": "https://scrnify.com/docs"
    }
}
