xxzj990 / transmission_api

A Transmission client library for dart.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Adding as dependencies

    Pub.dev's installation guide

    Add this to your package's pubspec.yaml file:

    dependencies:
      transmission_api: latest
  2. Import it

    Now in your Dart code, you can use:

    import 'package:transmission_api/transmission_api.dart';
  3. Create Instance

    Now you need to create instance for Transmission and AuthKeys 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.
  4. 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 of Transmission instance Custom Logs

    final 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

visit offical API documentation

About

A Transmission client library for dart.

License:GNU General Public License v3.0


Languages

Language:Dart 100.0%