Query playlist videos

Filter, sort, and slice playlist videos.

POST
/api/playlist/{id}/query

Path Parameters

id*string

Playlist ID or URL

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

import { Router } from 'express'import { client } from '../lib.js'const router = Router()router.post('/playlist/:id/query', async (req, res) => {  const { id } = req.params  const body = req.body  let query = client!.playlistQuery(id)  if (body.filter?.duration) query = query.filterByDuration(body.filter.duration)  if (body.filter?.views) query = query.filterByViews(body.filter.views)  if (body.filter?.likes) query = query.filterByLikes(body.filter.likes)  if (body.sort) query = query.sortBy(body.sort.field, body.sort.order)  if (body.range) query = query.between(body.range.start, body.range.end)  const result = await query.execute()  res.json(result)})export const routes = router
{
  "id": "string",
  "title": "string",
  "description": "string",
  "thumbnails": {
    "default": {
      "url": "string",
      "width": 0,
      "height": 0
    },
    "medium": {
      "url": "string",
      "width": 0,
      "height": 0
    },
    "high": {
      "url": "string",
      "width": 0,
      "height": 0
    },
    "standard": {
      "url": "string",
      "width": 0,
      "height": 0
    },
    "maxres": {
      "url": "string",
      "width": 0,
      "height": 0
    }
  },
  "videoCount": 0,
  "totalDuration": 0,
  "totalDurationFmt": "string",
  "videos": [
    {
      "id": "string",
      "title": "string",
      "description": "string",
      "channelTitle": "string",
      "publishedAt": "string",
      "duration": 0,
      "durationFmt": "string",
      "views": 0,
      "viewsFmt": "string",
      "likes": 0,
      "likesFmt": "string",
      "thumbnails": {
        "default": {
          "url": "string",
          "width": 0,
          "height": 0
        },
        "medium": {
          "url": "string",
          "width": 0,
          "height": 0
        },
        "high": {
          "url": "string",
          "width": 0,
          "height": 0
        },
        "standard": {
          "url": "string",
          "width": 0,
          "height": 0
        },
        "maxres": {
          "url": "string",
          "width": 0,
          "height": 0
        }
      }
    }
  ],
  "originalCount": 0
}
{
  "error": {
    "code": 0,
    "message": "string",
    "details": [
      "string"
    ]
  }
}
{
  "error": {
    "code": 0,
    "message": "string",
    "details": [
      "string"
    ]
  }
}