---
title: How to Embed Your YouTube Channel as a Playlist
date: 2011-11-13T11:43:47+00:00
modified: 2012-02-09T02:21:30+00:00
permalink: https://kaspars.net/blog/embed-youtube-channel-playlist
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
category:
  - Development
post_tag:
  - How to
  - Javascript
---

# How to Embed Your YouTube Channel as a Playlist

**Update:** There is an undocumented ID of your channel playlist which is available in the current [beta version of YouTube UI](http://www.youtube.com/cosmicpanda) as [described by Federico](https://kaspars.net/blog/embed-youtube-channel-playlist#comment-11790) in the comments.

For some reason YouTube doesn’t offer a simple way to embed your YouTube **channel**. The only official method is to manually create a **playlist** with all your videos and embed that. However, it requires additional work after every upload which is not cool, especially if you’re on a mobile. Here is [a simple script](http://jsfiddle.net/q3meN/) that creates an HTML5 (iframe) player using the YouTube API:

```
(function() {
    function createPlayer(jqe, video, options) {
        var ifr = $('iframe', jqe);
        if (ifr.length === 0) {
            ifr = $('<iframe scrolling="no" frameborder="no">');
            ifr.addClass('player');
            if (options.playeropts)
                ifr.attr(options.playeropts);
        }
        var src = 'http://www.youtube.com/embed/' + video;
        if (options.playopts) {
            src += '?';
            for (var k in options.playopts) {
                src+= k + '=' + options.playopts[k] + '&';
            }
        }
        ifr.attr('src', src);
        jqe.append(ifr);
    }

    var defoptions = {
        autoplay: false,
        user: null,
        player: createPlayer,
        playeropts: {},
        loaded: function() {},
        playopts: {
            fs: 1,
            showinfo: 1,
            modestbranding: 1
        }
    };

    $.fn.extend({
        youTubeChannel: function(options) {
            var md = $(this);
            var allopts = $.extend(true, {}, defoptions, options);
            $.getJSON('http://gdata.youtube.com/feeds/api/users/' + allopts.user + '/uploads?alt=jsonc&v=2', null, function(data) {
                var videos = [];
                var playlist = '';
                $.each(data.data.items, function(i, item) {
                    videos.push(item.id);
                    if (i > 0)
                        playlist += item.id + ',';
                });
                allopts.playopts.playlist = playlist;
                allopts.player(md, videos[0], allopts);
            });
        }
    });

})();

$(function() {
    $('#player').youTubeChannel({user:'kasparsdambis', playeropts: { width: 400, height: 280 }});
});
```