How to Get your YouTube last video uploaded with Google API

Asked Sep 3, 2022·2 replies·Last activity 3 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

THIS IS A TUTORIAL FOR GET YOUR OWN COMMAND OF:
- Get your last video uploaded to YouTube

Things before to start:
1.- This link is actually generated by Google to get a JSON from a query(search) on YouTube:

https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=CHANNEL_I…

Let me explaint important parameters:
channelId=CHANNEL_ID - This URL Parameter is the channel ID, you can get it from here:
> See your YouTube Channel ID here

key=USER_API_KEY - This is your API Credential Auth, You can get it from your developer account of Google in this link:
> Get Your Credential Here

2.- After knowing the above URL, and get both (ID and API key) you need to check the URL with your information:
- Simply replace parameter value from key* and channelId.*

This could happen

To fix this you have to go to the link that this page refers to and enable YouTube API

Then your link will work:

The most important thing we need from this JSON is the videoId value so...

3.- Shorten our JSON link

  • We have to shorten our JSON link first:

I recommend this shortener

(for testing reasons my link was changed before)

  • After getting our JSON shortened link we have to make the next step:

4.- Creating the Nightbot command

!addcom !video $(eval const urlJSON = '$(urlfetch json YOUR_LINK )';
const j = JSON.parse(urlJSON);
const json = j.items[0].id.videoId;
"/me Heyo! VoHiYo This is my last video from youtube, check it out! http://y2u.be/" + json)

YOUR_LINK - change it for your link

5.- Enjoy!

2 replies

That was all! This command get your last video from youtube so, no neccesary updates to the command.
Good luck for everybody 😃

command.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.png