npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

transmission-ts

v0.0.3

Published

An opinionated Transmission RPC client for Node.js written in TypeScript

Downloads

8

Readme

Transmission TS

An opinionated Transmission RPC client for Node.js written in TypeScript 🧲

Installation

npm install transmission-ts

Usage

import { TransmissionClient } from "transmission-ts";

const client = new TransmissionClient();

You can also pass in a config object to the constructor to configure the connection to the Transmission RPC server, all of the following are optional:

  • host: The host of the Transmission RPC server. Defaults to localhost.
  • port: The port of the Transmission RPC server. Defaults to 9091.
  • protocol: The protocol of the Transmission RPC server. Defaults to http.
  • username: The username to use for authentication. Defaults to transmission.
  • password: The password to use for authentication. Defaults to transmission.
  • path: The path to the Transmission RPC server. Defaults to /transmission/rpc.

Add a torrent

You can add a torrent by passing in a magnet link

const torrent = await client.addMagnet({
  magnet: "magnet:?xt=urn:btih:..."
});

While adding a torrent you can also pass in any of the following options:

  • downloadDir: The directory where the downloaded contents will be saved in. Defaults to the default download directory configured in Transmission.
  • paused: Whether or not the torrent should be added in a paused state. Defaults to false.

List torrents

You can get all torrents or only some of them by specifying a list of ids:

// List all torrents currently in Transmission
const torrents = await client.getTorrents();
// List torrents with ids 1 and 2
const torrents = await client.getTorrents({
  ids: [1, 2],
});

When getting torrents you can also select which fields you want to receive by passing in a list of fields:

const torrents = await client.getTorrents({
  fields: ["id", "name", "status"],
});

A full list of fields can be found in the API reference. If you don't pass in any fields, all fields will be returned.

Remove torrents

You can remove torrents by passing in one or more ids:

// Remove torrent with id 1
await client.removeTorrents({
  ids: 1,
});
// Remove torrents with ids 1 and 2
await client.removeTorrents({
  ids: [1, 2],
});
// Remove torrent and delete downloaded data
await client.removeTorrents({
  ids: 1,
  deleteLocalData: true,
});

When removing torrents you can also specify whether or not you want to delete the downloaded data by setting the deleteLocalData option to true. Defaults to false.

When deleting torrents you can also specify whether or not you want to delete the downloaded data by setting the deleteLocalData option to true. Defaults to false.

Change torrent status

You can start one or more torrents by passing in one or more ids:

// Start torrent with id 1
await client.startTorrents({
  ids: 1,
});
// Start torrents with ids 1 and 2
await client.startTorrents({
  ids: [1, 2],
});

Optionally, you can also pass in a now option to start the torrent immediately:

await client.startTorrents({
  ids: 1,
  now: true,
});

You can also stop one or more torrents by passing in one or more ids:

// Stop torrent with id 1
await client.stopTorrents({
  ids: 1,
});
// Stop torrents with ids 1 and 2
await client.stopTorrents({
  ids: [1, 2],
});

Other methods

The following methods are also available:

  • getRecentlyActiveTorrents() - Gets the recently active torrents, this is useful to get a list of torrents that are currently present or have recently been deleted.
  • ping() - Pings the Transmission RPC server, this is useful to check if the remote server is reachable.
  • getSession() - Gets the current Transmission session information, this includes the Transmission daemon configuration.

For a full list of methods and their options, see the API reference.

License

This project is licensed under the MIT-0 License - see the LICENSE file for details.

Contributing

Contributions are welcome, however please open an issue first to discuss what you would like to change, thanks!

Notice

This package and the maintainers are not affiliated with the Transmission project in any way. Likewise, the existence of this package nor its open-source nature implies any endorsement towards piracy or download of copyrighted content via any means including but not limited to the usage of this package. Use of this package is entirely at your own risk and responsibility.