Skip to content

📺 Unofficial API for multimedia websites. (node.js only)

License

Notifications You must be signed in to change notification settings

mat-sz/media-api

Repository files navigation

media-api

Unofficial API for multimedia websites. (node.js only)

workflow npm npm NPM

Quickstart:

npm install media-api
# or:
yarn add media-api
import { YouTube } from 'media-api';

async function example() {
  const youtube = new YouTube();
  const content = await youtube.content('jNQXAC9IVRw');
  console.log(content);
}

Supported media websites:

Title Content Playlist Search
YouTube ✔️ ✔️ Partial
SoundCloud Partial

Usage

All classes implement the Service interface:

export interface Service {
  content(id: string): Promise<Content>;
  playlist?(id: string): Promise<Playlist>;
  search?(text: string): Promise<SearchResults>;
}

The Content interface is defined here. This is the shortened representation of it:

export interface Content {
  id: string;
  type: ContentType;
  title: string;
  description?: string;
  duration?: number;
  statistics?: ContentStatistics;
  streams?: ContentStream[];
  thumbnails?: Thumbnail[];
  keywords?: string[];
  author?: Author;
  date?: Date;
}

The Playlist interface is defined here. This is the shortened representation of it:

export interface Playlist {
  id: string;
  title: string;
  thumbnails?: Thumbnail[];
  author?: Author;
  contents?: Content[];
}

The SearchResults interface is defined here. This is the shortened representation of it:

export interface SearchResults {
  contents?: Content[];
}