The YouTube Data API (v3) is an experimental API version, which means it is still in development. We'll be adding many more features to the API while it is still an experimental version. Until the experimental label is removed, however, the Deprecation Policy for YouTube APIs won't apply to this version as discussed in the API Terms of Service.
Adds a resource to a playlist. Try it now.
Request
HTTP request
POST https://www.googleapis.com/youtube/v3/playlistItems
Authorization
This request requires authorization with at least one of the following scopes (read more about authentication and authorization).
Scope |
---|
https://www.googleapis.com/auth/youtubepartner |
https://www.googleapis.com/auth/youtube |
Parameters
Parameter name | Value | Description |
---|---|---|
Required parameters | ||
part |
string |
The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include.The part names that you can include in the parameter value are snippet and contentDetails . |
Request body
Provide a playlistItems resource in the request body. For that resource:
-
You must specify a value for these properties:
snippet.playlistId
snippet.resourceId
-
You can set values for these properties:
snippet.playlistId
snippet.position
snippet.resourceId
contentDetails.startAt
contentDetails.endAt
contentDetails.note
Response
If successful, this method returns a PlaylistItems resource in the response body.
Errors
The table below identifies error messages that the API could return in response to a call to this method.
Error name | Reason | Likely cause |
---|---|---|
invalidValue |
invalidPlaylistItemPosition | The request attempts to set the playlist item's position to an invalid or unsupported value. Check the value of the position property in the resource's snippet . |
required |
channelIdRequired | The request does not specify a value for the required channelId property. |
required |
resourceIdRequired | The request must contain a resource in which the snippet object specifies a resourceId . |
required |
playlistIdRequired | The request does not specify a value for the required playlistId property. |
notFound |
playlistNotFound | The playlist identified with the request's playlistId parameter cannot be found. |
notFound |
videoNotFound | The video that you are trying to add to the playlist cannot be found. Check the value of the videoId property to ensure that it is correct. |
invalidValue |
invalidResourceType | The type specified for the resource ID is not supported for this operation. The resource ID identifies the item being added to the playlist &ndash.; e.g. youtube#video . |
duplicate |
videoAlreadyInPlaylist | The playlist already contains the maximum allowed number of items. |
duplicate |
videoAlreadyInPlaylist | The video that you are trying to add to the playlist is already in the playlist. |
Try it!
Use the API Explorer to call this method on live data and see the API request and response.