Get Video details from Youtube using PHP,Json and Youtube Data API.

Hey, guys, today I am going to show you that how we can get video and its details of a particular channel from youtube in PHP in a Json format and display it in a nice format in a web page using html. And all this would be possible just because of youtube Data API.

Demo Subscribe on youtube

So lets get started,

What type of details we will be fetching?

So in this script i will be using to fetch just the basic details like –

  • Id of the video (MAX – 50 video’s id)
  • Thumbnails
  • Title
  • Description
  • Likes
  • Dislikes

And That’s all we are getting. Ofcourse there are a lot more things we can get but the basic stuff is that much only. and if you want to get more details like – thumbnail according to the size, playlist, playlists items. So you can get all these just by using the api in the same way i am getting all these things.

How to Set up the script?

So for using this script you will be needing couple of things to be set up first like –

  • Youtube data API Key
  • Channel id (To get the videos of the channel).

That’s it

How to get Youtube Data API key?

So to get the Apikey you need to register the application on Google Api Console and create a new application like this –1 pic

Then Type your app name whatever you want and proceed.

Then the library page will open so select  youtube Data Api2 pic

And the enable the youtube data api

Ten Locate towards the credentials tab from the sidebar and click create credentials and choose api key.

And then the pop will appear containing you Api key, Copy that key and paste it in YOUR_API_KEY with your api key in the source file here –

So That’s it for this tutorial i hope you like it and if you did then subscribe the blog for latest updates via email and also subscribe my youtube channel – Hacker Rahul .

Thanks you

Ta Da!