npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iniru-youtube-search-api

v1.0.6

Published

Node.js easy to get Youtube results with playlist by provided keywords, no Login or API key required!

Downloads

19

Readme

Youtube Search API

This is fork of Youtube Search API.

You can test it via opening http://localhost:3000

api routes are / = Home Page

/autocomplete = Search suggestion for input keyword

/channel/:id = Get Channel by id

/playlist/:id = Playlist by id

/search = Search results page

/watch/:id = Video Details page with comments and player embed, media files

/watch/:id/comments = Load more comments with replies

/watch/:id/suggestions = Load more Suggestions

/trending = Trending List Page

Installation

npm install && npm run dev

it will start express server on port 3000 so access it http://localhost:3000

Demo

you can check working example on netlify by follow this link

https://cheetube.netlify.app/

It use ReactJS , ViteJS, Vite-Express, Express, TailwindCSS, React-icons

Api Access

https://cheetube.netlify.app/api/

Usage (import)

const youtubesearchapi = require("youtube-search-api");

GetListByKeywords (Promise)

youtubesearchapi.GetListByKeyword("<keywords>",[playlist boolean],[limit number],[options JSONArray])

GetListByKeywords Result

{items:[],nextPage:{nextPageToken:"xxxxxxxx",nextPageContext:{}}}

"items" is the array from youtube, "nextPage" needs to pass when going to the next page. If playlist arg is true, will return type:'playlist' but the videos:[] property will not return the whole videos in the list, need to call GetPlaylistData to get real playlist's videos. Item with Video type will return isLive=[true/false] to identify live video or not.

Options added, this version only support return result type, e.g. [{type:'video'}].

Parameters

| Parameter | Type | Value | | --------- | ---------- | --------------------------------------- | | keywords | String | up to you | | playlist | boolean | true/false | | limit | number | integer | | options | JSON Array | [{type:"video/channel/playlist/movie"}] |

NextPage (Promise)

youtubesearchapi.nextPage(<nextPage from GetListByKeywords result>,[playlist boolean],[limit number])

NextPage Result

{items:[],nextPage:{nextPageToken:"xxxxxxxx",nextPageContext:{}}}

Item with Video type will return isLive=[true/false] to identify live video or not.

Playlist with ID (Promise)

youtubesearchapi.GetPlaylistData(<Playlist Id>,[limit number])

Playlist Result

{items:[],metadata:{}}

Get Suggest Data (Promise)

youtubesearchapi.GetSuggestData([limit number])

Suggest Data Result

{
  items: [];
}

Item with Video type will return isLive=[true/false] to identify live video or not.

Get Channel by channel Id (Promise)

youtubesearchapi.GetChannelById(<channel ID>)

Channel Data Results

[[{ title: "[title]", banner: [array], description: string, content: [Object] }]];

Will return tabs in array format.

Get Video Details with suggestion

GetVideoDetails

youtubesearchapi.GetVideoDetails(<video ID>)

Get Video Details Results

{
 id: string
  title: string
  views: string
  likes: string
  publishedAt: string
  description: string
  channel: {
    id: string
    title: string
    url: string
    subscriber: string
    avatar: [{
      url: string
      width: number
      height: number
    }]
  },
  player: {
    id: string
    title: string
    thumbnails: [{
      url: string
      width: number
      height: number
    }]
    shortDescription: string
    length: string
    keywords: string[]
    category: string
    publishDate: string
    embed: {
      iframeUrl: string
      width: number
      height: number
    },
    media: [{
      url: string
      hls: any
      fileType: string
      type: string
      label: string
      width: number
      height: number
    }],
    formats: [{
      itag: number
      mimeType: string
      bitrate: number
      width: number
      height: number
      lastModified: string
      quality: string
      xtags: string
      fps: number
      qualityLabel: string
      projectionType: string
      audioQuality: string
      approxDurationMs: string
      audioSampleRate: string
      audioChannels: number
      signatureCipher: string
    }]
    adaptiveFormats: [{
      itag: number
      mimeType: string
      bitrate: number
      width?: number
      height?: number
      initRange: {
        start: string
        end: string
      }
      indexRange: {
        start: string
        end: string
      }
      lastModified: string
      contentLength: string
      quality: string
      fps?: number
      qualityLabel?: string
      projectionType: string
      averageBitrate: number
      colorInfo?: {
        primaries: string
        transferCharacteristics: string
        matrixCoefficients: string
      }
      approxDurationMs: string
      signatureCipher: string
      highReplication?: boolean
      audioQuality?: string
      audioSampleRate?: string
      audioChannels?: number
      loudnessDb?: number
    }]
  },
  suggestion: [{
      id: string
      type: string
      thumbnails: [{
        url: string
        width: number
        height: number
      }]
      title: string
      channel: {
        id: string
        title: string
        url: string
        subscriber: string
        avatar: [{
          url: string
          width: number
          height: number
        }]
      },
      length: string
      views: string
      publishedAt: string
      badges: string[]
      isLive: boolean
  }],
  suggestionContext: {
    nextPageToken: string
    nextPageContext: {
      context: Context
      continuation: string
    },
  },
  isLive: boolean,
  comments: [{
    text: string
    items: [{
      channel: Channel3
      isOwner: boolean
      content: string
      publishedAt: string
      likes?: string
      replyCount?: number
      repliesToken?: string
      replies?: [{
        channel: {
          id: string
          title: string
          url: string
          avatar: [{
            url: string
            width: number
            height: number
          }]
          verified: boolean
          artist: boolean
        },
        isOwner: boolean
        content: string
        publishedAt: string
        likes?: string
      }]
    }]
    nextPage: {...}
  }],
  commentContext: {...},
}

Will return video details in Json format.

Get Short Video List (Beta)

Only return short video from suggestion.

GetShortVideo

youtubesearchapi.GetShortVideo()

Get Short Video List Results

[
  {
    id: "",
    type: "reel",
    thumbnail: {
      url: '',
      width: 405, //only return 405
      height: 720 //only return 720
    },
    title: '',
    inlinePlaybackEndpoint: {} //may not return all the time
  }
]

Will return Short Video list in Json Array format.

Limitation:

  1. Only return short video from suggestion.
  2. inlinePlaybackEndpoint facing async issue.
  3. Only return first page of short video.

Docker:

Docker Image

Message

If you want to work with me to fix bug or implement new idea. You are available to send me some new idea of this project.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

TODO

  1. Web app with show case
  2. Typescript version (Contributor is working on)

Bug fixed

Update

  1. Search for shorts (Limitation)

License

MIT

Support me

https://www.buymeacoffee.com/damonwcw