This document is intended for programmers who are writing client applications that interact with YouTube. The document supplements the information in the developer's guide protocol as well as the language-specific guides for Java, PHP and Python developers.
This document lists the different types of feeds that you can retrieve using the YouTube Data API. It also provides diagrams that explain how to navigate between different feeds – for example, the diagrams show that a user's playlists feed contains URLs that reference individual playlists and data such as a user's profile. The diagrams also indicate how you would navigate from one feed to another. Finally, this document defines the parameters used in YouTube Data API requests as well as the XML tags returned in an API response. For Java, PHP and Python developers, the XML tags may correspond directly to a property of a VideoEntry, ProfileEntry or other type of object.
The YouTube Data API retrieves search results from a specially optimized search index. The index is designed to include new videos as quickly as possible while ensuring high performance even under heavy API server loads. Please note that there may be delays between the time that a video is uploaded or updated and the time the new information is included in video feeds. The following list provides expected data latencies for various API functions:
The YouTube Data API offers different views, or projections, of the data available in the API. The Developer's Guide and the examples in this document all use the api projection, which supports all of the tags defined in the XML element definitions section of this document.
Most developers who are using this documentation will use the api projection. However, if you are developing applications for mobile devices, you can substitute "mobile" for "api" in any of the sample requests described in the API documentation. Similarly, if you prefer to use the base projection, which is well suited to feed readers, you can substitute "base" for "api" in any of the sample requests described in the API documentation.
The following table describes the supported projection values:
| Projection Name | Description |
|---|---|
api |
This projection yields feeds that support all of the XML elements defined in this document, including all relevant tags in the YouTube and Media RSS schemas. All properties contain plain text, not HTML. |
base |
This projection yields basic Atom feeds without any extension elements. Its <atom:summary> and <atom:content> properties contain entity-encoded HTML. |
mobile |
This projection supports most of the XML elements defined in this document and should be used when by developers building applications for mobile devices. |
You can retrieve the following types of feeds from the YouTube Data API:
The API allows you to retrieve any of these feeds without authentication. However, in some cases, an authenticated request may retrieve additional information. For example, if you submit an authenticated request for a user's own list of uploaded videos, the feed will contain private videos as well as rejected or pending videos. Private, pending and rejected videos would not appear in a response to an unauthenticated API request or a request for videos uploaded by someone other than the currently authenticated user.
To add or update videos, playlists, subscriptions, ratings, comments or any other entity, you must authenticate all requests, including GET requests, using a developer key and either AuthSub or ClientLogin authentication.
Video feeds return a collection of video entries. In turn, each video entry contains information about a specific video in the video feed's result set. The YouTube Data API allows you to retrieve the following types of video feeds:
The API returns a videos feed in response to a request to search for videos. A videos feed contains a maximum of 999 entries. To retrieve search results, send an API request to the following URL:
http://gdata.youtube.com/feeds/projection/videos
Search requests can use any of the query parameters defined in the Query parameters reference section of this document except for the time parameter. For example, the following URL requests all videos related to the query "skateboarding dog," starting with the 21st search result and returning 10 results:
http://gdata.youtube.com/feeds/api/videos?
vq=skateboarding+dog
&start-index=21
&max-results=10
The related videos feed contains a list of videos that are related to another video. YouTube algorithmically selects the set of related videos.
Each video entry in an API response contains a series of <link> tags. The <link> tag that has a rel attribute value of http://gdata.youtube.com/schemas/2007/#video.related identifies the URL for retrieving other videos related to that video entry. (The <link> tag's href attribute identifies the URL.)
<link rel="http://gdata.youtube.com/schemas/2007#video.related"
type="application/atom+xml"
href="http://gdata.youtube.com/feeds/api/videos/ZTUVgYoeN_b/related"/>
Related videos feeds contain a maximum of 100 videos.
A video responses feed contains videos that have been explicitly designated as a response to another video. A video can be designated as a video response to exactly one other video, and some videos may not have any video responses.
Each video entry in an API response contains a series of <link> tags. The <link> tag that has a rel attribute value of http://gdata.youtube.com/schemas/2007/#video.responses identifies the URL for retrieving video responses for that video entry. (The <link> tag's href attribute identifies the URL as shown in the following example.)
<link rel="http://gdata.youtube.com/schemas/2007#video.responses"
type="application/atom+xml"
href="http://gdata.youtube.com/feeds/api/videos/ZTUVgYoeN_b/responses"/>
Standard feeds contain lists of videos that either reflect YouTube user behavior, such as top-rated and most viewed video feeds, or were selected by YouTube staff, such as recently featured and mobile video feeds. Many of these feeds are shown on the Videos tab of the YouTube website.
To retrieve a standard feed, send an HTTP GET request to the URL associated with that feed. The following table identifies the URL associated with each standard feed:
| Name | Feed Id | URL and Description |
|---|---|---|
| Top rated | top_rated | URL: http://gdata.youtube.com/feeds/api/standardfeeds/top_rated Description: This feed contains the most highly rated YouTube videos. |
| Top favorites | top_favorites | URL: http://gdata.youtube.com/feeds/api/standardfeeds/top_favorites Description: This feed contains videos most frequently flagged as favorite videos. |
| Most viewed | most_viewed | URL: http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed Description: This feed contains the most frequently watched YouTube videos. |
| Most popular | most_popular | URL: http://gdata.youtube.com/feeds/api/standardfeeds/most_popular Description: This feed contains the most popular YouTube videos, selected using an algorithm that combines many different signals to determine overall popularity. |
| Most recent | most_recent | URL: http://gdata.youtube.com/feeds/api/standardfeeds/most_recent Description: This feed contains the videos most recently submitted to YouTube. |
| Most discussed | most_discussed | URL: http://gdata.youtube.com/feeds/api/standardfeeds/most_discussed Description: This feed contains the YouTube videos that have received the most comments. |
| Most linked | most_linked | URL: http://gdata.youtube.com/feeds/api/standardfeeds/most_linked Description: This feed contains the YouTube videos that receive the most links from other websites. |
| Most responded | most_responded | URL: http://gdata.youtube.com/feeds/api/standardfeeds/most_responded Description: This feed contains YouTube videos that receive the most video responses. |
| Recently featured | recently_featured | URL: http://gdata.youtube.com/feeds/api/standardfeeds/recently_featured Description: This feed contains videos recently featured on the YouTube home page or featured videos tab. |
| Videos for mobile phones | watch_on_mobile | URL: http://gdata.youtube.com/feeds/api/standardfeeds/watch_on_mobile Description: This feed contains videos suitable for playback on mobile devices. |
The API enables you to retrieve region-specific standard feeds by inserting a region ID in the standard feed URL. The following URL demonstrates the format of the URLs that you would use to retrieve region-specific standard feeds:
http://gdata.youtube.com/feeds/api/standardfeeds/regionID/feedID
For example, to retrieve a list of the top-rated videos in Japan, you would send an HTTP GET request to the following URL:
http://gdata.youtube.com/feeds/api/standardfeeds/JP/top_rated
Note: Region-specific versions of the watch_on_mobile standard feed are not available.
The following table identifies the countries for which the YouTube Data API supports localized feeds and the regionID associated with each country:
| Country | Region ID |
|---|---|
| Australia | AU |
| Brazil | BR |
| Canada | CA |
| France | FR |
| Germany | DE |
| Great Britain | GB |
| Holland | NL |
| Hong Kong | HK |
| Ireland | IE |
| Italy | IT |
| Japan | JP |
| Mexico | MX |
| New Zealand | NZ |
| Poland | PL |
| Russia | RU |
| South Korea | KR |
| Spain | ES |
| Taiwan | TW |
| United States | US |
All standard feeds support the time query parameter, which allows you to restrict the feed to only contain relevant results from the previous day, week or month. For example, to retrieve top-rated videos from the previous day, you would send an HTTP GET request to the following URL:
http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today
The favorite videos feed retrieves a list of videos that a particular user has explicitly flagged as a favorite video. On YouTube's website, a user can view and edit his list of favorite videos on his account page, and a user's favorite videos are also publicly visible to other YouTube users.
To request a feed of the currently logged-in user's favorite videos, send an HTTP GET request to the following URL. Note: For this request, you must provide an authentication token in the Authorization HTTP request header. The authentication token enables YouTube to identify the user.
http://gdata.youtube.com/feeds/api/users/default/favorites
To request a feed of another user's favorite videos, send an HTTP GET request to the following URL. Note that this request does not require authentication.
http://gdata.youtube.com/feeds/api/users/username/favorites
In the URL above, you must replace the text username with the user's YouTube username.
The favorites feed returns a maximum of 50 entries. We strongly recommend that you paginate the feed by using the start-index and max-results query parameters to optimize the response size and latency. The recommended value for max-results is 10, yielding a response that contains about 60KB of data.
A playlist feed contains information about a collection of up to 200 videos that can be viewed sequentially. A user can view and edit his list of playlists on his account page, and a user's playlists are also publicly visible to other YouTube users. In addition, users can modify an individual playlist by adding or removing videos from the playlist.
A playlist can be public or private. The API allows you to retrieve public playlists with or without authentication. However, you can only retrieve a private playlist for a user who is properly authenticated and authorized to view the playlist.
Before retrieving a playlist feed, you will probably first retrieve a user's playlists feed, which contains a list of the playlists created by that user. Within the user's playlists feed, each entry describes a single playlist. (On the other hand, a playlist feed describes the individual videos that comprise a single playlist.) Each entry in the user's playlists feed contains a <gd:feedLink> tag that identifies the URL that allows you to retrieve the feed for that playlist.
<gd:feedLink rel='http://gdata.youtube.com/schemas/2007#playlist'
href='http://gdata.youtube.com/feeds/api/playlists/PLAYLIST_ID'/>
Note: The actual URL will contain an ID that uniquely identifies the playlist in place of the term PLAYLIST_ID.
A user's playlists feed contains a list of the playlists created by that user. If you are requesting the playlists feed for the currently authenticated user, the feed will contain both public and private playlists. However, if you send an unauthenticated request or request playlists created by someone other than the currently authenticated user, the feed will only contain public playlists.
In a playlists feed, each entry contains information about a single playlist, including the playlist title, description and author. The <gd:feedLink> tag in the entry identifies the URL that allows you to retrieve the playlist feed, which specifies information about the videos in the playlist.
To request a feed of the currently logged-in user's playlists, send an HTTP GET request to the following URL. Note: For this request, you must provide an authentication token in the Authorization HTTP request header. The authentication token enables YouTube to identify the user.
http://gdata.youtube.com/feeds/api/users/default/playlists
To request a feed of another user's playlists, send an HTTP GET request to the following URL. Note that this request does not require authentication.
http://gdata.youtube.com/feeds/api/users/username/playlists
In the URL above, you must replace the text username with the user's YouTube username.
A user's subscriptions feed contains a list of the channels, favorite video lists and search queries to which the user has subscribed.
To request a feed of the currently logged-in user's subscriptions, send an HTTP GET request to the following URL. Note: For this request, you must provide an authentication token in the Authorization HTTP request header. The authentication token enables YouTube to identify the user.
http://gdata.youtube.com/feeds/api/users/default/subscriptions
To request a feed of another user's subscriptions, send an HTTP GET request to the following URL. Note that this request does not require authentication.
http://gdata.youtube.com/feeds/api/users/username/subscriptions
In the URL above, you must replace the text username with the user's YouTube username.
In a subscriptions feed, each entry contains information about a single subscription. Each entry contains the following key tags:
The <gd:feedLink> tag in the entry identifies the URL that allows you to retrieve videos for the subscription.
For one of the <category> tags in the entry, the scheme attribute value will be http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat. That tag's term attribute indicates whether the entry describes a subscription to a channel (term="channel"), another user's favorite videos list (term="favorites"), or to videos that match specific keywords (term="query").
If the subscription is to another user's channel or list of favorite videos, the <yt:username> tag will identify the user who owns the channel or favorite video list.
If the subscription is to a keyword query, the <yt:queryString> element will contain the subscribed-to query term.
Each video entry contains a <gd:comments> tag, which encapsulates the URL to which you will send API requests to retrieve or append to the list of comments for the video. The sample XML below shows how this URL appears in a video feed:
<feed>
<entry>
...
<media:group>
...
</media:group>
<gd:comments>
<gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments'/>
</gd:comments>
</entry>
</feed>
Each entry in the comments feed contains information about a single comment. Each comment has an author, a title, content, and an in-reply-to link.
A user profile contains information that the user lists on his YouTube profile page.
To request the currently logged-in user's profile, send an HTTP GET request to the following URL. Note: For this request, you must provide an authentication token in the Authorization HTTP request header. The authentication token enables YouTube to identify the user.
http://gdata.youtube.com/feeds/api/users/default
To request another user's profile, send an HTTP GET request to the following URL. Note that this request does not require authentication.
http://gdata.youtube.com/feeds/api/users/username
In the URL above, you must replace the text username with the user's YouTube username. Depending on the type of YouTube API response you are working with, usernames will appear in either the <name> tag or the <yt:username> tag.
Note: Whereas many API responses contain information about the response feed and a list of entries, the request to retrieve a profile only contains a single entry. As such, the root tag in the API response for this request is <entry>.
A user's contacts feed lists all of the contacts for a specified user.
To request the currently logged-in user's contact list, send an HTTP GET request to the following URL. Note: For this request, you must provide an authentication token in the Authorization HTTP request header. The authentication token enables YouTube to identify the user.
http://gdata.youtube.com/feeds/api/users/default/contacts
To request another user's contact list, send an HTTP GET request to the following URL. Note that this request does not require authentication.
http://gdata.youtube.com/feeds/api/users/username/contacts
In the URL above, you must replace the text username with the user's YouTube username.
Contacts can be classified as either Friends or Family.
Every feed and entry uses <link rel="relationshipID"> tags and <gd:feedLink rel="relationshipID"> elements that contain links to related feeds or entries. Generally, a <link> tag identifies a relationship between related, but not nested, feeds. On the other hand, a <gd:feedLink> tag identifies a feed that might otherwise be nested within the original response except for the fact that actually nesting the feeds would make the feed too large.
These tags identify URLs that enable you to implement API functionality without hardcoding URLs into your application. For example, the following <link> element, which might appear in a video entry, provides a link to a feed that contains video responses for that entry.
<link rel="http://gdata.youtube.com/schemas/2007#video.responses"
type="application/atom+xml"
href="http://gdata.youtube.com/feeds/api/videos/UwOA8H5Vaak/responses"/>
Similarly, the following <gd:feedLink> element might appear in a user profile entry. This tag identifies the URL from which you would retrieve a feed of that user's contacts.
<gd:feedLink
rel="http://gdata.youtube.com/schemas/2007#user.contacts"
href="http://gdata.youtube.com/feeds/api/users/liz/contacts"/>
The use cases in the Developer's Guide attempt to explain how to navigate between the different feeds. In addition, the following diagram illustrates the interconnections between the YouTube Data API feeds. Each solid arrow denotes a <link> element, and each dotted arrow denotes a <gd:feedLink> element. Each blue arrow denotes a <link rel="related"> link. A subscription entry may contain a <gd:feedLink> tag pointing to one of several types of feeds depending on the type of subscription that the entry describes.
The last term in each circle is the Google Data "kind" of the entries in a given feed. For example, a subscriptions feed has entries of the "subscription" kind, and a "videos" feed contains entries of the "video" kind.

