How do I get the title of a youtube video if I have the Video Id?

后端 未结 9 1987
忘掉有多难
忘掉有多难 2020-12-13 00:28

I\'m playing now with the Youtube API and I began a small project (for fun).

The problem Is that I cant find the way to get Title of a video from the Id. (example: y

9条回答
  •  天涯浪人
    2020-12-13 00:58

    The answers of Robert Sim and cbaigorri were the best, that's the correct way to do it at this time with JS, do GET request to:

    https://www.googleapis.com/youtube/v3/videos?part=snippet&id={YOUTUBE_VIDEO_ID}&fields=items(id,snippet)&key={YOUR_API_KEY}

    A little specification about this: You can use comma separated youtube video IDs to get multiple videos info in one request.

    To get 1 video, replace {YOUTUBE_VIDEO_ID} with video ID (ex: 123456) To get more videos in one request, replace {YOUTUBE_VIDEO_ID} with comma separated IDs (ex: 123456,234567,345678,456789)

    This will count as a single request in the Quotas, this way you can get a lot of video details with only 1 quota/request cost.

提交回复
热议问题