0.0.9 • Published 1 year ago

youtube-browser-api v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

JSONInterfaceSource Code
Examine the shape of the Response from a Video using a JSON ViewerThe autogenerated Interfaces for the playerResponse, videoData, apiToken, context and transcriptMetaThe source code from a YouTube Video website - how to
Dummy - SkeletonInspectview-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.

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago