Yesterday one of my clients (roundpeg) asked for a ColdFusion interface to the YouTube API. This turned out to be rather simple since they made use of a REST API. From this work I was able to build a CFC to work with all the functions defined in the API. This lets you get video information, profile information, search for videos etc. Best of all - roundpeg, Inc was cool with me releasing the code. You can download the CFC below.

Now the bad news is that YouTube will eventually be switching to a GData based API. I am not a fan of Google's APIs so frankly I can't see this as being a good thing - but I'll worry about that when the API is updated.

Here are some sample calls:

<cfset devid = "changethis">

<cfset yt = createObject("component", "youtube").init(devid)>

<!--- get videos by user ---> <cfdump var="#yt.getVideosByUser('joerinehart')#" label="Videos by user.">

<!--- get music videos tagged Lush ---> <cfdump var="#yt.getVideosByCategoryAndTag(10,'Lush')#" label="Lush music videos." top="10">

p.s. Note that you need to get a developer profile and key before you use the code.

Download attached file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA