Video

Fetch video details, titles, and batch data

client.video(urlOrId)

Fetch full details for a single video. Accepts a video ID or any YouTube URL.

const video = await client.video('dQw4w9WgXcQ')

Also accepts URLs:

const video = await client.video('https://youtu.be/dQw4w9WgXcQ')

Response

PropertyTypeDescription
idstringYouTube video ID
titlestringVideo title
descriptionstringFull video description
channelstringChannel name
channelIdstringChannel ID
viewsnumberRaw view count
viewsFmtstringFormatted views (e.g. "1.8B")
likesnumberRaw like count
likesFmtstringFormatted likes (e.g. "19M")
commentsnumberRaw comment count
commentsFmtstringFormatted comments
durationnumberDuration in seconds
durationFmtstringDuration as clock (e.g. "3:34")
publishedstringFormatted publish date (e.g. "October 25, 2009")
publishedAtstringISO 8601 timestamp
thumbnailsobjectThumbnail map (default, medium, high, standard, maxres)

client.videos(urlsOrIds)

Batch fetch multiple videos. Accepts an array of IDs or URLs.

const videos = await client.videos(['dQw4w9WgXcQ', 'jNQXAC9IVRw'])

Automatically chunks requests into batches of 50 and fetches details in parallel.

Response

Returns an array of Video objects (same shape as client.video).


client.videoTitle(urlOrId)

Lightweight title-only lookup. Costs 1 quota unit instead of the full video detail cost.

const { id, title } = await client.videoTitle('dQw4w9WgXcQ')

Response

PropertyTypeDescription
idstringYouTube video ID
titlestringVideo title

client.videoTitles(urlsOrIds)

Batch fetch titles for multiple videos.

const titles = await client.videoTitles(['dQw4w9WgXcQ', 'jNQXAC9IVRw'])
// { "dQw4w9WgXcQ": "Rick Astley - Never Gonna Give You Up", ... }

Response

Returns Record<string, string> — a map of video IDs to titles.


Error Handling

import { yt, NotFoundError, QuotaError } from 'lyra-sdk'

try {
  const video = await client.video('INVALID_ID')
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log('Video not found')
  } else if (error instanceof QuotaError) {
    console.log('Quota exceeded, retry after', error.retryAfter, 'seconds')
  }
}

On this page