
# Stremio Addon SDK
**Build a [Stremio](https://www.stremio.com) addon in Node.js in minutes.**
[](https://app.travis-ci.com/github/Stremio/stremio-addon-sdk)
[](https://www.npmjs.com/package/stremio-addon-sdk)
[](https://www.npmjs.com/package/stremio-addon-sdk)
[](/LICENSE.md)
**[π Documentation](/docs)** Β· [Addon guide](https://stremio.github.io/stremio-addon-guide) Β· [Protocol spec](/docs/protocol.md) Β· [Report a bug](https://github.com/Stremio/stremio-addon-sdk/issues)
Stremio is a modern media center that discovers, organizes and streams video content through addons. An addon is a small HTTP service that answers a handful of JSON requests: which catalogs it offers, what an item is, and where to stream it from. This SDK gives you the builder, the HTTP server and the publishing tools so you only write the handlers. Stremio runs on Windows, macOS, Linux, Android and iOS, and one addon serves all of them.
## β¨ Features
- π§± **Builder API** β declare a manifest, define handlers for catalogs, metadata, streams and subtitles, done
- π **Serve or embed** β start a server with `serveHTTP`, or mount the addon as an Express router with `getRouter`
- π **CORS and caching handled** β the SDK sets the headers Stremio expects; you set the cache lifetimes
- π **Landing page** β every addon gets a homepage with an βInstallβ button out of the box
- π£ **Publishing** β `publishToCentral` submits your addon to the [public addon collection](https://api.strem.io/addonscollection.json)
- 𧬠**TypeScript types** β bundled since `1.6.10`, no `@types/stremio-addon-sdk` needed
- πΊ **Live TV guides** β catalogs with a programme schedule render as a native EPG, see [Native EPG](/docs/epg.md)
- βοΈ **User settings** β addons can ask for configuration through `manifest.config`, see [user data](/docs/api/responses/manifest.md#user-data)
## π Getting started
You'll need [Node.js](https://nodejs.org) 12 or newer.
### Scaffold an addon
```bash
npm install -g stremio-addon-sdk # use sudo on Linux
addon-bootstrap hello-world
cd hello-world
npm install
npm start -- --launch
```
`addon-bootstrap` asks which [resources and types](/docs/api/README.md) you want to support and generates a working addon. `--launch` opens Stremio Web with the addon installed; use `--install` to install it into the [desktop app](https://www.stremio.com/downloads) instead.
### Or write one by hand
This addon serves a single stream for Big Buck Bunny:
```javascript
const { addonBuilder, serveHTTP, publishToCentral } = require('stremio-addon-sdk')
const builder = new addonBuilder({
id: 'org.myexampleaddon',
version: '1.0.0',
name: 'simple example',
// Properties that determine when Stremio picks this addon:
// streams for items of type movie whose id starts with "tt"
catalogs: [],
resources: ['stream'],
types: ['movie'],
idPrefixes: ['tt']
})
builder.defineStreamHandler(function(args) {
if (args.type === 'movie' && args.id === 'tt1254207') {
const stream = { url: 'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4' }
return Promise.resolve({ streams: [stream] })
}
return Promise.resolve({ streams: [] })
})
serveHTTP(builder.getInterface(), { port: process.env.PORT || 7000 })
// publishToCentral('https://your-domain/manifest.json') // once the addon is publicly reachable
```
```bash
npm install stremio-addon-sdk
node ./addon.js
```
The process prints a URL you can use to [install the addon in Stremio](/docs/testing.md#how-to-install-addon-in-stremio). Addon URLs must be served over HTTPS with CORS enabled, except for `127.0.0.1`; the SDK handles CORS, HTTPS is up to your host.
## π How it works
Stremio never runs your code. The app reads your manifest, decides which addons are relevant for a request from their `types`, `idPrefixes` and catalog `extra` filters, and calls the matching resources over HTTP. The SDK turns those calls into handler invocations and turns your return values into protocol-conformant JSON.
```mermaid
flowchart LR
App["Stremio app