Reputation: 1
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 ?
Upvotes: 5
Views: 18503
Reputation: 13667
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
Upvotes: 10