{
    "openapi": "3.1.0",
    "info": {
        "title": "YouTube API",
        "version": "v1",
        "description": "Kanalstatistiken für YouTube-Kanäle: Abonnenten, Videos und Aufrufe, per Handle oder Channel-ID."
    },
    "servers": [
        {
            "url": "https://api.flowdata.one/v1",
            "description": "FlowData API"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "stats",
            "description": "Kanal-Statistiken"
        }
    ],
    "paths": {
        "/youtube/stats/{identifier}": {
            "get": {
                "operationId": "stats-get",
                "summary": "Kanal-Statistiken abrufen",
                "description": "Ruft die Statistiken eines YouTube-Kanals ab. Berechnet wird jede erfolgreiche Antwort, auch mit cached: true; 404 für einen nicht gefundenen Kanal ist kostenlos.",
                "tags": [
                    "stats"
                ],
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Handle (zum Beispiel @YouTube) oder Channel-ID (zum Beispiel UCBR8-60-B28hp2BmDPdntcQ)"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "cached": true,
                                    "data": {
                                        "channel_id": "UCBR8-60-B28hp2BmDPdntcQ",
                                        "handle": "@YouTube",
                                        "title": "YouTube",
                                        "description": "YouTube's official channel...",
                                        "subscriber_count": 40000000,
                                        "video_count": 500,
                                        "view_count": 3000000000,
                                        "thumbnail_url": "https://...",
                                        "last_synced_at": "2026-01-12T10:00:00Z"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "FlowData-Schlüssel als Authorization: Bearer fd_…"
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            },
                            "type": {
                                "type": "string"
                            },
                            "details": {
                                "type": "object"
                            }
                        }
                    }
                }
            }
        }
    }
}