kauderk / youtube-browser-api

Retrieve YouTube data from your Browser

Home Page:https://youtube-browser-api.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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

📚 Response Reference - Your IDE will autocomplete everthing :)
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

📦 Visual Response Reference

Excalidraw Link


Code </>
// 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,
                        },
                    },
                },
            },
        },
    },
})
🚧 Keep in mind

For complex queries you may enable tsAny: true to bypass typechecking.
Help to solve the issue #1


Javascript
// 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.

Code </>
// typescript
import Api from 'youtube-browser-api'

const titleData = await Api.content({
    id: 'pOEyYwKtHJo',
    params: ['title'],
})
Javascript
// 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:

Code </>
// typescript
import Api from 'youtube-browser-api'

const mySearch = await Api.data('search', {
    keyword: 'AI',
    limit: 1,
})
Javascript
// 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:

Code </>
// typescript
import Api from 'youtube-browser-api'

const myTranscript = await Api.transcript({
    videoId: 'pOEyYwKtHJo',
})
Javascript
// 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.

About

Retrieve YouTube data from your Browser

https://youtube-browser-api.netlify.app/

License:MIT License


Languages

Language:TypeScript 91.2%Language:Svelte 8.0%Language:JavaScript 0.6%Language:HTML 0.2%Language:CSS 0.0%