Skip to content

Sonarr Module API Explanation

The Sonarr module tracks television series library sizes and missing episode release queues.


API Execution Logic

The module locates the service matching the identifier sonarr. The API key is loaded from the SONARR_API_KEY environment variable and mapped to the X-Api-Key header.

Parallel Request Execution

To retrieve both the library size and missing item queues, the backend executes two parallel HTTP GET requests using Promise.all:

  1. Library Query: A request is sent to /api/v3/series to retrieve the list of all series in the library.
  2. Missing Queue Query: A request is sent to /api/v3/wanted/missing to retrieve missing episode records.

Data Parsing

  • Primary Metric: The total count of series in the library (calculated as the length of the series array).
  • Secondary Metric: The count of missing episode items (calculated as the length of the records array returned from the wanted endpoint).

Caching Strategy

The results are cached for 60 seconds (TTL) with a maximum stale window of 300 seconds. A timeout of 5 seconds is enforced per request.