Custom YouTube Hashtag and Channel Playlists

Design your own video strategy with custom playlists

At RebelMouse, we have the ability to implement almost any idea thanks to the power of our Layout & Design Tool. One use case is the ability to easily create custom YouTube playlists based on hashtags.

For example, if your company uses the #OurCompany hashtag, you could create a custom YouTube playlist on your website that pulls in content from that stream. You can also customize the playlist so that it only pulls in videos from a certain YouTube channel, or from a single channel without a hashtag:

The key to creating a custom playlist is to use YouTube's API to pull content. Let's explore how to pull content based on a hashtag, regardless of the channel.

Query for a Playlist Based on a Hashtag

The first step is to create a JavaScript variable for the query that will pull from the YouTube API. For example:

var queryStr = '' + queryHash + '&type=video&videoCaption=any&videoDefinition=any&videoDimension=any&videoDuration=any&videoEmbeddable=any&videoLicense=any&videoSyndicated=any&videoType=any&key=' + key + '&maxResults='+maxResults;

For playlists based just on hashtags, there are three required parameters:

  • QueryHash: Your custom hashtag.
  • MaxResults: Fetch x videos, where x equals the maximum number of videos you want to pull. It can be any positive integer value.
  • Key: The API key. (This will be shared by the owner of the YouTube channel. See this guide that describes how to get an API key.)
  • ChannelId: This is an optional parameter. If it's provided in your query, it will only fetch videos from the channel ID you designate, otherwise it will fetch videos from any channel. Click here to learn how to locate a channel's ID.

Query for Playlists Based on Hashtags From a Single Channel

Here is the API query using the ChannelId parameter:' + queryHash + '&type=video&videoCaption=any&videoDefinition=any&videoDimension=any&videoDuration=any&videoEmbeddable=any&videoLicense=any&videoSyndicated=any&videoType=any&key=' + key + '&maxResults=' + maxResults + '&channelId='+ channelId;

Understanding the JavaScript Logic

Now that we have an understanding of which query strings to use when making requests to the YouTube API, let's dive into how the JavaScript logic works

The basic idea is that we use the fetch API built into modern browsers to make Ajax requests to the YouTube API. Next, it fetches a response in JSON, and then we parse it and display the response in a video format using iframes.

