I want to extract the Title of YouTube\'s videos. How can I do this?
Thanks.
I'll lay out the process as outlined by the YouTube API v3 documentation.
Create a new project at https://console.developers.google.com/apis/credentials.
Make a new API key. You'll need it to access video info under v3.
https://www.googleapis.com/youtube/v3/videos?id=&key=%20&part=snippet
(no angle brackets)
fields
and part
parameters in the URL are key here.The URL
is, well, what URL you can go to through your browser to check it out. In return, you should get what's under API response:
.
URL: https://www.googleapis.com/youtube/v3/videos?id=7lCDEYXw3mM&key=YOUR_API_KEY
&fields=items(id,snippet(channelId,title,categoryId),statistics)&part=snippet,statistics
Description: This example modifies the fields parameter from example 3
so that in the API response, each video resource's snippet
object only includes the channelId, title,
and categoryId properties.
API response:
{
"videos": [
{
"id": "7lCDEYXw3mM",
"snippet": {
"channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
"title": "Google I/O 101: Q&A On Using Google APIs",
"categoryId": "28"
},
"statistics": {
"viewCount": "3057",
"likeCount": "25",
"dislikeCount": "0",
"favoriteCount": "17",
"commentCount": "12"
}
}
]
}
This gives you video info in the .json
file format. If your project is to access this info through JavaScript, you may be going here next: How to get JSON from URL in Javascript?.