Pedro Mancheno
Pedro Mancheno

Reputation: 5237

YouTube Data API's video upload privacy settings

I am looking into using the YouTube Data API to upload videos from an iOS app.

I would like these videos to exist in a channel especially made for the App. I would also like all uploaded videos to be private, and only visible through a "secret" URL (just like Dropbox makes your private files available through a public URL). I've heard this is possible in YouTube API.

My question is: When doing the HTTP request to upload a video, is it possible to set the video as private? And if so, is it possible to have a "secret" URL in the response?

Upvotes: 0

Views: 1218

Answers (1)

jlmcdonald
jlmcdonald

Reputation: 13667

Yes ... this is fairly straightforward. The only thing you have to be aware of is the version of the API you want to use. If you use version 2, then when you upload your video you'll be sending along an XML data packet with it that contains the metadata -- this packet must have the <yt:private/> element. All updates to private videos via the API must include that element, or the video will be subsequently set to public. An upload with v2 of the API that is successful will return an Atom feed that contains info about the video, including its id, an embed code, etc., thus fulfilling your 2nd requirement.

In v3 of the API, you'll be sending a json packet to a RESTful endpoint, and must include this attribute when uploading (and on subsequent updates):

"status": {
    "privacyStatus": "private"
  }

Again, it will return a json representation of your video object, which includes the ID and embed code, so you can get the URL for your private videos.

More info can be found here:

https://developers.google.com/youtube/2.0/developers_guide_protocol#Uploading_Videos (for v2)

and here:

https://developers.google.com/youtube/v3/docs/videos/insert (for v3)

Upvotes: 2

Related Questions