Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Learn how to get the ID of any YouTube video.

How to get the ID of any YouTube Video

This article walks you through how to get the ID of any YouTube video.

How to get a YouTube video ID from a youtube.com page URL

You may be watching the video or just happened to visit a link to a video. The video ID will be located in the URL of the video page, right after the v= URL parameter.

In this case, the URL of the video is: https://www.youtube.com/watch?v=aqz-KE-bpKQ. Therefore, the ID of the video is aqz-KE-bpKQ.

How to get a YouTube video ID from a youtu.be short URL

The youtu.be URLs are created by generating a URL intendend for sharing. They differ slightly from youtube.com URLs because there are no URL parameters. Instead, the video ID is part of the URL itself.

In this case, the URL of the video is: https://youtu.be/aqz-KE-bpKQ. Therefore, the ID of the video is aqz-KE-bpKQ.

How to get a YouTube video ID from an embedded video player

The easiest method is to use the "Stats for nerds" option.

  1. Right click the embedded video player to present a menu.
  2. Select the "Stats for nerds" option in the menu.
  3. Note the "Video ID" property.

Feel free to test on this video player in the following link: http://codepen.io/anon/pen/qReQZL

@Mahdi-Soultana

This comment has been minimized.

Copy link

@Mahdi-Soultana Mahdi-Soultana commented Dec 16, 2020

thank you very much for that !("_")

@Barqain

This comment has been minimized.

Copy link

@Barqain Barqain commented Feb 19, 2021

Hey, i have a question. Is it possible to find the video's ID without knowing where it is originated from?

@jakebellacera

This comment has been minimized.

Copy link
Owner Author

@jakebellacera jakebellacera commented Feb 19, 2021

@Barqain can you elaborate?

@honiibee

This comment has been minimized.

Copy link

@honiibee honiibee commented Feb 19, 2021

Hey, i have a question. Is it possible to find the video's ID without knowing where it is originated from?

I'm not sure in what context you're asking this in but, if you're making a music discord bot and just so happen to use the lavaplayer library, use AudioTrack.getIdentifier(); basically AudioTrack is the currently playing track while identifier is obviously the identifier. But if you're using other libraries/asking this question to do something else than to make a music discord bot, I'm not sure how to help. I hope this helps you and/or other people who are searching for the answer. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment