This document describes the new Jellyfin API integration features added to KeeperCheky, providing enhanced monitoring and statistics capabilities.
GetActiveSessions)Purpose: Monitor real-time streaming activity on your Jellyfin server.
API Endpoint: GET /api/jellyfin/sessions
Response Example:
{
"sessions": [
{
"Id": "session-123",
"UserId": "user-456",
"UserName": "john_doe",
"Client": "Web",
"DeviceName": "Chrome",
"DeviceId": "device-789",
"ApplicationVersion": "10.8.13",
"RemoteEndPoint": "192.168.1.100",
"LastActivityDate": "2024-01-15T20:30:00Z",
"SupportsRemoteControl": true,
"NowPlayingItem": {
"Id": "movie-123",
"Name": "Inception",
"Type": "Movie",
"MediaType": "Video"
},
"PlayState": {
"PositionTicks": 36000000000,
"CanSeek": true,
"IsPaused": false,
"IsMuted": false,
"VolumeLevel": 100,
"AudioStreamIndex": 0,
"SubtitleStreamIndex": -1,
"MediaSourceId": "source-123",
"PlayMethod": "DirectPlay"
},
"TranscodingInfo": null
}
],
"count": 1
}
Use Cases:
Dashboard Integration:
GetLibraryStats)Purpose: Get comprehensive statistics about your Jellyfin media library.
API Endpoint: GET /api/jellyfin/stats
Response Example:
{
"total_items": 1250,
"movie_count": 450,
"series_count": 80,
"episode_count": 720,
"album_count": 0,
"song_count": 0,
"total_size": 5497558138880,
"library_folders": [
{
"Name": "Movies",
"Locations": ["/media/movies"],
"ItemId": "folder-123"
},
{
"Name": "TV Shows",
"Locations": ["/media/tv"],
"ItemId": "folder-456"
}
]
}
Use Cases:
Integration Points:
GetRecentlyAdded)Purpose: Track newly added content to your Jellyfin library.
API Endpoint: GET /api/jellyfin/recently-added?limit=20
Query Parameters:
limit (optional, default: 20): Number of items to returnResponse Example:
{
"items": [
{
"id": "movie-789",
"name": "The Matrix",
"type": "Movie",
"date_created": "2024-01-15T18:00:00Z",
"poster_url": "http://jellyfin:8096/Items/movie-789/Images/Primary?tag=abc123",
"overview": "A computer hacker learns..."
}
],
"count": 20
}
Use Cases:
Dashboard Integration:
GetActivityLog)Purpose: Retrieve server activity and event logs from Jellyfin.
API Endpoint: GET /api/jellyfin/activity?limit=50
Query Parameters:
limit (optional, default: 50): Number of entries to returnResponse Example:
{
"entries": [
{
"id": 12345,
"name": "AuthenticationSucceeded",
"type": "AuthenticationSuccess",
"user_id": "user-123",
"date": "2024-01-15T20:30:00Z",
"severity": "Info",
"short_overview": "User john_doe logged in"
},
{
"id": 12346,
"name": "SubtitleDownloadFailure",
"type": "SubtitleDownload",
"user_id": "",
"date": "2024-01-15T19:00:00Z",
"severity": "Error",
"short_overview": "Failed to download subtitle for Movie XYZ"
}
],
"count": 50
}
Use Cases:
Available for Integration:
Location: Dashboard page (appears when sessions are active)
Features:
Visual Indicators:
Location: Dashboard page (appears when items exist)
Features:
Visual Design:
The Settings page automatically displays detailed Jellyfin system information when testing the connection:
Displayed Information:
This information is retrieved via the existing GetSystemInfo() function and displayed in the standard system info card format.
The Files (Health) page already integrates Jellyfin playback data:
Existing Features:
Data Points Used:
has_been_watched: Boolean indicating if content was viewedlast_watched: Timestamp of last playback (if available)in_jellyfin: Whether the file exists in Jellyfin libraryFile: internal/service/clients/jellyfin.go
All new functions follow the same patterns:
callWithRetry() for resilient API callsFile: internal/service/sync_service.go
Type-safe wrapper methods:
func (s *SyncService) GetJellyfinActiveSessions(ctx context.Context) ([]clients.SessionInfo, error)
func (s *SyncService) GetJellyfinLibraryStats(ctx context.Context) (*clients.LibraryStats, error)
func (s *SyncService) GetJellyfinRecentlyAdded(ctx context.Context, limit int) ([]clients.RecentlyAddedItem, error)
func (s *SyncService) GetJellyfinActivityLog(ctx context.Context, limit int) ([]clients.ActivityLogEntry, error)
File: internal/handler/settings.go
RESTful HTTP handlers with proper:
File: cmd/server/main.go
// Jellyfin endpoints
api.Get("/jellyfin/stats", h.Settings.GetJellyfinStats)
api.Get("/jellyfin/sessions", h.Settings.GetJellyfinSessions)
api.Get("/jellyfin/recently-added", h.Settings.GetJellyfinRecentlyAdded)
api.Get("/jellyfin/activity", h.Settings.GetJellyfinActivity)
File: internal/service/clients/jellyfin_test.go
Comprehensive test coverage:
Run tests:
go test -v ./internal/service/clients/ -run TestJellyfin
Test Coverage: All new functions have unit tests with mocked HTTP responses.
No additional configuration is required. The new features automatically work when Jellyfin is enabled:
clients:
jellyfin:
enabled: true
url: "http://jellyfin:8096"
api_key: "your-api-key-here"
Or via environment variables:
JELLYFIN_ENABLED=true
JELLYFIN_URL=http://jellyfin:8096
JELLYFIN_API_KEY=your-api-key-here
Currently, no server-side caching is implemented. Consider:
Potential additions based on Jellyfin API capabilities:
Symptoms: Dashboard shows no sessions despite active playback
Checks:
GET /api/jellyfin/sessionsDebug:
curl http://localhost:8000/api/jellyfin/sessions
Symptoms: No items shown in recently added widget
Checks:
/api/jellyfin/recently-added?limit=20Symptoms: Item counts don’t match Jellyfin UI
Possible Causes:
Solution: Trigger a library refresh in Jellyfin and wait for completion
| Endpoint | Method | Parameters | Response |
|---|---|---|---|
/api/jellyfin/stats |
GET | None | Library statistics |
/api/jellyfin/sessions |
GET | None | Active sessions list |
/api/jellyfin/recently-added |
GET | limit (int) |
Recently added items |
/api/jellyfin/activity |
GET | limit (int) |
Activity log entries |
All endpoints return JSON and require Jellyfin to be configured in settings.
Last Updated: January 2025 Version: 1.0.0 Author: KeeperCheky Development Team