Sonarr API

Dart library package providing an abstraction for Sonarr's public API.

This package is intended to supply a 1:1 mapping of the public API documentation and does not make assumptions on orchestration to execute different workflows.

Preparing Sonarr

To connect to your instance of Sonarr, you will need:

  1. The host IPv4 address of the machine running Sonarr
  2. The API key of the Sonarr instance (which can be found in the web GUI under Settings → General)

Please note that in order to access Sonarr from another machine on the network you must ensure that both the Sonarr executable and the running port are allowed in any running firewalls on the host machine.

Connecting to the API

All classes, models, and types are exported in the main package file:

import 'package:sonarr_api/sonarr_api.dart';

Now you can instantiate an instance of SonarrConfig that is used to instantiate an instance of SonarrAPI:

final config = SonarrConfig(
  host: '192.168.1.100:7878',
  apiKey: 'asdf123',
);
final api = SonarrAPI(config);

You can optionally pass in a Dio BaseOptions instance to the configuration to customize the HTTP client. Note that the baseUrl property will be overwritten with the given host property in the configuration.

And you are ready to make API calls!

final series = await api.getSeries(); // Get the current catalogue of series
final queue = await api.getQueue();   // Get items in the queue
...

Additional Notes

  1. All available API methods can be viewed in the generated Dart documentation
  2. All models are immutable freezed-generated classes that can be modified using the <model>.copyWith(...) method
  3. All models are JSON serializable using the <model>.toJson() method