mirror of
https://github.com/jellyfin/jellyfin-sdk-typescript.git
synced 2024-11-27 00:01:19 +00:00
TypeScript SDK for Jellyfin
f25f07f1b6
Bumps [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/HEAD/packages/typedoc-plugin-markdown) from 3.11.13 to 3.11.14. - [Release notes](https://github.com/tgreyuk/typedoc-plugin-markdown/releases) - [Changelog](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/typedoc-plugin-markdown/CHANGELOG.md) - [Commits](https://github.com/tgreyuk/typedoc-plugin-markdown/commits/typedoc-plugin-markdown@3.11.14/packages/typedoc-plugin-markdown) --- updated-dependencies: - dependency-name: typedoc-plugin-markdown dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> |
||
---|---|---|
.github | ||
.vscode | ||
docs | ||
scripts | ||
src | ||
.eslintignore | ||
.eslintrc.js | ||
.gitattributes | ||
.gitignore | ||
.npmignore | ||
codecov.yml | ||
jest.config.js | ||
LICENSE | ||
openapi.json | ||
openapitools.json | ||
package-lock.json | ||
package.json | ||
README.md | ||
tsconfig.json |
jellyfin-sdk-typescript
A TypeScript SDK for Jellyfin.
Warning: This project is under active development API changes may occur.
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 api.systemApi.getPublicSystemInfo();
console.log('Info =>', info.data);
// Fetch the list of public users
const users = await api.userApi.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 api.libraryApi.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