A type-safe, auto-generated Dart client for the Jellyfin Media Server API. This package provides comprehensive coverage of the Jellyfin API v10.11.0 with full type safety and Dart/Flutter compatibility.
β¨ Complete API Coverage - All 60+ Jellyfin API endpoints included π Type-Safe - Full type safety with generated models and enums π― Modern Dart - Built for Dart 3.9.0+ with null safety π± Flutter Compatible - Works seamlessly in Flutter applications π Auto-Generated - Generated from official Jellyfin OpenAPI specification π Dio-Powered - Uses Dio for efficient HTTP networking π MediaBrowser Auth - Native Jellyfin authentication with DeviceId, Version, and Token
Add this to your package's pubspec.yaml:
dependencies:
jellyfin_dart: ^0.1.0Then run:
dart pub getOr with Flutter:
flutter pub getimport 'package:jellyfin_dart/jellyfin_dart.dart';
void main() async {
// Create a client instance
final client = JellyfinDart(
basePathOverride: 'https://your-jellyfin-server.com',
);
// Set up MediaBrowser authentication
client.setMediaBrowserAuth(
deviceId: 'unique-device-id-12345', // Unique identifier for your client
version: '10.10.7', // Your app/client version
token: 'your-access-token', // Optional - required for authenticated endpoints
);
// Use any API endpoint
final systemApi = client.getSystemApi();
final response = await systemApi.getSystemInfo();
final info = response.data;
print('Connected to: ${info?.serverName}');
}Jellyfin uses MediaBrowser authentication with a custom Authorization header format.
final client = JellyfinDart(
basePathOverride: 'https://your-jellyfin-server.com',
);
// Option 1: Set all parameters at once (recommended)
client.setMediaBrowserAuth(
deviceId: 'unique-device-id-12345',
version: '10.10.7',
token: 'access-token', // Optional - add after login
);
// Option 2: Set parameters individually
client.setDeviceId('unique-device-id-12345');
client.setVersion('10.10.7');
client.setToken('access-token'); // Optionalfinal client = JellyfinDart(
basePathOverride: 'https://your-jellyfin-server.com',
);
// Setup device info before login
client.setDeviceId('unique-device-id-12345');
client.setVersion('10.10.7');
// Login with username and password
final userApi = client.getUserApi();
final authResponse = await userApi.authenticateUserByName(
authenticateUserByName: AuthenticateUserByName(
username: 'your-username',
pw: 'your-password',
),
);
// Set the token for authenticated requests
final token = authResponse.data?.accessToken;
if (token != null) {
client.setToken(token);
print('Logged in successfully!');
}Important Authentication Notes:
- DeviceId: Must be a unique identifier for your client/device. Generate once and store persistently.
- Version: Your application version (e.g., "1.0.0" or "10.10.7").
- Token: Access token from login. Required for authenticated endpoints, optional for public endpoints.
final itemsApi = client.getItemsApi();
final items = await itemsApi.getItems(
userId: 'user-id',
limit: 20,
sortBy: ['DateCreated'],
);final activityLogApi = client.getActivityLogApi();
final logs = await activityLogApi.getLogEntries(
startIndex: 0,
limit: 50,
);final searchApi = client.getSearchApi();
final results = await searchApi.get(
searchTerm: 'movie name',
userId: 'user-id',
);You can provide your own configured Dio instance:
final customDio = Dio(BaseOptions(
connectTimeout: Duration(seconds: 10),
receiveTimeout: Duration(seconds: 30),
));
final client = JellyfinDart(
dio: customDio,
basePathOverride: 'https://your-jellyfin-server.com',
);Add your own interceptors for logging, error handling, etc:
final client = JellyfinDart(
basePathOverride: 'https://your-jellyfin-server.com',
interceptors: [
LogInterceptor(responseBody: true),
// Your custom interceptors
],
);The client provides access to all Jellyfin APIs through factory methods:
| API Class | Access Method | Description |
|---|---|---|
| ActivityLogApi | getActivityLogApi() |
Activity log operations |
| ApiKeyApi | getApiKeyApi() |
API key management |
| ArtistsApi | getArtistsApi() |
Artist information |
| AudioApi | getAudioApi() |
Audio streaming |
| ItemsApi | getItemsApi() |
Library items |
| LibraryApi | getLibraryApi() |
Library management |
| PlaylistsApi | getPlaylistsApi() |
Playlist operations |
| SearchApi | getSearchApi() |
Search functionality |
| SessionApi | getSessionApi() |
Session management |
| UserApi | getUserApi() |
User management |
| VideosApi | getVideosApi() |
Video streaming |
| ... | ... | 60+ total APIs |
See the API documentation for complete endpoint coverage.
- Dart SDK:
>=3.9.0 <4.0.0 - Dependencies:
dio: ^5.7.0- HTTP clientjson_annotation: ^4.9.0- JSON serializationequatable: ^2.0.7- Value equalitycopy_with_extension: ^7.1.0- Copyable objects
All API calls can throw DioException. Handle them appropriately:
try {
final users = await userApi.getUsers();
print('Success: ${users?.length} users');
} on DioException catch (e) {
if (e.response != null) {
print('Server error: ${e.response?.statusCode}');
print('Error data: ${e.response?.data}');
} else {
print('Network error: ${e.message}');
}
}This package is auto-generated from the official Jellyfin OpenAPI specification using OpenAPI Generator.
Generator details:
- API Version: 10.11.0
- Generator: dart-dio (v7.16.0)
- OpenAPI Spec: Jellyfin stable
If you need to regenerate the client (for contributors):
make generateThis target will:
- Download the latest Jellyfin OpenAPI spec
- Generate Dart code
- Apply post-generation fixes
- Modify api.dart to use MediaBrowser authentication
- Format code
- Generate JSON serialization files
- Auto-generated code: While comprehensive, some edge cases in the OpenAPI spec may produce less-than-ideal code
- Large package size: Complete API coverage means this is a substantial package
- Breaking changes: Jellyfin API changes may introduce breaking changes in future versions
Contributions are welcome! This package is auto-generated, so most improvements should target:
- The Makefile (
make generatetarget) - Post-generation fixes (
tool/fix_issues.dart) - OpenAPI configuration (
openapi-config.yaml) - Documentation and examples
Please open issues at: https://github.com/devaryakjha/jellyfin-dart/issues
This project is licensed under the MIT License - see the LICENSE file for details.
The Jellyfin project itself is licensed under the GNU GPL. This client library is independently licensed under MIT.