Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube Data API V3 - No Video url

I am using youtube data api version 3, to get the top youtube videos, i am calling the REST api like this:

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&forMine=true&maxResults=10&order=viewCount&type=video&_h=6&

and get the data like this is json format:

"kind": "youtube#searchResult",
"etag": "adasdasdasdasdas",
"id": 
{
  "kind": "youtube#video",
  "videoId": "123123asdsad12"
},
"snippet": 
{
  "publishedAt": "date",
  "channelId": "Gasdqqweqweqwr123123",
  "title": "my tutle",
  "description": "xyz",
  "thumbnails": 
  {
    "default": 
    {
      "url": "......jpg",
      "width": 120,
      "height": 90
    },
    "medium": 
    {
      "url": "......jpg",
      "width": 320,
      "height": 180
    },
    "high": 
    {
      "url": "......jpg",
      "width": 480,
      "height": 360
    }
  },
  "liveBroadcastContent": "none"
}

but this data do not contain youtube video url, how can i obtain it from the api?

like image 310
Sanjay Bathre Avatar asked Oct 17 '14 11:10

Sanjay Bathre


People also ask

How do I get YouTube data v3 API?

Log in to Google Developers Console. Create a new project. On the new project dashboard, click Explore & Enable APIs. In the library, navigate to YouTube Data API v3 under YouTube APIs.

Can you play videos with YouTube API?

The IFrame player API lets you embed a YouTube video player on your website and control the player using JavaScript. Using the API's JavaScript functions, you can queue videos for playback; play, pause, or stop those videos; adjust the player volume; or retrieve information about the video being played.

Is YouTube data API v3 free?

Yes, using the YouTube API does not incur any monetary cost for the entity calling the API. If you go over your quota an 403 Error will be returned by the API.


1 Answers

You can have the video url like this :

You have the result :

     "kind": "youtube#searchResult",
"etag": "\"adasdasdasdasdas"",
"id": {
"kind": "youtube#video",
"videoId": "123123asdsad12"
},
...

Now you get the field "videoId": "123123asdsad12"

And you can acces to the video via the link:

https://www.youtube.com/watch?v=123123asdsad12

And that's it !

like image 112
mpgn Avatar answered Oct 21 '22 09:10

mpgn