2021-09-20 18:25:35 +00:00
< h1 align = "center" > jellyfin-sdk-typescript< / h1 >
2022-06-28 14:37:11 +00:00
< h3 align = "center" > Part of the < a href = "https://jellyfin.org" > Jellyfin Project< / a > < / h3 >
---
2021-09-20 18:25:35 +00:00
< p align = "center" >
2022-06-28 14:37:11 +00:00
< img alt = "Logo Banner" src = "https://raw.githubusercontent.com/jellyfin/jellyfin-ux/master/branding/SVG/banner-logo-solid.svg?sanitize=true" / >
< br / >
< br / >
< a href = "https://github.com/jellyfin/jellyfin-sdk-typescript/blob/master/LICENSE" > < img alt = "MPL-2.0 license" src = "https://img.shields.io/github/license/jellyfin/jellyfin-sdk-typescript" > < / a >
< a href = "https://github.com/jellyfin/jellyfin-sdk-typescript/releases" > < img alt = "Current Release" src = "https://img.shields.io/github/release/jellyfin/jellyfin-sdk-typescript.svg" / > < / a >
2022-09-15 04:36:44 +00:00
< a href = "https://www.npmjs.com/package/@jellyfin/sdk" > < img alt = "npm" src = "https://img.shields.io/npm/v/@jellyfin/sdk" > < / a >
2023-11-14 19:19:13 +00:00
< a href = "https://sonarcloud.io/component_measures?metric=coverage&id=jellyfin_jellyfin-sdk-typescript" >
< img alt = "Sonar Coverage" src = "https://img.shields.io/sonar/coverage/jellyfin_jellyfin-sdk-typescript/master?server=https%3A%2F%2Fsonarcloud.io" >
2021-09-20 18:25:35 +00:00
< / a >
< / p >
2021-09-14 05:20:14 +00:00
2021-09-14 05:44:53 +00:00
A TypeScript SDK for Jellyfin.
2022-02-25 12:52:36 +00:00
> Warning: This project is under active development, so API changes may occur.
2021-09-14 05:44:53 +00:00
2021-09-20 18:29:00 +00:00
## Install
```sh
2022-09-15 04:36:44 +00:00
npm i --save @jellyfin/sdk
2021-09-20 18:29:00 +00:00
```
or
```sh
2022-09-15 04:36:44 +00:00
yarn add @jellyfin/sdk
2021-09-20 18:29:00 +00:00
```
2022-06-17 19:26:14 +00:00
### Supported Jellyfin Versions
| SDK Version | Jellyfin Version |
|:-:|:-:|
2024-10-28 20:37:55 +00:00
| 0.11.0 | 10.10.x |
2024-06-03 19:57:08 +00:00
| 0.10.0 | 10.9.x |
2024-05-14 19:28:33 +00:00
| 0.9.0 | 10.9.x |
| 0.8.2 - 0.6.0 | 10.8.1 - 10.8.13 |
2022-07-14 17:46:51 +00:00
| 0.5.0 | 10.8.0 |
2022-06-17 19:26:14 +00:00
| < 0.5.0 | 10 . 7 . x |
2022-09-15 21:01:49 +00:00
> Note: Versions prior to 0.7.0 were published as `@thornbill/jellyfin-sdk`.
2021-10-14 18:48:51 +00:00
### 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.
2021-10-15 20:46:40 +00:00
[React Native URL Polyfill ](https://github.com/charpeni/react-native-url-polyfill ) seems like a good solution for this.
2021-10-14 18:48:51 +00:00
2021-09-14 05:20:14 +00:00
## Usage
```js
// Create a new instance of the SDK
2021-09-16 21:32:35 +00:00
const jellyfin = new Jellyfin({
clientInfo: {
name: 'My Client Application',
version: '1.0.0'
},
deviceInfo: {
name: 'Device Name',
id: 'unique-device-id'
}
});
2021-09-22 02:55:05 +00:00
// 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);
2021-09-14 05:20:14 +00:00
2022-12-06 17:46:13 +00:00
// Each API endpoint is represented by a class in the generated client.
// Helper utility functions are provided under `/lib/utils/api/` to create an
// instance of a specific Jellyfin API using the shared Configuration and Axios
// instance from the `api` object created above.
// For example, the SystemApi can be generated using the `getSystemApi`
// function in `/lib/utils/api/system-api` .
2021-09-14 05:20:14 +00:00
// Fetch the public system info
2022-06-17 07:06:32 +00:00
const info = await getSystemApi(api).getPublicSystemInfo();
2021-09-14 05:20:14 +00:00
console.log('Info =>', info.data);
// Fetch the list of public users
2022-06-17 07:06:32 +00:00
const users = await getUserApi(api).getPublicUsers();
2021-09-14 05:20:14 +00:00
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.
2021-09-21 14:30:24 +00:00
const auth = await api.authenticateUserByName('demo', '');
2021-09-14 05:20:14 +00:00
console.log('Auth =>', auth.data);
2021-09-16 21:41:17 +00:00
// Authentication state is stored internally in the Api class, so now
// requests that require authentication can be made normally
2022-06-17 07:06:32 +00:00
const libraries = await getLibraryApi(api).getMediaFolders();
2021-09-16 21:41:17 +00:00
console.log('Libraries =>', libraries.data);
2021-09-21 14:18:49 +00:00
// 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();
2021-09-14 05:20:14 +00:00
```
2021-10-18 15:00:27 +00:00
2022-06-17 18:33:08 +00:00
## Breaking Changes
2024-10-28 20:37:55 +00:00
### v0.11.0
* Updated OpenAPI spec for Jellyfin 10.10.0. [#816 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/816 )
2024-06-03 19:57:08 +00:00
### v0.10.0
* Updated build target to ES2018. [#712 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/712 )
2024-05-14 19:28:33 +00:00
### v0.9.0
* Updated OpenAPI spec for Jellyfin 10.9.1. [#694 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/694 )
2022-12-04 22:38:16 +00:00
### v0.8.0
* The library is now fully targeted to ES6/ES2015.
[#341 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/341 )
* Axios received a major version upgrade.
[#300 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/300 )
2022-09-15 21:01:49 +00:00
### v0.7.0
* Renamed package to @jellyfin/sdk .
[#262 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/262 )
2022-07-14 17:46:51 +00:00
### v0.6.0
* Updated OpenAPI spec for Jellyfin 10.8.1.
[#208 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/208 )
2022-06-17 18:33:08 +00:00
### v0.5.0
* Build directory is now `lib` instead of `dist` .
Any imports used that were previously in `dist` will need updated.
2022-06-28 14:37:11 +00:00
[#147 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/147 )
2022-06-17 18:33:08 +00:00
* Duplicated exports were removed.
Any imports may need updated if you referenced one of the duplicates.
2022-06-28 14:37:11 +00:00
[#148 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/148 )
2022-06-17 18:33:08 +00:00
* 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.
2022-06-28 14:37:11 +00:00
[#149 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/149 )
2022-06-17 18:33:08 +00:00
* `BaseItemKind` is now included in the generated client.
Imports will need updated.
2022-06-28 14:37:11 +00:00
[#187 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/187 )
2022-06-17 18:33:08 +00:00
2021-10-18 15:00:27 +00:00
## Roadmap to 1.0
2022-09-15 21:01:49 +00:00
* [x] Use custom generator templates for API versions [#231 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/231 ) (Currently uses sed to update the value could be improved.)
2023-03-24 15:43:17 +00:00
* [x] Automate OpenAPI spec updates using GitHub [#351 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/351 )
* [x] Create branch tracking unstable Jellyfin builds with automated builds [#354 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/354 )
2024-05-14 19:28:33 +00:00
* [x] Fix authentication header escaping [#564 ](https://github.com/jellyfin/jellyfin-sdk-typescript/pull/564 )
2023-03-24 15:43:17 +00:00
* [ ] Add WebSocket API support
* [ ] Add example projects for different ecosystems [#186 ](https://github.com/jellyfin/jellyfin-sdk-typescript/issues/186 )
2022-09-15 21:01:49 +00:00
* [ ] Add utility function for `getFile` [#164 ](https://github.com/jellyfin/jellyfin-sdk-typescript/issues/164 )
2023-03-24 15:43:17 +00:00
* [ ] More complete device profile generation utilities