I am trying to get a simple thing - a video, and i just can't understand why such a simple thing, is not clearly defined in the API docs.
To search for a video i have :
https://www.googleapis.com/youtube/v3/search?part=snippet&q=guy&key=api key
Than , i get the json, with results like :
"kind": "youtube#searchListResponse",
"etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/_yCHjN-Yei6to4bLpd2j603Ea18\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 223929,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/ruSBEQPUZp3DX2M8M4bcCPny2fc\"",
"id": {
"kind": "youtube#video",
"videoId": "J0tGubH9ZyM"
},
What should i do now, to retrieve this first video ? i just need to get the link to the video with the video id, (or etag ? )
How the next request should look like ?
If all you want is a URL for the video (at youtube's page), it takes this form:
https://www.youtube.com/watch?v={videoId}
If you're instead looking to embed the video on your page, you could either do so with the embed code, which you can get with this call:
https://www.googleapis.com/youtube/v3/videos?part=player&id={videoId}&key=api key
Or with the iFrame API, which you can read about here:
https://developers.google.com/youtube/iframe_api_reference
Related
I'm using the YouTubeAPI PlaylistItems: list to retrieve the most recent videos I've uploaded. Up until a week or so ago the playlistitems.item.snippet.publishedAt value returned the date the video was published. Now it appears this value is returning the date the video was uploaded. A video that was published yesterday shows it was published 8+ days ago when it was originally uploaded. This video (along with the others affected) were all uploaded on the same date, always set to private never unlisted and scheduled to be released on a specific date/time.
This is the response I'm getting from https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUhi5MyXJLQuPni3dM19Ar3g&key=[YOUR_API_KEY]
{
"kind": "youtube#playlistItemListResponse",
"etag": "n7hGa6RMjI-sRVXU8hch13PdCDo",
"nextPageToken": "EAAaBlBUOkNCNA",
"items": [
{
"kind": "youtube#playlistItem",
"etag": "pGT_oiGswmjgJXqc1gh8nycNWQ4",
"id": "VVVoaTVNeVhKTFF1UG5pM2RNMTlBcjNnLnlNaGZHaEJadF9j",
"snippet": {
"publishedAt": "2022-01-24T20:29:06Z",
YouTube API website where you can "Try this API" I'm getting this response:
https://developers.google.com/youtube/v3/docs/playlistItems/list?apix=true&apix_params=%7B%22part%22%3A%5B%22snippet%22%5D%2C%22playlistId%22%3A%22UUhi5MyXJLQuPni3dM19Ar3g%22%7D
{
"kind": "youtube#playlistItemListResponse",
"etag": "USoSirgO2XD5JSNHas4dzixQ1Q4",
"nextPageToken": "EAAaBlBUOkNBVQ",
"items": [
{
"kind": "youtube#playlistItem",
"etag": "pGT_oiGswmjgJXqc1gh8nycNWQ4",
"id": "VVVoaTVNeVhKTFF1UG5pM2RNMTlBcjNnLnlNaGZHaEJadF9j",
"snippet": {
"publishedAt": "2022-01-24T20:29:06Z",
Both of these values now are reporting the same and incorrect value. Earlier today when I testing this using Visual Studio and the website I was getting differing values. (see attached images)
Visual Studio (incorrect publishedAt value)
YouTube Data API (correct publishedAt value)
I don't know why PlaylistItems: list doesn't work properly (on my side too) however Videos: list seems to work fine (cf https://www.googleapis.com/youtube/v3/videos?part=snippet&id=yMhfGhBZt_c&key=KEY), since you can check up to 50 videos with a single request you will just double your workload and quota usage.
Youtube's Channel's list API isn't returning brandingSettings even when requested explicitly like this:
https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id=UCJ-gg-0xws8J6PKfY6DBLzg&key=
returned this:
{
"kind": "youtube#channelListResponse",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/hqQ5f5obTKYUNURbAaBo87W-LAw\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/EEjleDhJYQadoLAXlnHS41MfcRk\"",
"id": "UCJ-gg-0xws8J6PKfY6DBLzg"
}
]
}
I wonder if this is a problem or will it be permanent to change?
This functionality (pulling brandingSettings via API) has been down since about 1am PST Aug 28, 2018. Hopefully someone from YouTube sees this and fixes soon...
YouTube fixed this earlier today. Should be working now!
I am using youtube data api (GET https://www.googleapis.com/youtube/v3/channels?part=snippet&categoryId=GCQ29va2luZyAmIEhlYWx0aA&maxResults=5&key={YOUR_API_KEY}). but getting no channel list in response. tried for so many categoryId's from different regionCode.
response from youtube api - 200
{
"kind": "youtube#channelListResponse",
"etag": "Wu2llbfqCdxIVjGbVPm2DslKPCA/ewwRz0VbTYpp2EGbOkvZ5M_1mbo",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
}
Looks like you copy pasted the URI
GET https://www.googleapis.com/youtube/v3/channels
,attached an API_KEY then pasted it on your browser.
What I would recommend is use the Try-it for testing then use OAuth for authorization when actually coding the app. You can see several Quickstarts in the Youtube Guide.
I've found at least five Stack Overflow questions of the form "here is a YouTube channel, how do I programmatically obtain the videos on this channel?"
I want to do the opposite: given a video, what channel did it come from?
So far, I've looked for solutions on this in the official YouTube API. I've also looked at libraries like pafy. No luck so far.
https://developers.google.com/youtube/v3/docs/videos/list
It looks like you can make a video request, then set:
part=snippet
This will return the channelId, among other things. I did a request like so:
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&id=f8WsO__XcI0&key={YOUR_API_KEY}
and I get the response:
{
...
"items": [
{
"kind": "youtube#video",
"etag": "\"IHLB7Mi__JPvvG2zLQWAg8l36UU/Xn3r39kJJF0iqtZbqFIeFUTgC0Q\"",
"id": "f8WsO__XcI0",
"snippet": {
"publishedAt": "2015-04-13T21:20:53.000Z",
"channelId": "UC6nSFpj9HTCZ5t-N3Rm3-HA",
...
}
Find the channel id for a youtube channel in case you want to subscribe to it or for any other purpose.
Let's say you want to let the users subscribe to the client application's youtube channel by clicking subscribe. The user would have to sign in to Google+ and then run an api request to subscribe. So for this scenario you would need the channel id.
Please note that the new way of doing things is Google+ instead of GData
Go to the following link and replace the username of that channel[foofightersVEVO with the username of that channel]
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=id&maxResults=1&q=foofightersVEVO&type=channel&_h=3&
execute the query and look at the api response:
GET https://www.googleapis.com/youtube/v3/search?part=id&maxResults=1&q=foofightersVEVO&type=channel&key={YOUR_API_KEY}
X-JavaScript-User-Agent: Google APIs Explorer
{
"kind": "youtube#searchListResponse",
"etag": "\"2vd4g3cVsHAtTjJSdUMaBo1PBVE/6Ux-QcH6OQdn3t89j3y5z9RQhv0\"",
"pageInfo": {
"totalResults": 161878,
"resultsPerPage": 1
},
"nextPageToken": "CAEQAA",
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"2vd4g3cVsHAtTjJSdUMaBo1PBVE/Q9-widOQXafayJk0l2DV9nrMYO0\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCGRjJrpD2bmk9Ilq6nq80qg"
}
}
]
}
Note the channelId there. Hope this helps.