0xSina
0xSina

Reputation: 21583

Get video's privacy settings using Youtube API

In YouTube video manager, I have the option to set a video to a) Public b) Private and c) Unlisted.

Using the YouTube API, is it possible to find out what the setting of a video is currently?

Upvotes: 5

Views: 5181

Answers (2)

Jeff Posnick
Jeff Posnick

Reputation: 56144

It depends.

I'm going to answer in the context of the YouTube Data API v3, which is the most recent release. There are analogous methods in the older v1 and v2 of the API.

If you're authenticated as the owner of the video, you can make a videos.list(part=status, id=VIDEO_ID) call, and the video's status will be returned in the video.status.privacyStatus property.

If you're not authenticated as the owner of the video, you can make the same videos.list() call, but if the video is private you won't get back a response. If the video is public or unlisted you will get back a video resource, and you could check video.status.privacyStatus to see what the exact privacy level is.

google_api_key = 'YOUR_API_KEY'
video_ids = 'VIDEO_ID_1,VIDEO_ID_2'

# Construct the API URL to retrieve video statuses for multiple videos
video_url = f'https://youtube.googleapis.com/youtube/v3/videos?id={video_ids}&part=status&key={google_api_key}'

Upvotes: 11

Gavindra Kalikapersaud
Gavindra Kalikapersaud

Reputation: 547

GET https://www.googleapis.com/youtube/v3/videos?part=status&id=giOAHm-dRaM&key={YOUR_API_KEY}

Use the link above to get the privacy settings of a video

Upvotes: 3

Related Questions