{
    "openapi": "3.1.0",
    "info": {
        "title": "API do YouTube",
        "version": "v1",
        "description": "Estatísticas de canais do YouTube: inscritos, vídeos e visualizações, por handle ou ID do canal."
    },
    "servers": [
        {
            "url": "https://api.flowdata.one/v1",
            "description": "FlowData API"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "stats",
            "description": "Estatísticas do canal"
        }
    ],
    "paths": {
        "/youtube/stats/{identifier}": {
            "get": {
                "operationId": "stats-get",
                "summary": "Obter estatísticas do canal",
                "description": "Consulta as estatísticas de um canal do YouTube. Toda resposta bem-sucedida é cobrada, inclusive com cached: true; 404 para canal não encontrado é grátis.",
                "tags": [
                    "stats"
                ],
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Handle (por exemplo @YouTube) ou ID do canal (por exemplo UCBR8-60-B28hp2BmDPdntcQ)"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "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": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "Chave FlowData como 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"
                            }
                        }
                    }
                }
            }
        }
    }
}