PlaylistItems: list Stay organized with collections Save and categorize content based on your preferences.
Returns a collection of playlist items that match the API request parameters. You can retrieve all of the playlist items in a specified playlist or retrieve one or more playlist items by their unique IDs.
Quota impact: A call to this method has aquota cost of 1 unit.
Common use cases
Request
HTTP request
GET https://www.googleapis.com/youtube/v3/playlistItems
Parameters
The following table lists the parameters that this query supports. All of the parameters listed are query parameters.
| Parameters | ||
|---|---|---|
| Required parameters | ||
part | stringThe part parameter specifies a comma-separated list of one or moreplaylistItem resource properties that the API response will include.If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a playlistItem resource, thesnippet property contains numerous fields, including thetitle,description,position, andresourceId properties. As such, if you setpart=snippet, the API response will contain all of those properties.The following list contains the part names that you can include in the parameter value:
| |
| Filters(specify exactly one of the following parameters) | ||
id | stringThe id parameter specifies a comma-separated list of one or more unique playlist item IDs. | |
playlistId | stringThe playlistId parameter specifies the unique ID of the playlist for which you want to retrieve playlist items. Note that even though this is an optional parameter, every request to retrieve playlist items must specify a value for either theid parameter or theplaylistId parameter. | |
| Optional parameters | ||
maxResults | unsigned integerThe maxResults parameter specifies the maximum number of items that should be returned in the result set. Acceptable values are0 to50, inclusive. The default value is5. | |
onBehalfOfContentOwner | stringThis parameter can only be used in a properlyauthorized request.Note: This parameter is intended exclusively for YouTube content partners. The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. | |
pageToken | stringThe pageToken parameter identifies a specific page in the result set that should be returned. In an API response, thenextPageToken andprevPageToken properties identify other pages that could be retrieved. | |
videoId | stringThe videoId parameter specifies that the request should return only the playlist items that contain the specified video. | |
Request body
Do not provide a request body when calling this method.
Response
If successful, this method returns a response body with the following structure:
{"kind":"youtube#playlistItemListResponse","etag":etag,"nextPageToken":string,"prevPageToken":string,"pageInfo":{"totalResults":integer,"resultsPerPage":integer},"items":[playlistItemResource]}Properties
The following table defines the properties that appear in this resource:
| Properties | |
|---|---|
kind | stringIdentifies the API resource's type. The value will be youtube#playlistItemListResponse. |
etag | etagThe Etag of this resource. |
nextPageToken | stringThe token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. |
prevPageToken | stringThe token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. |
pageInfo | objectThe pageInfo object encapsulates paging information for the result set. |
pageInfo.totalResults | integerThe total number of results in the result set. |
pageInfo.resultsPerPage | integerThe number of results included in the API response. |
items[] | listA list of playlist items that match the request criteria. |
Examples
Note: The following code samples may not represent all supported programming languages. See theclient libraries documentation for a list of supported languages.
Go
This code sample calls the API'splaylistItems.list method to retrieve a list of videos uploaded to the channel associated with the request. The code also calls thechannels.list method with themine parameter set totrue to retrieve the playlist ID that identifies the channel's uploaded videos.This example uses theGo client library.
packagemainimport("fmt""log""google.golang.org/api/youtube/v3")// Retrieve playlistItems in the specified playlistfuncplaylistItemsList(service*youtube.Service,partstring,playlistIdstring,pageTokenstring)*youtube.PlaylistItemListResponse{call:=service.PlaylistItems.List(part)call=call.PlaylistId(playlistId)ifpageToken!=""{call=call.PageToken(pageToken)}response,err:=call.Do()handleError(err,"")returnresponse}// Retrieve resource for the authenticated user's channelfuncchannelsListMine(service*youtube.Service,partstring)*youtube.ChannelListResponse{call:=service.Channels.List(part)call=call.Mine(true)response,err:=call.Do()handleError(err,"")returnresponse}funcmain(){client:=getClient(youtube.YoutubeReadonlyScope)service,err:=youtube.New(client)iferr!=nil{log.Fatalf("Error creating YouTube client: %v",err)}response:=channelsListMine(service,"contentDetails")for_,channel:=rangeresponse.Items{playlistId:=channel.ContentDetails.RelatedPlaylists.Uploads// Print the playlist ID for the list of uploaded videos.fmt.Printf("Videos in list %s\r\n",playlistId)nextPageToken:=""for{// Retrieve next set of items in the playlist.playlistResponse:=playlistItemsList(service,"snippet",playlistId,nextPageToken)for_,playlistItem:=rangeplaylistResponse.Items{title:=playlistItem.Snippet.TitlevideoId:=playlistItem.Snippet.ResourceId.VideoIdfmt.Printf("%v, (%v)\r\n",title,videoId)}// Set the token to retrieve the next page of results// or exit the loop if all results have been retrieved.nextPageToken=playlistResponse.NextPageTokenifnextPageToken==""{break}fmt.Println()}}}
.NET
The following code sample calls the API'splaylistItems.list method to retrieve a list of videosuploaded to the channel associated with the request. The code also calls thechannels.list method with themine parameter set totrue to retrieve the playlist ID that identifies the channel's uploadedvideos.This example uses the.NET client library.
usingSystem;usingSystem.IO;usingSystem.Reflection;usingSystem.Threading;usingSystem.Threading.Tasks;usingGoogle.Apis.Auth.OAuth2;usingGoogle.Apis.Services;usingGoogle.Apis.Upload;usingGoogle.Apis.Util.Store;usingGoogle.Apis.YouTube.v3;usingGoogle.Apis.YouTube.v3.Data;namespaceGoogle.Apis.YouTube.Samples{///<summary>///YouTubeDataAPIv3sample:retrievemyuploads.///ReliesontheGoogleAPIsClientLibraryfor.NET,v1.7.0orhigher.///Seehttps://developers.google.com/api-client-library/dotnet/get_started///</summary>internalclassMyUploads{[STAThread]staticvoidMain(string[]args){Console.WriteLine("YouTube Data API: My Uploads");Console.WriteLine("============================");try{newMyUploads().Run().Wait();}catch(AggregateExceptionex){foreach(vareinex.InnerExceptions){Console.WriteLine("Error: "+e.Message);}}Console.WriteLine("Press any key to continue...");Console.ReadKey();}privateasyncTaskRun(){UserCredentialcredential;using(varstream=newFileStream("client_secrets.json",FileMode.Open,FileAccess.Read)){credential=awaitGoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets,//ThisOAuth2.0accessscopeallowsforread-onlyaccesstotheauthenticated//user's account, but not other types of account access.new[]{YouTubeService.Scope.YoutubeReadonly},"user",CancellationToken.None,newFileDataStore(this.GetType().ToString()));}varyoutubeService=newYouTubeService(newBaseClientService.Initializer(){HttpClientInitializer=credential,ApplicationName=this.GetType().ToString()});varchannelsListRequest=youtubeService.Channels.List("contentDetails");channelsListRequest.Mine=true;//RetrievethecontentDetailspartofthechannelresourcefortheauthenticateduser's channel.varchannelsListResponse=awaitchannelsListRequest.ExecuteAsync();foreach(varchannelinchannelsListResponse.Items){//FromtheAPIresponse,extracttheplaylistIDthatidentifiesthelist//ofvideosuploadedtotheauthenticateduser's channel.varuploadsListId=channel.ContentDetails.RelatedPlaylists.Uploads;Console.WriteLine("Videos in list {0}",uploadsListId);varnextPageToken="";while(nextPageToken!=null){varplaylistItemsListRequest=youtubeService.PlaylistItems.List("snippet");playlistItemsListRequest.PlaylistId=uploadsListId;playlistItemsListRequest.MaxResults=50;playlistItemsListRequest.PageToken=nextPageToken;//Retrievethelistofvideosuploadedtotheauthenticateduser's channel.varplaylistItemsListResponse=awaitplaylistItemsListRequest.ExecuteAsync();foreach(varplaylistIteminplaylistItemsListResponse.Items){//Printinformationabouteachvideo.Console.WriteLine("{0} ({1})",playlistItem.Snippet.Title,playlistItem.Snippet.ResourceId.VideoId);}nextPageToken=playlistItemsListResponse.NextPageToken;}}}}}
Ruby
This sample calls the API'splaylistItems.list method to retrieve a list of videos uploadedto the channel associated with the request. The code also calls thechannels.list method with themine parameter set totrue to retrieve the playlist ID that identifies the channel'suploaded videos.This example uses theRuby client library.
#!/usr/bin/rubyrequire'rubygems'gem'google-api-client','>0.7'require'google/api_client'require'google/api_client/client_secrets'require'google/api_client/auth/file_storage'require'google/api_client/auth/installed_app'# This OAuth 2.0 access scope allows for read-only access to the authenticated# user's account, but not other types of account access.YOUTUBE_READONLY_SCOPE='https://www.googleapis.com/auth/youtube.readonly'YOUTUBE_API_SERVICE_NAME='youtube'YOUTUBE_API_VERSION='v3'defget_authenticated_serviceclient=Google::APIClient.new(:application_name=>$PROGRAM_NAME,:application_version=>'1.0.0')youtube=client.discovered_api(YOUTUBE_API_SERVICE_NAME,YOUTUBE_API_VERSION)file_storage=Google::APIClient::FileStorage.new("#{$PROGRAM_NAME}-oauth2.json")iffile_storage.authorization.nil?client_secrets=Google::APIClient::ClientSecrets.loadflow=Google::APIClient::InstalledAppFlow.new(:client_id=>client_secrets.client_id,:client_secret=>client_secrets.client_secret,:scope=>[YOUTUBE_READONLY_SCOPE])client.authorization=flow.authorize(file_storage)elseclient.authorization=file_storage.authorizationendreturnclient,youtubeenddefmainclient,youtube=get_authenticated_servicebegin# Retrieve the "contentDetails" part of the channel resource for the# authenticated user's channel.channels_response=client.execute!(:api_method=>youtube.channels.list,:parameters=>{:mine=>true,:part=>'contentDetails'})channels_response.data.items.eachdo|channel|# From the API response, extract the playlist ID that identifies the list# of videos uploaded to the authenticated user's channel.uploads_list_id=channel['contentDetails']['relatedPlaylists']['uploads']# Retrieve the list of videos uploaded to the authenticated user's channel.next_page_token=''untilnext_page_token.nil?playlistitems_response=client.execute!(:api_method=>youtube.playlist_items.list,:parameters=>{:playlistId=>uploads_list_id,:part=>'snippet',:maxResults=>50,:pageToken=>next_page_token})puts"Videos in list#{uploads_list_id}"# Print information about each video.playlistitems_response.data.items.eachdo|playlist_item|title=playlist_item['snippet']['title']video_id=playlist_item['snippet']['resourceId']['videoId']puts"#{title} (#{video_id})"endnext_page_token=playlistitems_response.next_page_tokenendputsendrescueGoogle::APIClient::TransmissionError=>eputse.result.bodyendendmain
Errors
The following table identifies error messages that the API could return in response to a call to this method. Please see theerror message documentation for more detail.
| Error type | Error detail | Description |
|---|---|---|
forbidden (403) | playlistItemsNotAccessible | The request is not properly authorized to retrieve the specified playlist. |
forbidden (403) | watchHistoryNotAccessible | Watch history data cannot be retrieved through the API. |
forbidden (403) | watchLaterNotAccessible | Items in "watch later" playlists cannot be retrieved through the API. |
notFound (404) | playlistNotFound | The playlist identified with the request'splaylistId parameter cannot be found. |
notFound (404) | videoNotFound | The video identified with the request'svideoId parameter cannot be found. |
required (400) | playlistIdRequired | The subscribe request does not specify a value for the requiredplaylistId property. |
invalidValue (400) | playlistOperationUnsupported | The API does not support the ability to list videos in the specified playlist. For example, you can't list a video in your watch later playlist. |
Try it!
Use theAPIs Explorer to call this API and see the API request and response.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-28 UTC.