'how do i get youtube shorts from youtube api data v3

I want a way to get YouTube shorts for a specific channel from YouTube API. I looked every where and i couldn't find anything.

Currently i can get a playlist ID for all channel videos with this endpoint:

request = youtube.channels().list(
    part="contentDetails",
    id=id
)

I also tried these parameters:

request = youtube.channels().list(
    part="snippet,contentDetails,statistics,brandingSettings",
    id=id
)

So is there a way to get YouTube shorts from a specific channel from YouTube API or any other source if it's available.



Solution 1:[1]

One way of detecting if a YouTube video ID is a Short without even using the API is to try a HEAD HTTP request to the /shorts/ version of the URL and see if it redirects you.

https://www.youtube.com/shorts/hKwrn5-7FjQ is a Short and if you visit that URL, you'll get an HTTP status code of 200 and the URL won't change.

https://www.youtube.com/watch?v=B-s71n0dHUk is not a Short, and if you visit https://www.youtube.com/shorts/B-s71n0dHUk, you get a 303 redirect back to the original URL.

Keep in mind, that this behavior might change down the line, but it works as of May 2022.

Solution 2:[2]

It seems that once again YouTube Data API v3 doesn't provide a basic feature.

I would recommend you to use my open-source YouTube operational API. Indeed by requesting the JSON document https://yt.lemnoslife.com/videos?part=short&id=VIDEO_ID containing item["short"]["available"] boolean, your problem is solved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Joost Schuur
Solution 2