sabnzbd-api
v1.5.0
Published
SABnzbd-API library written in TypeScript
Downloads
2,024
Readme
SABnzbd-API
SABnzbd API client written in TypeScript licensed under the MIT. It supports all of the API calls listed in the version 3.4.0 documentation (https://sabnzbd.org/wiki/advanced/api). It's still under active development and I welcome issue reports and pull requests.
Features
- Written in TypeScript
- Promise based API
- Supports adding files via multi-part form data using the FormData library.
Dependencies
- TypeScript
- Got v11.8.2+ (https://github.com/sindresorhus/got)
- FormData v4.0+ (https://github.com/form-data/form-data)
Installation
npm install --save sabnzbd-api
Documentation
You can find the API documentation at https://zordtk.github.io/sabnzbd-api/docs/, you should also read SABnzbd's API documentation at https://sabnzbd.org/wiki/advanced/api
Usage
version()
const SABnzbd = require("sabnzbd-api");
let client = new SABnzbd.Client("http://example.com/sabnzbd", "apikey");
client.version().then(version => {
console.log(version);
}).catch(error => {
console.log(error.message);
});
addUrl()
const SABnzbd = require("sabnzbd-api");
let client = new SABnzbd.Client("http://example.com/sabnzbd", "apikey");
client.addUrl('url-to-nzb').then(results => {
if( results.status )
console.log('Added NZB');
else
console.log('Failed to add NZB: ' + results.error);
}).catch(error => {
console.log(error.message);
});
addFile()
const SABnzbd = require("sabnzbd-api");
const fs = require("fs");
const FormData = require("form-data");
let client = new SABnzbd.Client("http://example.com/sabnzbd", "apikey");
let formData = new FormData();
formData.append("name", fs.createReadStream("/path/to/file"));
client.addFile(formData).then(results => {
if( results.status )
console.log('Added NZB');
else
console.log('Failed to add NZB: ' + results.error);
}).catch(error => {
console.log(error.message);
});
Todo
- Improve documentation