Skip to content

Get the stream URL of a Twitch livestream or past broadcast (VOD)

License

Notifications You must be signed in to change notification settings

ItsWilliam/twitch-m3u8

 
 

Repository files navigation

twitch-m3u8

Get the stream URL of a Twitch livestream or past broadcast (VOD)

Features

⚫ Supports both livestreams and past broadcasts (VODs)
⚫ Promise-based
⚫ Can return raw .m3u8 data

Installation

Node.js required

npm install twitch-m3u8

Usage

Twitch Client ID required. Register here.

Use this client-id: kimne78kx3ncx6brgo4mv6wki5h1ko

Functions getStream and getVod have an optional second boolean parameter which defaults to false (can be omitted). Setting it to:
true - function returns raw .m3u8 data
false - function returns an array of JSON objects containing the quality, resolution and URL of the stream

// replace clientID with your Twitch Client ID
const twitch = require('twitch-m3u8')(clientID);



// returns a JSON object containing available streams of a livestream
twitch.getStream(channelName)
.then(data => console.log(data))
.catch(err => console.error(err));

// returns a JSON object containing available streams of a VOD
twitch.getVod(vodID)
.then(data => console.log(data))
.catch(err => console.error(err));

// returns raw .m3u8 data containing available streams of a livestream
twitch.getStream(channelName, true)
.then(data => console.log(data))
.catch(err => console.error(err));

// returns raw .m3u8 data containing available streams of a VOD
twitch.getVod(vodID, true)
.then(data => console.log(data))
.catch(err => console.error(err));

Example output:

[
    {
        quality: '1080p60 (source)',
        resolution: '1920x1080',
        url: 'https://...'
    },
    {
        quality: '720p60',
        resolution: '1280x720',
        url: 'https://...'
    },
    ...
]

Contribute

Did you find a bug? Do you have an idea or a feature request? Open an issue!

License

MIT © Samuel Dudik

About

Get the stream URL of a Twitch livestream or past broadcast (VOD)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%