This section explains the HTTP response codes that YouTube returns for different types of API requests.
A 200 response code indicates that YouTube successfully handled an HTTP GET request to retrieve a feed.
A 400 response code identifies a bad request. For example, you will receive a 400 response code if you submit a request to the wrong URL or include an unsupported or nonexistent parameter in your request. The API response content will explain the reason wny the API returned a 400 response code.
Browser-based uploading
200 - The API returns a 200 response code if you successfully upload a video's metadata. The Uploading video metadata section of the developer's guide explains this process in more detail.
301 - When the user uploads his actual video file directly to YouTube via the form on your site, YouTube will send a 301 redirect to the user's browser, causing the browser to request and load the URL that you had specified with the nexturl parameter in your upload form. (Learn more about the upload form.) YouTube will append the following variables to that URL, and you need to extract those variables to provide the appropriate user experience:
Direct uploading
201 - The API returns a 201 response code if your video uploads successfully.
400 (Bad request) - A 400 response code indicates that a request was poorly formed or contained invalid data. For example, the API would return a 400 response code if your request contained poorly formed XML or if you tried to submit keywords containing invalid characters.
The API returns the following response codes for requests to add resources such as ratings, comments, video responses, complaints, favorite videos, playlists, playlist entries, subscriptions and contacts.
201 (Created) - A 201 response code indicates that an HTTP POST request to add a rating, comment, complaint, video response, subscription, playlist or contact was successfully handled.
400 (Bad request) - A 400 response code indicates that a request was poorly formed or contained invalid data. For example, the API would return a 400 response code if your request contained poorly formed XML or if you tried to submit a rating of "16" for a video since the rating must be between 1 and 5. The API response content will explain the reason wny the API returned a 400 response code.
The API returns the following response codes for requests to update resources such as videos, playlists, playlist entries and contacts:
200 (OK) - A 200 response code indicates that YouTube successfully handled an HTTP PUT request to update a resource.
400 (Bad request) - A 400 response code indicates that a request was poorly formed or contained invalid data. The API response content will explain the reason wny the API returned a 400 response code.
The API returns the following response codes for requests to delete resources such as videos, video responses, favorite videos, playlists, playlist entries, subscriptions and contacts.
200 (OK) - A 200 response code indicates that YouTube successfully handled an HTTP DELETE request to delete a resource.
401 (Not authorized) - A 401 response code indicates that a request did not contain an Authorization header, that the format of the Authorization header was invalid, or that the authentication token supplied in the header was invalid.
403 (Forbidden) - A 403 response code indicates that you have submitted a request that is not properly authenticated for the requested operation.
404 (Not found) - A 404 response code indicates that you have tried to modify a resource that does not exist. For example, you would receive a 404 response code if you tried to delete a subscription but you specified the wrong URL for the subscription.
The API may also return the following response codes:
401 (Not authorized) - A 401 response code indicates that a request did not contain an Authorization header, that the format of the Authorization header was invalid, or that the authentication token supplied in the header was invalid.
403 (Forbidden) - A 403 response code indicates that you have submitted a request that is not properly authenticated for the requested operation.
500 (Internal error) - A 500 response code indicates that YouTube experienced an error handling a request. You could retry the request at a later time.
501 (Not implemented) - A 501 response code indicates that you have tried to execute an unsupported operation, such as retrieving a list of ratings or updating a complaint.
503 (Service unavailable) - A 503 response code indicates that the YouTube Data API service can not be reached. You could retry your request at a later time.
To search for videos, submit an HTTP GET request to the following URL, appending the appropriate query parameters to your request:
http://gdata.youtube.com/feeds/api/videos
For example, a request to the following URL searches for the second set of 10 recently uploaded videos matching the query term "football" but not matching the query term "soccer":
http://gdata.youtube.com/feeds/api/videos?
vq=football+-soccer
&orderby=published
&start-index=11
&max-results=10
The YouTube Data API supports the following standard Google Data query parameters.
| Name | Definition |
|---|---|
| alt | The alt parameter specifies the format of the feed to be returned. Valid values for this parameter are atom, rss and json. The default value is atom and this document only explains the format of Atom responses. |
| author | The author parameter restricts the search to videos uploaded by a particular YouTube user. The Videos uploaded by a specific user section discusses this parameter in more detail. |
| max-results | The max-results parameter specifies the maximum number of results that should be included in the result set. This parameter works in conjunction with the start-index parameter to determine which results to return. For example, to request the second set of 10 results – i.e. results 11-20 – set the max-results parameter to 10 and the start-index parameter to 11. The default value of this parameter for all Google Data APIs is 25, and the maximum value is 50. However, for displaying lists of videos, we recommend that you set the max-results parameter to 10. |
| start-index | The start-index parameter specifies the index of the first matching result that should be included in the result set. This parameter uses a one-based index, meaning the first result is 1, the second result is 2 and so forth. This parameter works in conjunction with the max-results parameter to determine which results to return. For example, to request the second set of 10 results – i.e. results 11-20 – set the start-index parameter to 11 and the max-results parameter to 10. |
Please see the Google Data APIs Protocol Reference for more information about standard Google Data API functionality or about these specific parameters.
In addition to the standard Google Data query parameters, the YouTube Data API defines the following API-specific query parameters. These parameters are only available on video and playlist feeds.
| Name | Definition | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| vq | The vq parameter, which is only supported for video feeds, specifies a search query term. YouTube will search all video metadata for videos matching the term. Video metadata includes titles, keywords, descriptions, authors' usernames, and categories. Note that any spaces, quotes or other punctuation in the parameter value must be URL-escaped. To search for an exact phrase, enclose the phrase in quotation marks. For example, to search for videos matching the phrase "spy plane", set the vq parameter to %22spy+plane%22. Your request can also use the Boolean NOT (-) and OR (|) operators to exclude videos or to find videos that are associated with one of several search terms. For example, to search for videos matching either "boating" or "sailing", set the vq parameter to boating%7Csailing. (Note that the pipe character must be URL-escaped.) Similarly, to search for videos matching either "boating" or "sailing" but not "fishing", set the vq parameter to "boating&7Csailing+-fishing". |
||||||||
| orderby | The orderby parameter, which is only supported for video feeds, specifies the value that will be used to sort videos in the search result set. Valid values for this parameter are relevance, published, viewCount and rating. In addition, you can request results that are most relevant to a specific language by setting the parameter value to relevance_lang_languageCode, where languageCode is an ISO 639-1 two-letter language code. (Use the values zh-Hans for simplified Chinese and zh-Hant for traditional Chinese.) In addition, please note that results in other languages will still be returned if they are highly relevant to the search query term. The default value for this parameter is relevance for a search results feed. Note: For a playlist feed, the default ordering is based on the position of each video in the playlist. For a user's playlists or subscriptions feed, the default ordering is arbitrary. |
||||||||
| client | The client parameter is an alphanumeric string that identifies your application. The client parameter is an alternate way of specifying your client ID. You can also use the X-GData-Client request header to specify your client ID. Your application does not need to specify your client ID twice by using both the client parameter and the X-GData-Client request header, but it should provide your client ID using at least one of those two methods. | ||||||||
| format | The format parameter specifies that videos must be available in a particular video format. Your request can specify any of the following formats:
| ||||||||
| location | The location parameter restricts the search to videos that have a geographical location specified in their metadata. The parameter does not require a value and its presence serves to restrict the search results to videos with a geographical location. This parameter does not enable you to find videos with a specific geographical location. This parameter can be used with all video feeds. A video that has a geographical location will have a <georss:where> tag in its metadata. | ||||||||
| lr | The lr parameter restricts the search to videos that have a title, description or keywords in a specific language. Valid values for the lr parameter are ISO 639-1 two-letter language codes. You can also use the values zh-Hans for simplified Chinese and zh-Hant for traditional Chinese. This parameter can be used when requesting any video feeds other than standard feeds. | ||||||||
| racy | The racy parameter allows a search result set to include restricted content as well as standard content. Valid values for this parameter are include and exclude. By default, restricted content is excluded. Feed entries for videos that contain restricted content will contain the <media:rating> element. | ||||||||
| restriction | The restriction parameter identifies the IP address that should be used to filter videos that can only be played in specific countries. We recommend that you always use this parameter to specify the end user's IP address. (By default, the API filters out videos that cannot be played in the country from which you send API requests. This restriction is based on your client application's IP address.) To request videos playable from a specific computer, include the restriction parameter in your request and set the parameter value to the IP address of the computer where the videos will be played – e.g. restriction=255.255.255.255.To request videos that are playable in a specific country, include the restriction parameter in your request and set the parameter value to the ISO 3166 two-letter country code of the country where the videos will be played – e.g. restriction=DE. |
||||||||
| time | The time parameter, which is only supported for the top_rated, top_favorites, most_viewed, most_popular, most_discussed, most_linked and most_responded standard feeds, restricts the search to videos uploaded within the specified time. Valid values for this parameter are today (1 day), this_week (7 days), this_month (1 month) and all_time. The default value for this parameter is all_time. |
YouTube videos can be categorized in the following ways:
Each video can be associated with one predefined YouTube category, such as Comedy, Music, News or Sports. A video's category is identified by the <media:category> tag and by the <category> tag for which the value of the scheme attribute is http://gdata.youtube.com/schemas/2007/categories.cat.
Each video can be associated with an arbitrary number of keywords, which are also known as tags. A video's tags are identified using the <media:keywords> tag in API requests and responses. Keyword tags are also identified by <category> tags for which the value of the scheme attribute is http://gdata.youtube.com/schemas/2007/keywords.cat.
Each video can also be associated with an arbitrary number of developer tags. You can search for videos using developer tags. However, developer tags are not displayed on YouTube's website and you should not display them in your application. A video's developer tags are identified in <media:category> and <category> tags for which the value of the scheme attribute is http://gdata.youtube.com/schemas/2007/developertags.cat.
Please see the developer's guide for more information about assigning developer tags.
Use the following URL to retrieve videos that are in a specific category or that are labeled with a specific keyword or developer tag:
http://gdata.youtube.com/feeds/api/videos/-/category_or_tag
The hyphen (-) in the URL is a standard Google Data API notation that indicates that the rest of the URL consists of a series of one or more tags. The following guidelines provide more detail about requesting videos associated with particular categories or tags:
If your request specifies a category and one or more keywords or if your request does not specify a category but does specify multiple keywords, separate each individual category and keyword name with a forward slash. For example, you would use the following URL to request videos related to the keywords "bass" and "fishing":
http://gdata.youtube.com/feeds/api/videos/-/bass/fishing
Your request can use the Boolean NOT (-) and OR (|) operators to exclude videos or to find videos that are associated with one of several keywords or categories. For example, if you wanted to display videos related to "bass" and "music", the most effective search might be for videos associated with the keyword "bass" but not associated with the keywords "fish" or "fishing" as shown in the example below. (Searching for videos associated with the "Music" category and the keyword "bass" might exclude instructional videos about how to play bass.)
http://gdata.youtube.com/feeds/api/videos/-/bass/-fish/-fishing
The following example shows how to search for baseball videos that are in either the "Sports" or "Howto" categories. The category names are separated by the value "%7C", which represents a URL-encoded pipe (|) character specifying that the video must be associated with one of the two categories:
http://gdata.youtube.com/feeds/api/videos/-/Sports%7CHowto/baseball
Capitalize the names of categories and lowercase the names of keywords. For example, the following query identifies videos associated with the keyword "comedy" that are not in the "Comedy" category:
http://gdata.youtube.com/feeds/api/videos/-/comedy/-Comedy
If you are generating category or keyword searches automatically based on the information in an API response, specify the schema as part of the category name to clearly differentiate YouTube categories from keyword tags or developer tags. The following URLs demonstrate how to specify the schema in the category name. (Note that each URL should actually appear on one line but has been split into multiple lines for printing purposes.)
Categories: http://gdata.youtube.com/feeds/api/videos/-/ %7Bhttp%3A%2F%2Fgdata.youtube.com%2Fschemas%2F2007 %2Fcategories.cat%7DNews Keywords: http://gdata.youtube.com/feeds/api/videos/-/ %7Bhttp%3A%2F%2Fgdata.youtube.com%2Fschemas%2F2007 %2Fkeywords.cat%7Ddog Developer tags: http://gdata.youtube.com/feeds/api/videos/-/ %7Bhttp%3A%2F%2Fgdata.youtube.com%2Fschemas%2F2007 %2Fdevelopertags.cat%7Dexample.com
Always specify the schema, as explained in the previous item, if you are requesting videos associated with a particular developer tag.
The YouTube Data API uses tags from multiple XML schemas. The following table identifies the different schemas that the API uses, the namespace prefix associated with each schema, and the namespace URL for each schema.
| Schema | Namespace Prefix | Schema URL |
|---|---|---|
| Atom Syndication Format | [None] - this is the default namespace | http://www.w3.org/2005/Atom |
| Open Search Schema | openSearch | http://a9.com/-/spec/opensearchrss/1.0/ |
| Media RSS | media | http://search.yahoo.com/mrss/ |
| YouTube XML Schema | yt | http://gdata.youtube.com/schemas/2007 |
| Google Data Schema | gd | http://schemas.google.com/g/2005 |
| GeoRSS | georss | http://www.georss.org/georss |
| Geography Markup Language | gml | http://www.opengis.net/gml |
| Atom Publishing Protocol | app | http://www.w3.org/2007/app |
The following tables define the XML tags from each of these schemas that appear in YouTube Data API requests and responses. Each table contains the definition for a single tag, and tags are listed in alphabetical order by schema.
Certain symbols may be displayed next to some child tags in the definitions below. These symbols, and their meanings, are:
The <author> tag contains information about the YouTube user who owns a piece of video content, a subscription, a list of favorite videos, a contact or other entity.
<author>
The <category> tag specifies the category to which the entry belongs.
When the <category> tag appears as a subtag of either <feed> or <entry>, the tag can identify the type of item described in each feed entry. The value of the scheme attribute is http://schemas.google.com/g/2005#kind and the value of the term attribute indicates whether feed entries describe videos, playlist links, subscriptions, contacts or another entity type.
When the <category> tag appears as a subtag of <entry> and the entry describes a video, the tag can also specify a particular keyword or category associated with that video. In this case, the scheme attribute indicates whether the term attribute value refers to a keyword or a category.
In a request to add a subscription, the <category> tag indicates whether the user is subscribing to a channel, another user's list of favorites, or a keyword tag:
If the user is subscribing to a channel, then the value of the <category> tag's term attribute must be channel.
If the user is subscribing to another user's list of favorites, then the value of the <category> tag's term attribute must be favorites.
If the user is subscribing to a keyword tag, then the value of the <category> tag's term attribute must be query.
In a request to add or update a contact, the <category> tag indicates whether the contact is a friend or family.
If the contact is a family member, the value of the <category> tag's term attribute should be Family.
If the contact is a friend, the value of the <category> tag's term attribute should be Friends.
| Name | Format | Description |
|---|---|---|
| scheme | Text (URI) | The scheme attribute specifies a URI that identifies the categorization scheme associated with the label.
|
| term | Text | The term attribute identifies the type of entity contained in a feed entry or a category or keyword associated with a video.
|
| label | Text | The label attribute specifies the entity-escaped name of the YouTube category to which the video belongs. This attribute is only included in <category> tags that refer to a category (and not a keyword or entity type). |
<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' term='channel'/>
The <content> tag contains the text of a comment or a description of a video or playlist. When the <content> tag appears in a video entry or playlist entry, it may contain the same description as the <media:description> tag.
The <content> tag is required in a request to add a comment.
<content type="text">Video comments are cool.</content>
The <entry> tag encapsulates information about a video, playlist, subscription, contact or other entity. The <entry> tag is the root tag in all YouTube Data API requests to add (POST) or update (PUT) data.
<entry>
The lists below identify possible subtags of the <entry> tag for different retrieve (GET), create (POST) and update (PUT) API operations. For example, when you retrieve a playlist feed, each entry contains many different fields. However, when you create or update a playlist entry, you only need to provide the title, description and playlist position for the entry.
GET operations
Retrieving a video entry or entries in a video or playlist feed: id, published, updated, category*, title?, content?, link*, author?, media:group?, yt:description? (this tag only appears in a playlist entry), yt:position? (this tag only appears in a playlist entry), yt:statistics?, gd:comments?, gd:rating?, location?, yt:recorded?, georss:where?, app:control?
Retrieving entries in a comments feed: id, published, updated, category*, title?, content?, link*, author?
Retrieving entries in a playlists feed: id, published, updated, category*, title?, content?, link*, author?, yt:description?, gd:feedLink
Retrieving entries in a subscriptions feed: id, published, updated, category*, title?, content?, link*, author?, yt:username?, yt:queryString?, gd:feedLink
Retrieving a profile entry: id, published, updated, category*, title?, content?, link*, author?, yt:age?, yt:books?, yt:company?, firstName?, yt:gender?, yt:hobbies?, yt:hometown?, lastName?, yt:location?, yt:movies?, yt:music?, yt:occupation?, yt:school?, yt:username?, yt:statistics?, media:thumbnail?, gd:feedLink*
Retrieving entries in a contacts feed: id, published, updated, category*, title?, link*, author, yt:username, yt:status
Retrieving entries in an inbox (messages) feed: id, published, category, title, content?, link*, author?, media:group?, yt:statistics?, gd:rating?, gd:comments?, description?
POST and PUT operations
Adding favorite videos: id
Adding and updating playlists: title, yt:description, yt:private
Adding and updating playlist entries: title, yt:description, yt:position
Adding subscriptions: category, yt:username, yt:queryString
Adding and updating contacts: category, yt:username
Adding comments: content
Adding video responses: id
Adding ratings: gd:rating
Adding complaints: yt:description
Adding (sending) messages: id, yt:description
If the <entry> tag appears in a batch processing request, then it might also include the <batch:operation> <batch:id> tags.
If the <entry> tag appears in a response to a batch processing request, then it will also include the <batch:operation> and <batch:status> tags and it may also include the <batch:id> and <batch:interrupted> tags.
The <feed> tag is the root tag for several types of YouTube Data API feeds, including video feeds, subscription feeds, playlist feeds, favorite video feeds and contact feeds. A feed contains a series of <entry> elements, each of which contains information about a single video, playlist, subscription or other entity.
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005'>
id, updated, category*, title, logo?, link*, author?, generator, openSearch:itemsPerPage?, openSearch:startIndex?, openSearch:totalResults?, batch:operation?, entry+
The <generator> tag identifies the software used to create the feed. This information might be used for debugging purposes.
| Name | Format | Description |
|---|---|---|
| version | Text | The version attribute specifies the version of the software application used to generate the feed. |
| uri | Text (URI) | The uri attribute specifies a URI related to the feed-generating software. |
<generator version='beta' uri='http://gdata.youtube.com/'>YouTube data API</generator>
The <id> tag specifies a URI that uniquely and permanently identifies a feed or video entry.
<id>http://gdata.youtube.com/feeds/api/users/andyland74/subscriptions/5c56f45db338111c</id>
The <link> tag contains an IRI reference that is relevant to a feed or a feed entry.
| Name | Format | Description |
|---|---|---|
| rel | Text | The rel attribute indicates how the URI specified in the href attribute is related to the current result set:
|
| type | Text | The type attribute specifies the media type of the resource at the associated URL. The links in a YouTube Data API response typically refer to either an HTML page or another API response (Atom feed). As such, the most common values for the type attribute are text/html and application/atom+xml. |
| href | Text (URI) | The href attribute specifies a URI that identifies the resource identified in the <link> tag. |
<link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/AlPqL7IUT6M/related'/>
The <logo> tag specifies an image that provides visual identification for the feed. The logo in a YouTube Data API feed is the YouTube logo.
<logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo>
The <name> tag contains the author's YouTube username.
<name>andyland74</name>
The <published> tag specifies the time that a feed entry was created.
<published>2007-10-15T15:39:34.000-07:00</published>
The <title> tag provides a human-readable title for a feed or an entry in a feed. This tag is also required for adding playlists and is optional for adding or updating playlist entries.
In a request to add or update a playlist, the <title> tag specifies the title of the playlist.
In a request to add or update a playlist entry, the <title> tag specifies a custom title that the user wants to display in the playlist instead of the video's actual title. If the user does not provide a custom title, YouTube will display the video's actual title in the playlist.
<title type='text'>andyland74's Subscriptions</title>
The <updated> tag specifies the time that a feed or feed entry was last updated.
<updated>2007-10-15T15:39:34.000-07:00</updated>
The <uri> tag contains a URL related to the author.
<uri>http://gdata.youtube.com/feeds/api/users/andyland74</uri>
The <openSearch:itemsPerPage> tag indicates how many entries are in an API response.
<openSearch:itemsPerPage>25</openSearch:itemsPerPage>
The <openSearch:startIndex> tag identifies the one-based index of the first item returned in the feed.
<openSearch:startIndex>1</openSearch:startIndex>
The <openSearch:totalResults> tag identifies the number of items in the result set for the feed. Please note that this value is an approximation and may not represent an exact value. You should not use this value to create pagination links. Use the <link rel="next"> and <link rel="prev"> tags to determine whether to show pagination links:
<openSearch:totalResults>36</openSearch:totalResults>
The <yt:age> tag specifies the user's age, which is calculated based on the birthdate provided for the user's YouTube profile. This tag appears in a user profile entry.
<yt:age>33</yt:age>
The <yt:books> tag identifies the user's favorite books as entered in the user's YouTube public profile. This tag appears in a user profile entry.
<yt:books>Catch-22</yt:books>
The <yt:company> tag identifies the company that the user works for as entered by the user in the user's public YouTube profile. This tag appears in a user profile entry.
<yt:company>Google</yt:company>
The <yt:description> tag contains either the description that a user entered for a playlist, a custom description that a user entered for a video in a playlist, or the text of a complaint.
<yt:description>My new playlist description</yt:description>
The <yt:duration> tag specifies the duration of a video in seconds.
| Name | Format | Description |
|---|---|---|
| seconds | Integer | The seconds attribute indicates the duration, in seconds, of a video. |
<yt:duration seconds='344'/>
The <yt:firstName> tag specifies the user's first name. This tag appears in a user profile entry.
<yt:firstName>John</yt:firstName>
The <yt:gender> tag specifies the user's gender as entered in the user's public YouTube profile. This tag appears in a user profile entry.
<yt:gender>m</yt:gender>
The <yt:hobbies> tag identifies the user's hobbies as entered in the user's YouTube public profile. This tag appears in a user profile entry.
<yt:hobbies>Testing YouTube APIs</yt:hobbies>
The <yt:hometown> tag identifies the user's hometown as entered in the user's YouTube public profile. This tag appears in a user profile entry.
<yt:hometown>Albany, GA</yt:hometown>
The <yt:lastName> tag specifies the user's last name. This tag appears in a user profile entry.
<yt:lastName>Smith</yt:lastName>
In a video entry, the <yt:location> tag contains descriptive text about the location where the video was taken. In a user profile entry, the <yt:location> tag identifies the user's location as entered in the user's YouTube public profile.
<yt:location>US</yt:location>
The <yt:movies> tag identifies the user's favorite movies as entered in the user's YouTube public profile. This tag appears in a user profile entry.
<yt:movies>Aqua Teen Hungerforce</yt:movies>
The <yt:music> tag identifies the user's favorite music as entered in the user's YouTube public profile. This tag appears in a user profile entry.
<yt:music>Elliott Smith, the Kooks</yt:music>
The <yt:noembed> tag specifies that a video may not be embedded on other websites. This tag may be included in a request to upload or update a video's metadata. By default, videos can be embedded on other sites unless they are private videos. If a request does not include either the <yt:noembed> tag or the <yt:private> tag, a video will be embeddable on other websites.
<yt:noembed/>
The <yt:occupation> tag identifies the user's occupation as entered in the user's public YouTube profile. This tag appears in a user profile entry.
<yt:occupation>Technical writer</yt:occupation>
The <yt:position> tag specifies the order in which a video appears in a playlist.
<yt:position>4</yt:position>
The <yt:private> tag indicates that a video is private, meaning that the video will not be publicly visible on YouTube's website. A private video can only be viewed by people personally selected by the video's owner. This tag may be included in a request to upload or update a video's metadata. The tag should not specify a value. The tag's presence indicates that the video is private. The tag's absence indicates that the video will be visible to all YouTube users. By default, videos are publicly visible on YouTube. The tag's absence indicates that the video will be visible to all YouTube users. (By default, videos are visible to all YouTube users, and you must include the <yt:private> tag in all requests to upload or update a video to indicate that the video is private.)
<yt:private/>
The <yt:queryString> tag specifies the keyword(s), or query string, associated with a subscription.
<yt:queryString>Dog skateboarding</yt:queryString>
Note: This tag has been deprecated. Even though the tag may still be included in API responses, your application should check for the presence of the <media:rating> tag to determine whether a video contains restricted content.
The <yt:racy> tag indicates whether a video contains restricted content. If you are requesting a videos feed, the feed will only contain restricted content if your API request includes the racy parameter.
<yt:racy/>
The <yt:recorded> tag specifies the date that a video was recorded.
<yt:recorded>2003-08-03</yt:recorded>
The <yt:relationship> tag indicates whether the user is in a relationship according to the information in the user's public YouTube profile.
<yt:relationship>taken</yt:relationship>
The <yt:school> tag identifies the school that the user attended according to the information in the user's public YouTube profile. This tag appears in a user profile entry.
<yt:school>University of North Carolina</yt:school>
The <yt:state> tag contains information that describes the status of a video. For videos that failed to upload or were rejected after the upload process, the reasonCode attribute and the tag value provide insight into the reason for the upload problem.
| Name | Format | Description |
|---|---|---|
| name | Text | The name attribute identifies the status of an unpublished video. Valid values for this tag are processing, rejected and failed. |
| reasonCode | Text | The reasonCode attribute provides information about why a video failed to upload or was rejected after the uploading process. The <yt:state> tag will not include a reasonCode attribute if the value of the name attribute is processing. The following list identifies possible reasonCode values for rejected or failed uploads:
|
| helpUrl | Text | The helpUrl parameter contains a link to a YouTube Help Center page that may help the developer or the video owner to diagnose the reason that an upload failed or was rejected. |
<yt:state name="rejected" reasonCode="tooLong" helpUrl="http://www.youtube.com/t/community_guidelines">Video is too long</yt:state>
The <yt:statistics> tag provides statistics about a video or a user. The <yt:statistics> tag is not provided in a video entry if the value of the viewCount attribute is 0. This tag appears in video, playlist and user profile entries.
| Name | Format | Description |
|---|---|---|
| viewCount | Integer | When the viewCount attribute refers to a video entry, the attribute specifies the number of times that the video has been viewed. When the viewCount attribute refers to a user profile, the attribute specifies the number of times that the user's profile has been viewed. |
| videoWatchCount | Integer | The videoWatchCount attribute specifies the number of videos that a user has watched on YouTube. The videoWatchCount attribute is only specified when the <yt:statistics> tag appears within a user profile entry. |
| subscriberCount | Integer | The subscriberCount attribute specifies the number of YouTube users who have subscribed to a particular user's YouTube channel. The subscriberCount attribute is only specified when the <yt:statistics> tag appears within a user profile entry. |
| lastWebAccess | DateTime | The lastWebAccess attribute indicates the most recent time that a particular user used YouTube. |
| favoriteCount | Integer | The favoriteCount attribute specifies the number of YouTube users who have added a video to their list of favorite videos. The favoriteCount attribute is only specified when the <yt:statistics> tag appears within a video entry. |
<yt:statistics viewCount='9' videoWatchCount='24' subscriberCount='1' lastWebAccess='2008-02-29T13:09:48.000-08:00'/>
The <yt:status> tag identifies the status of a contact. This tag only appears when you are retrieving contacts of the currently authenticated user. The following list identifies valid values for this tag:
<yt:status>accepted</yt:status>
The <yt:username> tag specifies a YouTube username. In a subscriptions feed or a request to add a subscription, the <yt:username> tag identifies the owner of the YouTube channel or favorites list that is being subscribed to. In a profile entry, the <yt:username> tag identifies the user associated with the profile. In a user contact entry, the <yt:username> tag identifies the contact of the logged-in user.
<yt:username>andyland74</yt:username>
The <media:category> tag specifies a genre or developer tag that describes a video resource. The Category List for Uploaded Videos section identifies YouTube video categories that may be associated with a video, and you may assign each video to one category in that list.
In addition, you may associate each video with one or more private categories or keywords using the category scheme http://gdata.youtube.com/schemas/2007/developertags.cat. Please see the Assigning Developer Tags section of the protocol document for more information about developer tags.
| Name | Format | Description |
|---|---|---|
| label | Text | The label attribute specifies the entity-escaped name of the YouTube category to which the video belongs. |
| scheme | Text (URI) | The scheme attribute specifies a URI that identifies the categorization scheme associated with the label. |
<media:category label='Sports' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Sports</media:category>
The <media:content> tag provides a URL and various other types of information about a video.
| Name | Format | Description |
|---|---|---|
| url | Text (URL) | The url attribute specifies the URL for the media object. |
| type | Text | The type attribute specifies the MIME type of the media object. |
| isDefault | Boolean | The isDefault attribute indicates whether the corresponding <media:content> tag identifies the default media resource for the media group. In a YouTube Data API response, the default media resource is the URL for the embeddable player (SWF) for the video. |
| expression | Text | The expression attribute indicates whether the video object represents a sample of the video, the complete version of the video, or a live video stream. The corresponding (and only) valid values for this attribute are sample, full and nonstop. |
| duration | Integer | The duration attribute specifies the length of the video in seconds. |
| yt:format | Text | The yt:format attribute specifies the video format of the video object described by the <media:content> element. The following list identifies the valid values for this attribute:
|
<media:content url='http://www.youtube.com/v/8aYQ_wjmriQ' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='166' yt:format='5'/>
The <media:description> tag contains a summary or description of a video. This field is required in requests to upload or update a video's metadata. The description should be sentence-based, rather than a list of keywords, and may be displayed in search results. The description has a maximum length of 5000 characters and may contain all valid UTF-8 characters except < and >.
| Name | Format | Description |
|---|---|---|
| type | Text | The type attribute specifies the type of text provided in the tag's value. YouTube content feeds require plain text (type=plain) format. |
<media:description type="plain">Granny takes crocheting to the extreme during a rodeo and while surfing.</media:description>
The <media:group> tag encapsulates metadata about a video resource.
<media:group>
media:title, media:description, media:keywords, media:category, media:content, media:player, media:rating?, media:thumbnail, yt:duration?, yt:private?, yt:noembed?
The <media:keywords> tag contains a comma-separated list of words associated with a video. You must provide at least one keyword for each video in your feed. This field has a maximum length of 120 characters, including commas, and may contain all valid UTF-8 characters except < and <. In addition, each keyword must be at least two characters long and may not be longer than 25 characters.
Please note that individual keywords may not contain spaces. However, you can use spaces after the commas that separate keywords. For example, crazy,surfing,stunts and crazy, surfing, stunts are both valid values for this tag. However, crazy, surfing stunts is not valid. (The invalid value does not contain a comma between "surfing" and "stunts".)
| Name | Format | Description |
|---|---|---|
| scheme | Text (URI) | The scheme attribute specifies a URI that identifies the categorization scheme associated with the label.
|
<media:keywords>rodeo, surfing, crochet</media:keywords>
The <media:player> tag specifies a URL where the full-length video is available through a media player that runs inside a web browser. In a YouTube Data API response, the <media:player> tag specifies the URL for the page on YouTube's website that plays the video.
| Name | Format | Description |
|---|---|---|
| url | Text (URL) | The url attribute identifies a URL that uses a video player to show the video in a browser window. |
<media:player url='http://www.youtube.com/watch?v=8aYQ_wjmriQ'/>
The <media:rating> tag indicates that a video contains restricted content. This tag will only be included in a video entry if the video contains restricted content.
Note:A feed will only include content that is restricted in all countries if your API request included the racy parameter with a value of include (racy=include). The <media:rating> tag replaces the <yt:racy> tag, which has been deprecated.
| Name | Format | Description |
|---|---|---|
| scheme | Text | The scheme attribute specifies a URI that identifies the categorization scheme associated with the rating. |
<media:rating scheme="http://gdata.youtube.com/schemas/2007#mediarating">1</media:rating>