Create Playlist


Create a Category Playlist

Creating a Category Playlist, is the same as creating a Playlist but setting its playlist_type with a category value. You should call the POST action with the following parameters:

Parameter

Function

Type

playlist[playlist_type]

The playlist type to create. Accepted values: manual, category

String

playlist[match_type]

Videos that should match with the categories selected. Accepted values: any, all. If match_type is any, videos to be added to the playlist should match ANY of the categories selected. If match_type is all, videos to be added to the playlist should match ALL of the categories selected.

String

playlist[categories]

Categories that will be used to selected the proper videos to add into the playlist

Array

The playlist[categories] should contain an array of hashes. Every hash will represent a category to be added with the following parameters:

Parameter

Function

Type

categories[category_id]

ID of the category that will be referenced

Integer

categories[title]

Title of the category to be added

String

playlist[values]

Values selected of the category referenced

Array

Here is an JSON example to be set as the body to create a Category Playlist:

{
  "playlist": {
    "title": "Category Playlist",
    "playlist_type": "category",
    "match_type": "any",
    "categories": [
      {
        "category_id": "1234",
        "title": "Category Title",
        "value": [
          "Category Value"
        ]
      }
    ]
  }
}

Take into account that the category_id should be included into the site's categories. To get the list of categories, please go to the categories documentation. If a category with the selected category_id doesn't exists, you will get a 422 response with the following message:

{
  "message": "Could not save playlist: Categories is invalid"
}

Smart Ordering

Playlist smart ordering allows you to change the order of its videos by sort options. The videos added or updated into a playlist with sort options are sorted automatically following that sort option

Parameter

Function

Type

playlist[sort_options]

An array of sort options. Only two levels of sorting are accepted and videos are sorted first by first level, and second by second level

Array

Every sort_option has three fields:

  • direction: The direction to sort the results. It accepts two values: asc (ascending - lowest to highest) and desc (descending - highest to lowest) order.
  • sort_by: The field name which will be taken into account to sort the results. It accepts the following values: created_at, published_at, and title.
  • sort_by_type: The type of the field which will be taken into account to sort the results. It accepts the following values: date, datetime, string, integer, array, and boolean. The difference between date and datetime is that date will only take the date part of the field, while datetime will take the date and time part of the field; so for example, for a date "01/01/2001 01:01:01", date will take only "01/01/2001" into account, while datetime will take the complete date "01/01/2001 01:01:01" into account.

Here is an JSON example to be set as the body to create a Playlist with one level smart ordering:

{
  "playlist": {
    "playlist title": "Title",
    "sort_options": [
      {
        "direction": "desc",
        "sort_by": "published_at",
        "sort_by_type": "datetime"
      }
    ]
  }
}

And with two levels smart ordering:

{
  "playlist": {
    "playlist title": "Title",
    "sort_options": [
      {
        "direction": "desc",
        "sort_by": "published_at",
        "sort_by_type": "datetime"
      },
      {
        "direction": "asc",
        "sort_by": "title",
        "sort_by_type": "string"
      }
    ]
  }
}
Language
Authentication
Query
URL
Click Try It! to start a request and see the response here!