{"id":14979790,"url":"https://github.com/prem-ium/youtube-analytics-bot","last_synced_at":"2025-10-28T19:32:03.985Z","repository":{"id":154548652,"uuid":"569301712","full_name":"Prem-ium/youtube-analytics-bot","owner":"Prem-ium","description":"🤖 Discord bot to receive YouTube Analytics statistics such as views, estimated ad revenue, \u0026 more!🕵📊","archived":false,"fork":false,"pushed_at":"2024-09-08T16:56:01.000Z","size":2712,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-11T20:02:32.301Z","etag":null,"topics":["adsense","content-creator","discord","discord-bot","google-api","google-cloud","monetization","youtube","youtube-analysis","youtube-analytics","youtube-analytics-api","youtube-api","youtube-api-v3","youtube-creators","youtube-data-api","youtube-partner","youtube-search","youtube-seo","youtube-video-metadata","youtubers-toolkit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Prem-ium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Prem-ium"],"custom":"https://www.buymeacoffee.com/prem.ium"}},"created_at":"2022-11-22T14:20:39.000Z","updated_at":"2024-09-08T16:56:04.000Z","dependencies_parsed_at":"2023-12-10T04:24:39.994Z","dependency_job_id":"1f5b2f3f-f747-4b71-a9cb-6eecaa9baf17","html_url":"https://github.com/Prem-ium/youtube-analytics-bot","commit_stats":{"total_commits":106,"total_committers":2,"mean_commits":53.0,"dds":"0.10377358490566035","last_synced_commit":"067ae4542f31f5cdc0c9fc6d85d29436f25e86b6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prem-ium%2Fyoutube-analytics-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prem-ium%2Fyoutube-analytics-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prem-ium%2Fyoutube-analytics-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prem-ium%2Fyoutube-analytics-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Prem-ium","download_url":"https://codeload.github.com/Prem-ium/youtube-analytics-bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219858899,"owners_count":16556039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adsense","content-creator","discord","discord-bot","google-api","google-cloud","monetization","youtube","youtube-analysis","youtube-analytics","youtube-analytics-api","youtube-api","youtube-api-v3","youtube-creators","youtube-data-api","youtube-partner","youtube-search","youtube-seo","youtube-video-metadata","youtubers-toolkit"],"created_at":"2024-09-24T14:00:41.426Z","updated_at":"2025-10-28T19:32:03.301Z","avatar_url":"https://github.com/Prem-ium.png","language":"Python","funding_links":["https://github.com/sponsors/Prem-ium","https://www.buymeacoffee.com/prem.ium"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"right\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/YouTube-%23FF0000.svg?style=for-the-badge\u0026logo=YouTube\u0026logoColor=white\" alt=\"YouTube\"/\u003e\r\n\u003c/p\u003e\r\n\u003ch1 align=\"center\"\u003e📊 YouTube Analytics Discord Bot 🤖\u003c/h1\u003e\r\n\r\n\u003cp align=\"center\"\u003e\r\n    An \u003ci\u003eawesome\u003c/i\u003e Discord Bot to fetch your YouTube Channel Analytics.\r\n\u003c/p\u003e\r\n\r\n\u003cp align=\"center\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/python-3670A0?style=for-the-badge\u0026logo=python\u0026logoColor=ffdd54\"/\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge\u0026logo=docker\u0026logoColor=white\"/\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/flask-%23000.svg?style=for-the-badge\u0026logo=flask\u0026logoColor=white\"/\u003e\r\n    \u003ca href=\"https://github.com/sponsors/Prem-ium\" target=\"_blank\"\u003e\r\n        \u003cimg src=\"https://img.shields.io/badge/sponsor-30363D?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=#EA4AA\" alt=\"GitHub Sponsor\"/\u003e\r\n    \u003c/a\u003e\r\n    \u003ca href=\"https://www.buymeacoffee.com/prem.ium\" target=\"_blank\"\u003e\r\n        \u003cimg src=\"https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black\" alt=\"Buy Me A Coffee\"/\u003e\r\n    \u003c/a\u003e\r\n\u003c/p\u003e\r\n\r\n---\r\n\r\n## Features 🔧\r\n- Collects data on various metrics, including views, revenue, subscriber growth, \u0026 more.\r\n- Helps analyze channel performance and identify areas for improvement.\r\n- User-friendly Discord Button UI.\r\n- Docker Support.\r\n- Developer Mode.\r\n- Efficient API Service Build Methods \u0026 Fail-Safe(s).\r\n- 24/7 Operation with Replit \u0026 Flask (Dev Mode + Build from Document).\r\n\r\n### Input Formatting \u0026 Bot Commands 🔠\r\nStart every command with `!`. Optional command inputs are denoted with [brackets].\r\n\r\nCheck [Example Output Folder](https://github.com/Prem-ium/youtube-analytics-bot/blob/main/output-examples/README.MD) for output examples.\r\n\r\n- MM / DD Format (MONTH/DATE, assumes current year) or MM / DD / YYYY:\r\n```sh\r\n   !stats 01/01 12/01\r\n   !stats 01/01/2021 12/31/2021\r\n```\r\n\r\n### Text Commands 💬\r\n| Command | Description |\r\n|---------|-------------|\r\n| `!button [startDate] [endDate]` | Open Discord Button UI with all supported commands. |\r\n| `!stats [startDate] [endDate]` | 📅 YouTube Analytics Report Card: Displays views, watch-time, estimated revenue, CPM, ad-impressions, \u0026 more. Defaults to current month if no date range is specified. |\r\n| `!getMonth [month/year]` | Return stats for a specific month. 📆 |\r\n| `!lifetime` | Get lifetime stats. 🧮 |\r\n| `!topEarnings [startDate] [endDate] [Length to Return]` | Get a list of the highest revenue-earning videos on your channel. 💰 |\r\n| `!geo_revenue [startDate] [endDate] [Length to Return]` | Get a list of your top revenue-earning countries. 🌎💰 |\r\n| `!geoReport [startDate] [endDate] [Length to Return]` | Detailed report of views, revenue, CPM, etc., by country. 🌎 |\r\n| `!adtype [startDate] [endDate]` | Get highest-performing ad types within specified time range. 💰 |\r\n| `!demographics [startDate] [endDate]` | Get demographics data (age and gender) of viewers. 👨‍👩‍👧‍👧 |\r\n| `!shares [startDate] [endDate] [Length to Return]` | Return list of top sharing methods for your videos. 📤 |\r\n| `!search [startDate] [endDate] [Length to Return]` | Return YouTube search terms resulting in the most views of your video(s). 🔍 |\r\n| `!os [startDate] [endDate] [Length to Return]` | Return top operating systems watching your videos (ranked by views). 📟 |\r\n| `!playlist [startDate] [endDate] [Length to Return]` | Retrieve your Playlist Report. |\r\n| `!everything [startDate] [endDate]` | Return everything. Call every method and output all available data. ♾️ |\r\n| `!refresh [token]` | Refresh API Token! |\r\n| `!switch` | Switch Dev Mode On/Off. |\r\n| `!help` | Send all Discord commands with explanations. 🦮 |\r\n| `!ping` | Check if the bot is running. |\r\n\r\n### Button Supported Commands 🔘\r\nUpon invoking the `!button` command, these are currently supported with a scene containing interactive buttons:\r\n- Analytics\r\n- Top Revenue Videos\r\n- Top Searched Keywords\r\n- Playlist Stats\r\n- Geographic Data\r\n- OS Statistics\r\n- Traffic Source\r\n- Shares\r\n- Top Geographic-Based Revenue\r\n\r\n---\r\n\r\n## Set-Up \u0026 Installation 🚀\r\nTo use this project, enable Google Cloud Console YouTube Analytics/Data API for your account and create a Discord bot to obtain a Discord token.\r\n\r\n### Google Cloud Console API Setup 🌐\r\n\r\n1. **Create a New Project**\r\n   - Visit [Google Cloud Console](https://console.cloud.google.com/apis) and create a new project.\r\n\r\n2. **Enable APIs and Services**\r\n   - Go to **API \u0026 Services** and select **Enable APIs and Services**.\r\n\r\n3. **Enable YouTube APIs**\r\n   - Search for and enable both **YouTube Data API** and **YouTube Analytics API**.\r\n\r\n4. **Configure OAuth Consent Screen**\r\n   - Return to **API \u0026 Services** page and click on **Credentials**.\r\n   - Select **User Type (External)**, then configure the **OAuth Consent Screen** with these YouTube Analytics-related scopes:\r\n     - `https://www.googleapis.com/auth/youtube.readonly`\r\n     - `https://www.googleapis.com/auth/yt-analytics-monetary.readonly`\r\n\r\n5. **Complete OAuth Configuration**\r\n   - Finish the rest of the OAuth configuration.\r\n\r\n6. **Create OAuth Credentials**\r\n   - Click **Create Credentials**, then select **OAuth Credentials**, followed by **Desktop Application**.\r\n\r\n7. **Download OAuth JSON File**\r\n   - Download the JSON file and name it `CLIENT_SECRET.json`.\r\n   - Place this file in the same folder as your program.\r\n\r\n8. **Create API Key**\r\n   - Create Credentials → API Key.\r\n   - Copy and assign the API key to the `YOUTUBE_API_KEY` environment variable.\r\n\r\nYour Google Cloud Console API is now ready!\r\n\r\n### Discord Bot Setup 🌐\r\n\r\n1. **Create a Discord Application**\r\n   - Go to [Discord Developers](https://discord.com/developers/) and create a new application. Name it \"YouTube Apprise\" or something suitable.\r\n\r\n2. **Configure OAuth2**\r\n   - In your new application, go to the **OAuth2** URL Generator section.\r\n\r\n3. **Select Scopes and Permissions**\r\n   - Under **Scopes**, choose **Bot** and enable the required bot permissions, such as **Send Messages** and **Read Message History**.\r\n\r\n4. **Generate Bot Invite Link**\r\n   - Copy the generated link from the **Permissions** section and use it to add the bot to your server.\r\n\r\n5. *(Optional)* **Customize Profile Picture**\r\n   - Upload an appealing image in the **Rich Presence** section.\r\n\r\n6. **Retrieve Bot Token**\r\n   - In the **Bot** section, obtain the bot token and assign it to the `DISCORD_TOKEN` environment variable.\r\n\r\nYour Discord bot is now set up!\r\n\r\n## Installation 🛠️\r\n\r\nThe bot can be run using Python or Docker.\r\n\r\n### Python Script 🐍\r\n\r\n1. Clone this repository, cd into it, and install dependencies:\r\n   ```sh\r\n   git clone https://github.com/Prem-ium/youtube-analytics-bot\r\n   cd youtube-analytics-bot\r\n   pip install -r requirements.txt\r\n   ```\r\n\r\n2. Configure your `.env` file (see below for options).\r\n3. Run the script:\r\n   ```sh\r\n   python main.py\r\n   ```\r\n\r\n### Docker Setup 🐳\r\n\r\n1. **Generate Credentials JSON File**\r\n   - Run the Python script locally to generate the `credentials.json` file.\r\n\r\n2. **Install Docker**\r\n   - Download and install Docker.\r\n\r\n3. **Configure `.env` File**\r\n   - Configure your `.env` file with the necessary settings.\r\n\r\n4. **Build Docker Image**\r\n   ```sh\r\n   docker build -t youtube-apprise .\r\n   ```\r\n\r\n5. **Start Bot in Docker Container**\r\n   ```sh\r\n   docker run -it --env-file ./.env --restart unless-stopped --name youtube-apprise youtube-apprise\r\n   ```\r\n\r\n6. **Running the Bot**\r\n   - To exit logs without stopping the bot, press `CTRL-p` followed by `CTRL-q`.\r\n\r\n---\r\n## Environment Variables 🖥️\r\n\r\nRefer to the `.env.example` file for options.\r\n\r\n### Required `.env`:\r\n| Environment Variable | Description |\r\n|----------------------|-------------|\r\n| `DISCORD_TOKEN`      | Discord bot token |\r\n| `YOUTUBE_API_KEY`    | YouTube Data API key |\r\n\r\n### Optional `.env`:\r\n| Environment Variable | Description |\r\n|----------------------|-------------|\r\n| `CLIENT_PATH`        | Path to YouTube/Google Client Secret JSON file (defaults to current directory). |\r\n| `DEV_MODE`           | Enable experimental features (requires CLIENT_SECRET). |\r\n| `CLIENT_SECRET`      | Contents of `CLIENT_SECRET.json`. |\r\n| `DISCORD_CHANNEL`    | Channel ID for developer mode. |\r\n| `KEEP_ALIVE`         | Boolean value to keep the bot running (e.g., True for Replit). |\r\n\r\n---\r\n## Experiencing Issues? 🛠️\r\nAs of 9/8/2024, I have disabled the Issues privilege for the general public. For direct support on any bugs or issues, please consider sponsoring me as a GitHub Sponsor under the Silver or Gold tier. \r\n[![Sponsor](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=#white)](https://github.com/sponsors/Prem-ium)\r\n\r\n---\r\n## Donations ❤️\r\nIf you appreciate my work, you can donate via:\r\n\r\n1. **GitHub Sponsors** - [Donate via GitHub Sponsors](https://github.com/sponsors/Prem-ium).\r\n2. **Buy Me A Coffee**: [Donate via Buy Me A Coffee](https://www.buymeacoffee.com/prem.ium).\r\n\r\n---\r\n## License 📝\r\nThis repository is licensed under the [BSD 3-Clause License](https://choosealicense.com/licenses/bsd-3-clause/#).\r\n\r\n---\r\n## Final Remarks ✨\r\nPlease leave a ⭐ if you found this project cool! Made possible by Google's YouTube Analytics/Data APIs. May your analytics skyrocket! 📈\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprem-ium%2Fyoutube-analytics-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprem-ium%2Fyoutube-analytics-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprem-ium%2Fyoutube-analytics-bot/lists"}