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

youtube-browser-api

v0.0.9

Published

Fully typed endpoints that parse HTML/JSON data from youtube.com from any environment.

Downloads

20

Readme

Fully typed endpoints that parse HTML/JSON data from youtube.com from any environment.

YouTube Browser API

Features

  • Get data on YouTube videos, channels, playlists, heatmap, chapters and more
  • Get YouTube video transcripts
  • Simple and user-friendly API wrapper
  • Works from any environment

Install

npm install youtube-browser-api
REST API is also available

Endpoints

/query: Extract data by passing schemas on video ids:

  • 🔥 You can make granular request as complex as the Javascript Object Notation allows.Go to the playground

| JSON | Interface | Source Code | |--------|--------|--------| | Examine the shape of the Response from a Video using a JSON Viewer | The autogenerated Interfaces for the playerResponse, videoData, apiToken, context and transcriptMeta| The source code from a YouTube Video website - how to | | Dummy - Skeleton | Inspect | view-source:https://www.youtube.com/watch?v=s-I_dV5oY8c |

Excalidraw Link

// typescript
import Api from 'youtube-browser-api'

const myVideoQuery = await Api.query({
    id: 'ZwLekxsSY3Y',
    schema: {
        playerResponse: {
            videoDetails: {
                title: true,
                shortDescription: true,
                thumbnail: {
                    thumbnails: {
                        1: {
                            url: true,
                            height: true,
                            width: true,
                        },
                    },
                },
            },
        },
    },
})

For complex queries you may enable tsAny: true to bypass typechecking. Help to solve the issue https://github.com/kauderk/youtube-browser-api/issues/1

// javascript
const partialChapterQuery = {
    id: 'ZwLekxsSY3Y',
    schema: {
        initialData: { playerOverlays: { playerOverlayRenderer: { decoratedPlayerBarRenderer: { decoratedPlayerBarRenderer: { playerBar: { multiMarkersPlayerBarRenderer: { markersMap: { 0: { value: { chapters: { 1: { chapterRenderer: { title: true, }, }, }, }, }, }, }, }, }, }, }, }, }
    },
    // optional paths|paths[]
    paths: 'playerResponse.streamingData.formats.0.url',
};
const fetchUrl = 'https://youtube-browser-api.netlify.app/query?' + new URLSearchParams(partialChapterQuery).toString()
// https://youtube-browser-api.netlify.app/query?id=ZwLekxsSY3Y&paths=playerResponse.streamingData.formats.0.url
fetch(fetchUrl)
    .then(res => res.json())
    .then(console.log)

/content: Extract all or some video data by a video ID.

// typescript
import Api from 'youtube-browser-api'

const titleData = await Api.content({
    id: 'pOEyYwKtHJo',
    params: ['title'],
})
// javascript
const query = {
    id: 'pOEyYwKtHJo',
    params: ['title'], // ['title','suggestions','storyboard','heatmapPath','isLive','channel','description','initialData','playerResponse','apiToken','context','auto_chapters','chapters','heatmap']
}
const fetchUrl = `https://youtube-browser-api.netlify.app/content?id=${query.id}&params=` + query.params.join()
// https://youtube-browser-api.netlify.app/content?id=pOEyYwKtHJo&params=title
fetch(fetchUrl)
    .then(res => res.json())
    .then(console.log)

/data: Search for narrower data by passing keywords in the query parameter. For example search:

// typescript
import Api from 'youtube-browser-api'

const mySearch = await Api.data('search', {
    keyword: 'AI',
    limit: 1,
})
// javascript
const query = {
    keyword: 'AI',
    withPlaylist: false,
    limit: 1,
    option: ''
};
const fetchUrl = 'https://youtube-browser-api.netlify.app/data/search?' + new URLSearchParams(query).toString()
// https://youtube-browser-api.netlify.app/data/search?keyword=record&withPlaylist=false&limit=1&option=
fetch(fetchUrl)
    .then(res => res.json())
    .then(console.log)

/transcript: Extract transcripts by passing video IDs in the query parameter. For example video ids:

// typescript
import Api from 'youtube-browser-api'

const myTranscript = await Api.transcript({
    videoId: 'pOEyYwKtHJo',
})
// javascript
const query = {
    videoId: 'pOEyYwKtHJo'
};
const fetchUrl = 'https://youtube-browser-api.netlify.app/transcript?' + new URLSearchParams(query).toString()
// https://youtube-browser-api.netlify.app/transcript?videoId=pOEyYwKtHJo
fetch(fetchUrl)
    .then(res => res.json())
    .then(console.log)

Description

This YouTube API Wrapper website offers a simple and user-friendly interface to access YouTube's API. It is tailored to the needs of developers; it provides data through fully typed endpoints. Whether you need to extract video analytics, search for specific data, or extract transcripts, the API wrapper can help you do it quickly and easily.

License

This project is licensed under the MIT License.