{
    "openapi": "3.1.0",
    "info": {
        "title": "YouTube API",
        "version": "v1",
        "description": "Channel statistics for YouTube channels: subscribers, videos and views, by handle or channel ID."
    },
    "servers": [
        {
            "url": "https://api.flowdata.one/v1",
            "description": "FlowData API"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "stats",
            "description": "Channel statistics"
        }
    ],
    "paths": {
        "/youtube/stats/{identifier}": {
            "get": {
                "operationId": "stats-get",
                "summary": "Get channel statistics",
                "description": "Retrieves the statistics of a YouTube channel. Every successful response is billed, including cached: true; 404 for a channel that was not found is free.",
                "tags": [
                    "stats"
                ],
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Handle (for example @YouTube) or channel ID (for example UCBR8-60-B28hp2BmDPdntcQ)"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "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": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "FlowData key as 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"
                            }
                        }
                    }
                }
            }
        }
    }
}