# twitch-m3u8

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

Latest version **1.1.5** (published 2021-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install twitch-m3u8
pnpm add twitch-m3u8
yarn add twitch-m3u8
bun add twitch-m3u8
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2021-11-18 |
| First published | 2018-06-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 111 |
| Author | Samuel Dudik |
| Maintainers | woafu |
| Keywords | twitch, m3u8, url, stream, vod, livestream |

## Links

- npm: https://www.npmjs.com/package/twitch-m3u8
- Repository: https://github.com/dudik/twitch-m3u8
- Homepage: https://github.com/dudik/twitch-m3u8#readme
- Issues: https://github.com/dudik/twitch-m3u8/issues
- npm.io page: https://npm.io/package/twitch-m3u8

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.1.5 (latest) — 2021-11-18
- 1.1.4 — 2021-01-20
- 1.1.3 — 2021-01-20
- 1.1.2 — 2021-01-20
- 1.1.1 — 2021-01-19
- 1.1.0 — 2021-01-19
- 1.0.6 — 2020-11-19
- 1.0.5 — 2019-01-14
- 1.0.4 — 2018-06-07
- 1.0.3 — 2018-06-07
- 1.0.2 — 2018-06-07
- 1.0.1 — 2018-06-07
- 1.0.0 — 2018-06-06

## README

# twitch-m3u8
> Get the stream URL of a Twitch livestream or past broadcast (VOD)

## Features
* Supports both livestreams and past broadcasts (VODs)    
* 0 dependencies   
* Promise-based    
* Can return raw .m3u8 data    

## Installation
[Node.js](https://nodejs.org/en/) required
```bash
npm install twitch-m3u8
```

## Usage
Doesn't require a Client-ID (from version 1.1.0).

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  
```js
const twitch = require("twitch-m3u8");

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

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

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

// returns raw .m3u8 data containing available streams of a VOD
twitch.getVod("877379571", true)
.then(data => console.log(data))
.catch(err => console.error(err));
```
Example output:
```js
[
    {
        quality: '1080p60 (source)',
        resolution: '1920x1080',
        url: 'https://...'
    },
    {
        quality: '720p60',
        resolution: '1280x720',
        url: 'https://...'
    },
    ...
]
```

## Credits
All reverse engineering of the GraphQL API was taken from the [streamlink](https://github.com/streamlink/streamlink) project. I just rewrote it for Node.js.

## Contribute
Did you find a bug? Do you have an idea or a feature request? [Open an issue!](https://github.com/dudik/twitch-m3u8/issues)

## License
[MIT](https://github.com/dudik/twitch-m3u8/blob/master/LICENSE) © Samuel Dudik

---
_Source: https://npm.io/package/twitch-m3u8 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
