transmission_api
A Transmission client library for dart. To know more about transmission visit offical site
Thanks tmdb_api,most of the code comes from it.
Getting started
-
Adding as dependencies
Add this to your package's pubspec.yaml file:
dependencies: transmission_api: latest
-
Import it
Now in your Dart code, you can use:
import 'package:transmission_api/transmission_api.dart';
-
Create Instance
Now you need to create instance for
Transmission
andAuthKeys
with your api keys.final transmission = Transmission( //Transmission instance AuthKeys('Username', 'Password'),//AuthKeys instance with your keys, ); await transmission.v1.waitRpcVersion();// Get real rpc version,default 18.
-
Configuring console logs
There are 3 logconfigs presets avaliable.
ConfigLogger.showAll()
: development use.ConfigLogger.showRecommended()
: development use.ConfigLogger.showNone()
: production use.
You can add any off this presets to
logConfig
named parameter ofTransmission
instance Custom Logsfinal transmission = Transmission( AuthKeys('Username', 'Password'), logConfig: ConfigLogger( showLogs: true,//must be true than only all other logs will be shown showErrorLogs: true, ), );
Example
For getting torrents list
Map result = await transmission.v1.torrent.torrentGet(fields: TorrentFields.basic());
Custom Dio instance
final transmission = Transmission(
AuthKeys('Username', 'Password'),
dio:Dio()// your own dio instance
);
Adding Interceptors
final transmission = Transmission(
AuthKeys('Username', 'Password'),
interceptors:Interceptors()..add(/*your interceptor*/)
);
or
final customDio = Dio();
customDio.interceptors.add(/*your interceptor*/)
final transmission = Transmission(
AuthKeys('Username', 'Password'),
dio:dio
);
note:Use interceptors only when you are not using a custom Dio
instance.
For more API documentation
Libraries
- transmission_api
- A new dart transmission rpc library