Thursday, March 8, 2012


YouTube/JSONP oEmbed service "oembed-js"

In the previous post I introduced my oembed-js service and an application using it: YouTube embeds in Blogger comments.

Oembed-js is a Google Appengine application coded in Python. It relays YouTube oembed calls and offers results also in JSONP format, so javascript applications can use it.


url: the (youtube) url to embed (best to be urlencoded)
maxwidth: max width of embedded object (optional)
maxheight: max height of embedded object (optional)
format: json/jsonp or xml (optional, default:json/jsonp)
callback or jsonp: the javascript callback function, required, if jsonp format is wanted
callID: a call ID that is passed through to response (optional)

Sample call:


YouTube oEmbed response in json(p) or xml format, including field html (see oembed specs), and:

callID: if callID was given, it is passed through (can identify the response)
url: pass through the url that is being embedded
videoid: contains 11 char long YouTube videoid, if single video embed
playlist: contains playlist id, if playlist embed

Sample response:

foo({"provider_url": "", "version": "1.0", "title": "Sviatoslav Richter in Kiev, 1958 - Pictures at an Exhibition", "url": "", "type": "video", "videoid": "GMra5Wh51oU", "thumbnail_width": 480, "height": 344, "width": 459, "html": "<iframe width=\"459\" height=\"344\" src=\"\" frameborder=\"0\" allowfullscreen></iframe>", "author_name": "FirstPublicChannel", "callID": "123", "provider_name": "YouTube", "thumbnail_url": "", "thumbnail_height": 360, "author_url": ""})

Another demo how to use it

Enter YouTube URL (video or playlist):


This demo and its source is also here in this jsFiddle.

Update March 27th 2012: Now oembed-js supports urls (YouTube oembed service does not support them). Also now supports videos which have embedding turned off (YouTube oembed does not support these either).
[Hide comments] - [Show comments]
Click on a single comment to hide/show its text


Beben Koben said... [reply]

I've read before master.
Used jQuery plugin too, but with use it
I do not know about the script :D
ty master :)

Beben Koben said... [reply]

@Beben Koben Do you have a email master? may i know ;)

MS-potilas said... [reply]

@Beben Koben Hi, I sent you an email. :)

I've used YouTube gdata API, too. That offers video title, author, length, and other info. For example gdata url for video:
and for playlist:

Actually I was thinking if I would return also some gdata info, mainly video length, with the oEmbed data. But that would require another call to youtube services, and I'm not sure if I will do that.

Post a Comment

Related Posts Plugin for WordPress, Blogger...
See the hack
for this dynamic
views icon: