A TypeScript SDK for Jellyfin.
Warning: This project is under active development API changes may occur.
npm i --save @thornbill/jellyfin-sdkor
yarn add @thornbill/jellyfin-sdkThe 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.
// 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();- 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