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

utorrent-api

v0.1.5

Published

Interact with the uTorrent Web API

Downloads

25

Readme

node-utorrent-api

NPM

Node.js wrapper arround the uTorrent Web API.

Basic Usage

Here is the basic usage of this module. You can find an advanded list of methods supported by uTorrent Web UI API on their website.

First you need to instanciate a new client object, and then set the credentials used to connect to the uTorrent Web UI.

Then you can do your calls to the API.

Methods

Here are the available methods :

utorrent.setCredentials(username, password)

Set the credentials used to access the uTorrent Web UI.

utorrent.fetchToken(callback)

Fetch the token which will be used in each subsequent API calls. This method is directly called before an API call if needed, you don't need to call it by yourself.

Return an error to the callback, if an error occured when accessing the uTorrent API.

utorrent.call(action, [params], callback)

Call the specified API action. If the action do not require params (like 'list'), this argument can be ignored.

If you want to use the 'add-file' method, just specify a 'torrent_file' param with a buffer containing the torrent file to upload to the API.

Return an error to the callback (if one appeared) and an object containing the result sent back by the API.

Examples

Request the torrents list

var Client = require('utorrent-api');

var utorrent = new Client('localhost', '22222');
utorrent.setCredentials('admin', '123456');

utorrent.call('list', function(err, torrents_list) {
	if(err) { console.log(err); return; }

	console.log(torrents_list);
});

Add torrent file

var request = require('request');
var Client = require('utorrent-api');
var fs = require('fs');

var utorrent = new Client('localhost', '22222');
utorrent.setCredentials('admin', '123456');

request({'uri' : 'http://releases.ubuntu.com/13.04/ubuntu-13.04-desktop-i386.iso.torrent', 'encoding': null}, function (error, response, torrentFileBuffer) {
	utorrent.call('add-file', {'torrent_file': torrentFileBuffer}, function(err, data) {
		if(err) { console.log('error : '); console.log(err); return; }

		console.log('Successfully added torrent file !');
		console.log(data);
	});
});

Get torrent details

var Client = require('utorrent-api');
var fs = require('fs');

var utorrent = new Client('localhost', '22222');
utorrent.setCredentials('admin', '123456');

utorrent.call('getprops', {'hash': 'daac7008e2e3a6e4321950c131690aca20c5a08a'}, function(err, data) {
	if(err) { console.log('error : '); console.log(err); return; }

	console.log(data);
});

Bitdeli Badge