TypeScript SDK for Jellyfin
Go to file
Bill Thornton 86270ae3b8
Merge pull request #149 from thornbill/shake-that
Fix tree-shaking of the SDK
2022-06-17 03:17:03 -04:00
.github Bump actions/checkout from 2.4.0 to 3 2022-03-07 19:12:10 +00:00
.vscode Add config to let ESLint format and fix on save 2021-09-23 11:12:15 +02:00
docs Update documentation 2022-02-17 17:31:53 -05:00
scripts Fix openapi schema 2021-08-30 00:36:18 -04:00
src Fix tests 2022-06-17 03:06:49 -04:00
.eslintignore Move output directory to lib 2022-03-15 00:10:08 -04:00
.eslintrc.js Fix jest linting 2021-10-12 09:27:49 -04:00
.gitattributes Initial commit 2021-08-29 01:00:52 -04:00
.gitignore Move output directory to lib 2022-03-15 00:10:08 -04:00
.npmignore Use groups for integration and unit tests 2021-09-21 00:38:48 -04:00
codecov.yml Add codecov configuration 2021-09-20 15:58:00 -04:00
jest.config.js Remove url-parse dependency 2021-10-15 15:43:59 -04:00
LICENSE Update license 2021-09-14 01:10:15 -04:00
openapi.json Update openapi spec to 10.7.7 2021-09-16 00:33:29 -04:00
openapitools.json Initial commit 2021-08-29 01:00:52 -04:00
package-lock.json Bump ts-jest from 27.1.3 to 27.1.4 2022-03-29 21:51:56 -04:00
package.json Move output directory to lib 2022-03-15 00:10:08 -04:00
README.md Add breaking changes list and update example 2022-06-17 03:06:49 -04:00
tsconfig.json Move output directory to lib 2022-03-15 00:10:08 -04:00

jellyfin-sdk-typescript

MPL-2.0 license Current Release npm Codecov

A TypeScript SDK for Jellyfin.

Warning: This project is under active development, so API changes may occur.

Breaking Changes

v0.5.0

  • Build directory is now lib instead of dist. Any imports used that were previously in dist will need updated. #147
  • Duplicated exports were removed. Any imports may need updated if you referenced one of the duplicates. #148
  • API classes are no longer exposed via getters. Instead you need to call a function passing the Api instance as a parameter. For example: getSystemApi(api). While I do feel this is a slightly worse developer experience, it was a necessary change to support tree-shaking. #149

Install

npm i --save @thornbill/jellyfin-sdk

or

yarn add @thornbill/jellyfin-sdk

React Native

The generated Axios client used in this library depends on URL and URLSearchParams to be available on the global scope. React Native only includes incomplete implementations for these classes, so a polyfill is required. React Native URL Polyfill seems like a good solution for this.

Usage

// Create a new instance of the SDK
const jellyfin = new Jellyfin({
    clientInfo: {
        name: 'My Client Application',
        version: '1.0.0'
    },
    deviceInfo: {
        name: 'Device Name',
        id: 'unique-device-id'
    }
});

// Find a valid server by trying to connect using common protocols and ports.
// Each server receives a score based on security, speed, and other criteria.
const servers = await jellyfin.discovery.getRecommendedServerCandidates('demo.jellyfin.org/stable');
// A utility function for finding the best result is available.
// If there is no "best" server, an error message should be displayed.
const best = jellyfin.discovery.findBestServer(servers);

// Create an API instance
const api = jellyfin.createApi(best.address);

// Each API endpoint is exposed via a getter on the SDK instance using
// a shared Configuration and Axios instance. For example the /System APIs
// are available as api.systemApi.

// Fetch the public system info
const info = await getSystemApi(api).getPublicSystemInfo();
console.log('Info =>', info.data);

// Fetch the list of public users
const users = await getUserApi(api).getPublicUsers();
console.log('Users =>', users.data);

// A helper method for authentication has been added to the SDK because
// the default method exposed in the generated Axios client is rather
// cumbersome to use.
const auth = await api.authenticateUserByName('demo', '');
console.log('Auth =>', auth.data);

// Authentication state is stored internally in the Api class, so now
// requests that require authentication can be made normally
const libraries = await getLibraryApi(api).getMediaFolders();
console.log('Libraries =>', libraries.data);

// A helper method for logging out the current user has been added to the
// SDK so the internal state is updated correctly.
await api.logout();

Roadmap to 1.0

  • More complete device profile generation utilities
  • Use custom generator templates for API versions
  • Automate OpenAPI spec updates using GitHub
    • Create branch tracking unstable Jellyfin builds