youtube-video-exists
Version:
Checks if a YouTube video exists under the given ID. No API key is required.
50 lines (49 loc) • 1.33 kB
TypeScript
export interface VideoInfo {
/**
* Title of the video
*/
title: string;
/**
* Information about the author of the video
*/
author: {
/**
* Name of the author of the video
*/
name: string;
/**
* URL to the channel of the author of the video
*/
url: string;
};
}
export interface VideoInfoResponse {
/**
* True when the video exists otherwise false
*/
existing: boolean;
/**
* True when the video id format is valid otherwise false
*/
validId: boolean;
/**
* True when the video is private otherwise false or undefined
* Is defined when existing is true
*/
private?: boolean;
/**
* Information about the video
* Is defined when existing is true and private is false
*/
info?: VideoInfo;
}
/**
* Checks if a YouTube video exists under the given ID
*
* When a video is found the return object also includes the title and author of the video
*
* @param id - YouTube video id
* @returns {@link VideoInfoResponse} when {@link Promise} is resolved
* @throws {@link AxiosError} when a network issue occurred
*/
export declare function getVideoInfo(id: string): Promise<VideoInfoResponse>;