Here is an example of a JSON response from the YouTube API:

 "kind": "youtube#searchListResponse",
 "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/zdxYH_AS29xYgdx2YxQYxPeLj-I\"",
 "nextPageToken": "CAEQAA",
 "regionCode": "IN",
 "pageInfo": {
  "totalResults": 12,
  "resultsPerPage": 1
 "items": [
   "kind": "youtube#searchResult",
   "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/77ZWdQpKmM3r0vin9RorTTevnQc\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "iv0N7i2virY"
   "snippet": {
    "publishedAt": "2019-07-04T08:40:09.000Z",
    "channelId": "UCJv753whZjpW22UfmaJbx4Q",
    "title": "From Kurils with Love: The Expedition Trailer",
    "description": "On Monday, the 8th July, an unusual expedition is setting sails in the town of Petropavlovsk in Kamchatka. A group of filmmakers, adventurers, climbers, ...",
    "thumbnails": {
     "default": {
      "url": "",
      "width": 120,
      "height": 90
     "medium": {
      "url": "",
      "width": 320,
      "height": 180
     "high": {
      "url": "",
      "width": 480,
      "height": 360
    "channelTitle": "Tomorrow Unlocked",
    "liveBroadcastContent": "none"

Sample Code

Below are some sample codes for using JavaScript to fetch a response for videos based on a hashtag and then render them as an iframe video player:

<div class="hash-videos"></div><button id="load-more-videos" class="load-more" onclick="LoadMore()">Load More</button><style>
.hash-videos {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
.yt-iframe {
margin: 0px 10px 0px 0px;
width: 340px;
padding: 5px;
/* tablets */
@media screen and (min-width: 768px) and (max-width: 1023px) {
 .yt-iframe {
  margin: 0 auto;
  width: 50%;
  box-sizing: border-box;
  /* small devices */
@media screen and (max-width:767px) {
  .yt-iframe {
  margin: 0;
  width: 100%;
  padding: 0 0 15px 0;
.load-more {
background: black;
border: 1px solid;
padding: 10px 20px;
width: 200px;
margin: 40px auto 50px;
display: block;
font-size: 15px;
  var queryHash = ""; //"fromkurilswithlove";
  var maxResults = 6;
  var key = "AIzaSyC5PqJgz18fIBjd9Yq3eA6cmL3EfmrbL1w";
  var pageToken = "";  // Pagination Logic.
  var channelId = "UCJv753whZjpW22UfmaJbx4Q"; // TomorrowUnlocked
  function LoadMore() {
 fetch('' + queryHash + '&type=video&videoCaption=any&videoDefinition=any&videoDimension=any&videoDuration=any&videoEmbeddable=any&videoLicense=any&videoSyndicated=any&videoType=any&channelId='+ channelId +'&key=' + key + '&maxResults='+maxResults+'&pageToken='+pageToken)
      function(response) {
        if (response.status !== 200) {
          console.log('Looks like there was a problem. Status Code: ' +
        // Examine the text in the response
        response.json().then(function(data) {
    .catch(function(err) {
      console.log('Fetch Error :-S', err);
  function renderVideos(data) {
    var videosData = data.items;
    var playerFrame = document.getElementsByClassName("hash-videos")[0];
    for(var i = 0; i < videosData.length; i++) {
        /*<div class='yt-iframe'><iframe title='' type='text/html' src=' frameborder='0' allowFullScreen></iframe><div>*/
        var ytdiv = document.createElement("div");
          var ytIframe = document.createElement("iframe");
          ytIframe.setAttribute("src", "" + videosData[i].id.videoId);
        ytIframe.setAttribute("title", videosData[i].snippet.title);
        ytIframe.setAttribute("allowFullScreen", "true")
        ytIframe.setAttribute("frameborder", 0);
    //check if we have more videos else hide load more button
    if(data.nextPageToken) {
      pageToken = data.nextPageToken; //YT response gives a token for next page fetch.
    } else {
      pageToken = "";
      var x = document.getElementById("load-more-videos"); = "none";

If you have any questions or need help implementing this or any other feature — depending on the nature of the request, it may require services hours from us to complete the work — please email or talk to your account manager today.

Why RebelMouse Is the Best Content Marketing Platform

RebelMouse is a unique platform and company. The company was founded on the vision that media companies would need an always-modern solution to thrive in the new connected internet, and that brands would have to behave like new media companies and use the same platforms.

Keep reading... Show less

Why Premium Creative Agencies and CTOs Choose to Develop on RebelMouse vs. WordPress and Drupal

The Intersection of Design and Development: Where Your Clients Thrive

We started RebelMouse seven years ago knowing that there was a fundamental design flaw in the world of traditional CMSs: Every instance, on every platform, had to be updated independently. It's similar to an era when users had to manage their own Microsoft Exchange Server for email. The costs of managing, maintaining, and iterating on a CMS to keep it awesome and world class is typically a $10 million-a-year endeavor. But even then, these cost-prohibitive CMSs are still behind the times.

Keep reading... Show less

Native Multivariate Testing at Scale With RebelMouse

What Differentiates Our Approach

There are many popular tools that allow you to perform experiments and A/B tests on your users — primarily Google Chrome Experiments and Optimizely. But all of these solutions are JavaScript additions to your web page that sidestep the problem of old, outdated, and clumsy CMSs. These solutions work by calling on a third-party JavaScript library that rewrites a page after it's rendered. This approach adds extra page weight and creates strange user experiences due to having to wait for everything to load and be rewritten on the fly.

At RebelMouse, we've solved this in a very elegant way. At the core level of our platform, we can natively render different layouts and track the exact differences in performance when comparing a test to your other layouts.

Keep reading... Show less

Modern E-Commerce: Blur the Line Between Content and Design

Create Modular + Reusable Design Patterns on RebelMouse

Content saturation is an industry-wide problem, and the e-commerce space is no exception given that it's filled with big brands, small Etsy stores, and everyone in between all fighting for similar audiences. The best way to fight this symptom is to understand your audience and provide them with what they want.

Keep reading... Show less

Instagram-style E-commerce Features on RebelMouse

Revolutionizing E-commerce on RebelMouse

Whether you're a brand with a blog or a media company with a site, driving purchasing behavior and building an audience that uses your content to find things they love to buy is vital. We're very proud to have built out the same functionality that everyone is now used to on Instagram, with layovers on images that lead to products with attribution.

Keep reading... Show less

Building Premium Communities and User Journeys on RebelMouse

RebelMouse is much more than just a replacement for a traditional CMS. Our platform is a tremendous community-building experience. Today's social ecosystem has given us a seemingly limitless number of premium creators who understand how to create gorgeous and relevant content that drives the growth of their own audiences. These creators and influencers are either experts in certain topics, or heavily engaged in targeted content that drives their interests. They're not only consuming the content they're passionate about, but they're contributing to the conversation, too. The new role of the editor is not just to cover the most important topics and people around their expertise, but also to invite those preferred influencers into their community and get them to participate in creating premium content.

Keep reading... Show less

Dynamic Voting: Grow Traffic and Engagement Organically

Help your audience find its voice.

Creating quality content is no longer on marketers alone. We live in a universe of creators who are willing to not only consume content that resonates, but play a role in the creation, promotion, and conversations surrounding it.

Since the start of RebelMouse, we've been on a journey to create dynamic media that is easier for content creators to curate and amplify on social. It's why we've built an online engagement platform centered around the power of communities that thrive naturally in the digital ecosystem.

Keep reading... Show less

How to Monetize Your Website in Today’s Publishing Environment

In order to define distributive publishing, we have to ask the following question: If you have quality content, but nobody sees it, does it even exist? The answer is no, because your content needs to be supported in a way that lets it move seamlessly across all channels, especially site, search, and social. But let's take this question a step further: If you can't monetize your content to generate the support it needs, how do you create quality content in the first place?

Keep reading... Show less

How COVID-19 Has Changed Four Key Components of Marketing

Picking up the pieces and the importance of building trust in a pandemic

As the second half of 2020 begins to pass us by, the COVID-19 pandemic continues to rage on throughout the global community. The longevity of the pandemic has left thousands of industries struggling to find an appropriate position in the marketplace that will allow them to sustain themselves alongside daily tragedy.

The pandemic is far from over, but publishers and marketers are beginning to sift through the aftershocks of what COVID-19 has done to the web. Here's a quick look at the decline in conversion growth during the first few weeks of the pandemic in the United States:

Keep reading... Show less

Explore Careers at RebelMouse

Join RebelMouses's modern and distributive workforce responsible for the websites of media powerhouses, including legacy brands like United Airlines and new media darlings like PAPER Magazine and Protocol.

If you feel like you've never quite fit into boxes or labels within the tech space, we want to hear from you. Built on a foundation of site performance, our cloud-based platform reaches 50+ million people a month with an always-modern approach to product and strategy.

Our fully remote team spans 25+ countries and has very flexible schedules. If you don't want to be confined to an office chair, and like the idea of being able to work from any place in the world you choose, we're a match.

RebelMouse is dedicated to pursuing inclusion for all individuals, regardless of their gender identity, sexual preference, ethnicity, religion, age, or disability. We work hard to form meaningful relationships beyond our platform, and it's this passion that has formed what is now a diverse software company and creative agency that's bucking industry norms. For us, diversity is a company pillar, not just a statistic.

Click here to browse our current opportunities
Subscribe to Our Newsletter