Youtube stats badges for your Github profile README
This project is now archived since the YouTube API is now officially supported by Shields.io
- Subscribers badge
- View count badge
- Additional parameters
- Mixing styles
- How to get a Youtube API key
- How to find your YouTube channel ID
- Deploying it on your own
- Contact me
- Support
Quick set up:
Use this URL to get the number of subscribers for your channel as shown above
https://github-readme-youtube-stats.herokuapp.com/subscribers/index.php?id=[YOUR CHANNEL ID]&key=[YOUR API KEY]
Markup for creating the badge as a link to your YouTube channel
<a href="https://www.youtube.com/channel/[YOUR CHANNEL ID]">
<img alt="youtube subscribers" src="https://github-readme-youtube-stats.herokuapp.com/subscribers/index.php?id=[YOUR CHANNEL ID]&key=[YOUR API KEY]"/>
</a>
See below for info on how to get a YouTube API key and your channel's ID.
Quick set up:
https://github-readme-youtube-stats.herokuapp.com/views/index.php?id=[YOUR CHANNEL ID]&key=[YOUR API KEY]
Markup for creating the badge as a link to your YouTube channel
<a href="https://www.youtube.com/channel/[YOUR CHANNEL ID]">
<img alt="youtube views" src="https://github-readme-youtube-stats.herokuapp.com/views/index.php?id=[YOUR CHANNEL ID]&key=[YOUR API KEY]"/>
</a>
See below for info on how to get a YouTube API key and your channel's ID.
Color of the right side of the badge (css named color or hex digits)
Default:
blue
for subscribers,brightgreen
for views
Parameter | Appearance |
---|---|
?color=red |
|
?color=0a8b9d |
Company logo supported by shields.io
Default:
youtube
Parameter | Appearance |
---|---|
?logo=none |
|
?logo=plex |
Color of the logo
Default:
white
Parameter | Appearance |
---|---|
?logoColor=gold |
|
?logoColor=brightgreen |
Style of the badge
Default:
flat-square
Parameter | Appearance |
---|---|
?style=plastic |
|
?style=flat |
|
?style=flat-square |
|
?style=for-the-badge |
|
?style=social |
Label for the badge
Default:
Youtube subscribers
for subscribers,YouTube view count
for views
Parameter | Appearance |
---|---|
?label=Subscribe |
|
?label=View+count |
Color for the left part of the badge
Default:
gray
Parameter | Appearance |
---|---|
?labelColor=magenta |
|
?labelColor=33ab06 |
Display format of the number in the badge
Default:
short
Parameter | Appearance |
---|---|
?format=none |
|
?format=commas |
|
?format=short |
Parameter | Appearance |
---|---|
?style=social&logoColor=black&label=Subscribe |
|
?label=View+count&style=for-the-badge&color=3d3d3d&format=commas |
|
?label=Views&style=for-the-badge&color=red&labelColor=ce4630 |
See shields.io for more info on parameters
- Go to https://console.developers.google.com/project and sign in
- Click "Create Project"
- Name your project and click "Create"
- Click the "Google APIs" link in the top left corner and select your project
- Click "Enable APIs and Services"
- Search for "YouTube Data API"
- Enable "YouTube Data API v3"
- In the left panel select "Credentials"
- Click "Create Credentials", then "API key"
- Copy your API key
- Make sure you are signed into your YouTube channel
- Go to https://www.youtube.com/account_advanced
- You will find your channel ID below your user ID
- Click "Copy" to copy your channel ID
- Go to the channel page for the user you want the ID of
- Press Ctrl+U to open the source code of the page
- Press Ctrl+F on the source code and search for
itemprop="channelId"
- In the
meta
tag, the content attribute will have the channel ID.
If you can, it is preferable to host the files on your own server.
Doing this can lead to better uptime and more control over customization (you can modify the code for your usage).
Also, deploying it on your own means you can place your API key directly into the PHP code so it will not be visible in the URL. This makes it so that your API key cannot get used by other people without your knowledge.
You can deploy the PHP files on any website server with PHP installed or as a Heroku app.
💙 If you like this project, give it a ⭐ and share it with friends!
Made with ❤️ and PHP