stremio-api-client

1.6.0 • Public • Published

stremio-api-client

Facilitates the connection between the stremio-api and Stremio, with extras such as user/add-on sync and persistence.

Contains two main modules:

StremioAPIClient

This is a stateless module to request the stremio-api

It's constructed like this:

var StremioAPIClient = require('stremio-api-client').StremioAPIClient
var API = new StremioAPIClient(options)

Options:

  • endpoint - URL to the API, default is https://api.strem.io

  • authKey - session auth key, default is null

Methods:

  • request(method, params) - returns a promise

StremioAPIStore

This is a stateful class that, when created, would take care of persistance and sync of the user and her add-ons collection

It's constructed like this:

var StremioAPIStore = require('stremio-api-client').StremioAPIStore
var APIStore = new StremioAPIStore(options)

Options:

  • endpoint - URL to the API, default is https://api.strem.io

  • storage - a storage object with synchronous getJSON and setJSON properties

Properties:

APIStore.user - User object

APIStore.addons - AddonCollection

Methods:

NOTE: All the methods return promises

APIStore.login({ email, password, fbLoginToken }) - logs in; fbLoginToken is optional

APIStore.register({ email, password }) - registers a new user

APIStore.logout() - logs out

All of the above 3 methods change API.user and therefore will emit (upon success) user-change

APIStore.pushUser() - pushes the local API.user to the API; requires to be logged in

APIStore.pullUser() - pull the latest user from the API; requires to be logged in

pullUser() may emit user-change if the remote user is more recent

APIStore.pushAddonCollection() - pushes local API.addons collection to the API (via addonCollectionSet); requires to be logged in

APIStore.pullAddonCollection() - pulls the remote add-on collection (via addonCollectionGet), may emit addons-change or addons-different

Events:

user-change: emitted when the User is changed (by ID, i.e. completely different user)

addons-change: emitted when the add-on set (AddonCollection) is changed

addons-different: emitted when the add-on collection is different (compared through transportUrls)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.6.02latest

Version History

VersionDownloads (Last 7 Days)Published
1.6.02
1.5.60
1.5.50
1.5.40
1.5.30
1.5.20
1.5.10
1.5.00
1.4.10
1.4.00
1.3.10
1.3.00
1.2.120
1.2.110
1.2.101
1.2.80
1.2.60
1.2.50
1.2.40
1.2.30
1.2.20
1.2.10
1.2.00
1.1.00
1.0.10
0.1.00

Package Sidebar

Install

npm i stremio-api-client

Weekly Downloads

3

Version

1.6.0

License

MIT

Unpacked Size

17.2 kB

Total Files

10

Last publish

Collaborators

  • ivogeorgiev