Options
All
  • Public
  • Public/Protected
  • All
Menu

The SABnzbd API Client.

Hierarchy

  • Client

Index

Constructors

constructor

  • new Client(host: string, apiKey: string): Client
  • Create new API client connecting to the given host using the supplied apiKey.

    example
    const sabnzbd    = require("sabnzbd-api");
    let client       = new sabnzbd.Client("https://host.com/sabnzbd", "apikey");
    

    If your host requires HTTP authentication you can pass it in the host param

    example
    const sabnzbd    = require("sabnzbd-api");
    let client       = new sabnzbd.Client("https://user:password@host.com/sabnzbd", "apikey");
    

    Parameters

    • host: string

      Hostname of the SABnzbd server. Include HTTP/HTTPS prefix

    • apiKey: string

      API key from the SABnzbd configuration

    Returns Client

Properties

Private mApiKey

mApiKey: string

The API key for the SABnzbd server

Private mHost

mHost: string

The hostname of the SABnzbd server including protocol (HTTP/HTTPS)

Config Methods

getConfig

  • getConfig(section?: string, keyword?: string): Promise<any>
  • You can read the whole configuration, a sub-set or a single setting.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • Optional section: string

      Section of the config item

    • Optional keyword: string

      The config item

    Returns Promise<any>

    Config item in JSON object

setConfig

  • setConfig(args: any): Promise<any>
  • Set configuration option

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • args: any

      JSON object with fields section, keyword, and value

    Returns Promise<any>

    JSON object with new config options if set

setConfigDefault

  • setConfigDefault(keyword: string | string[]): Promise<Results>
  • Reset config item to default value

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • keyword: string | string[]

    Returns Promise<Results>

    Results containing the status

History Methods

history

  • history(start?: number, limit?: number, category?: string, search?: string, nzoIds?: string[], failedOnly?: boolean, lastHistoryUpdate?: number): Promise<History>
  • Full history output with details about all jobs. The queue and the history output share many common fields, but the history also contains statistiscs about how much has been downloaded in the past day, week, month and total.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • Optional start: number

      Index of job to start at

    • Optional limit: number

      Number of jobs to display

    • Optional category: string

      Only return jobs in this category

    • Optional search: string

      Filter job names by search term

    • Optional nzoIds: string[]

      Filter jobs by nzo_ids

    • Optional failedOnly: boolean

      Only show failed jobs

    • Optional lastHistoryUpdate: number

      Only return full output if anything has changed since lastHistoryUpdate, the last update is given by a previous call to history

    Returns Promise<History>

    The history

historyDelete

  • historyDelete(id: string | string[]): Promise<Results>
  • Delete history items(s) based on nzo_id

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string | string[]

      nzo_id of the item(s) to delete

    Returns Promise<Results>

    Results containing the status

historyDeleteAll

  • historyDeleteAll(): Promise<Results>
  • Delete all history items(s)

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

historyDeleteAllFailed

  • historyDeleteAllFailed(): Promise<Results>
  • Delete all failed history items(s)

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

historyRetry

  • historyRetry(id: string, password?: string): Promise<Results>
  • Retry history item(s) based on nzo_id Optionally provide a password for unpacking.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      nzo_id of the history item

    • Optional password: string

      Password for unpacking

    Returns Promise<Results>

    Results containing the status

historyRetryWithNZB

  • historyRetryWithNZB(id: string, formData: FormData, password?: string): Promise<Results>
  • Retry history item(s) based on nzo_id and an additional NZB set to the nzbfile field. Optionally provide a password for unpacking.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      nzo_id of the history item

    • formData: FormData

      New NZB to upload

    • Optional password: string

      Password for unpacking

    Returns Promise<Results>

    Results containing the status

Misc Methods

auth

  • auth(): Promise<string[]>
  • Get authentication methods available for interaction with the API

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<string[]>

    An array of auth methods

getCats

  • getCats(): Promise<string[]>
  • Get all categories

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<string[]>

    An array of strings containing the categories

getScripts

  • getScripts(): Promise<string[]>
  • Get all scripts

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<string[]>

    An array of strings containing the scripts

pausePostProcessing

  • pausePostProcessing(): Promise<Results>
  • Pause post-processing queue

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

resetQuota

  • Reset the user defined quota to 0

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

restart

  • Restart SABnzbd

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

restartRepair

  • restartRepair(): Promise<Results>
  • Restart SABnzbd and perform a queue repair

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

rssNow

  • Fetch and process all RSS feeds

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

shutdown

  • Shutdown SABnzbd

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

translateText

  • translateText(text: string): Promise<string>
  • Translate any text known to SABnzbd from English to the locale setting of the user.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • text: string

      The text to translate

    Returns Promise<string>

    The translated text

version

  • version(): Promise<string>
  • Get version of running SABnzbd

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<string>

    String containing the version information

warnings

  • Get all active warnings

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<ErrorWarning[]>

    An array of ErrorWarning describing all warnings.

warningsClear

  • warningsClear(): Promise<Results>
  • Clear all active warnings

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

watchedNow

  • Scan Watched Folder now

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

Other Methods

addFile

  • addFile(formData: FormData, name?: string, password?: string, cat?: string, script?: string, priority?: Priority, postProcess?: PostProcessing): Promise<Results>
  • Upload NZB using POST multipart/form-data with the FormData library. You must set the file data to either the name or nzbfile field.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • formData: FormData

      The FormData with the file in either the name or nzbfile field.

    • Optional name: string

      Name of the job, if empty NZB filename is used.

    • Optional password: string

      Password to use when unpacking the job.

    • Optional cat: string

      Category to be assigned, * means Default. List of available categories can be retrieved from getCats.

    • Optional script: string

      Script to be assigned, Default will use the script assigned to the category. List of available scripts can be retrieved from getScripts.

    • Optional priority: Priority

      Priority to be assigned, one of Priority

    • Optional postProcess: PostProcessing

      Post-processing options, one of PostProcessing

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

addPath

  • addPath(filePath: string, name?: string, password?: string, cat?: string, script?: string, priority?: Priority, postProcess?: PostProcessing): Promise<Results>
  • Upload NZB from a location on the file system that SABnzbd can access.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • filePath: string

      Path to the file to add

    • Optional name: string

      Name of the job, if empty NZB filename is used.

    • Optional password: string

      Password to use when unpacking the job.

    • Optional cat: string

      Category to be assigned, * means Default. List of available categories can be retrieved from getCats.

    • Optional script: string

      Script to be assigned, Default will use the script assigned to the category. List of available scripts can be retrieved from getScripts.

    • Optional priority: Priority

      Priority to be assigned, one of Priority

    • Optional postProcess: PostProcessing

      Post-processing options, one of PostProcessing

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

addUrl

  • addUrl(url: string, name?: string, password?: string, cat?: string, script?: string, priority?: Priority, postProcess?: PostProcessing): Promise<Results>
  • Add NZB using an URL that needs to be accessible by SABnzbd, so make sure to include authentication information if the Indexer requires it.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • url: string

      URL of the NZB file to add

    • Optional name: string

      Name of the job, if empty NZB filename is used.

    • Optional password: string

      Password to use when unpacking the job.

    • Optional cat: string

      Category to be assigned, * means Default. List of available categories can be retrieved from getCats.

    • Optional script: string

      Script to be assigned, Default will use the script assigned to the category. List of available scripts can be retrieved from getScripts.

    • Optional priority: Priority

      Priority to be assigned, one of Priority

    • Optional postProcess: PostProcessing

      Post-processing options, one of PostProcessing

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

changeCat

  • changeCat(id: string, category: string): Promise<Results>
  • Change category of job with nzo_id. List of available categories can be retrieved from getCats.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      The nzo_id of the Job to change

    • category: string

      The name of the category

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

changeCompleteAction

  • changeCompleteAction(action: string): Promise<Results>
  • Set an end-of-queue action

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • action: string

      Either one of CompleteAction or a string contaning the name of a script to execute. Prefix the script name with script_ example: script_process.py

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

changePostProcessing

  • Change post-processing of job.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      The nzo_id of the Job to change

    • postProcessing: PostProcessing

      The PostProcessing level

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

changePriority

  • Change priority of job.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      The nzo_id of the Job to change

    • priority: Priority

      The priority

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

changeScript

  • changeScript(id: string, script: string): Promise<Results>
  • Change script of job with nzo_id. List of available scripts can be retrieved from getScripts.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      The nzo_id of the Job to change

    • script: string

      The script name

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

fullStatus

  • fullStatus(): Promise<Status>
  • Get all status information available from SABnzbd.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Status>

    Status

getFiles

  • getFiles(id: string): Promise<File[]>
  • Get files of job

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      The nzo_id of the Job

    Returns Promise<File[]>

    Any array of File

historyRetryAll

  • historyRetryAll(): Promise<Results>
  • Will retry all failed jobs in the history. However, you are not able to supply passwords or extra NZB's.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status

jobChangeName

  • jobChangeName(id: string, newName: string, password?: string): Promise<Results>
  • Change name and optionally the password of job with nzo_id.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      nzo_id of the Job

    • newName: string

      New name for the job

    • Optional password: string

      Optional password to be used during unpacking

    Returns Promise<Results>

    {@link Results.Status} set to true or false if the call was successful

jobDelete

  • jobDelete(id: string | string[]): Promise<Results>
  • Delets jobs based on its nzo_id. Returns list of affected nzo_ids.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string | string[]

      Either a string containing one nzo_id or a array of nzo_ids

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

jobDeleteAll

  • Delete all jobs

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

jobMove

  • jobMove(firstId: string, secondId: string): Promise<any>
  • Job's can be switched by providing 2 nzo_id, firstId is the item you want to move, secondId is the id of the job where you want to put value one above, shifting job secondId down.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • firstId: string

      nzo_id of job to move

    • secondId: string

      nzo_id of where you want to put the job, shifting this job down.

    Returns Promise<any>

jobPause

  • jobPause(id: string): Promise<Results>
  • Pause a single job based on its nzo_id. Returns list of affected nzo_ids.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      The nzo_id of the Job to pause

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

jobResume

  • jobResume(id: string): Promise<Results>
  • Resumes a single job based on its nzo_id. Returns list of affected nzo_ids.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • id: string

      The nzo_id of the Job to resume

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

Private methodCall

  • methodCall(method: string, args?: any, output?: string): Promise<any>
  • Call method on SABnzbd server and parse results as a JSON object if output is json.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • method: string

      The api method to call

    • Optional args: any

      Either a JSON object or a URLSearchParams object containing the arguments

    • output: string = 'json'

      Output type either json or text

    Returns Promise<any>

    JSON object or string containing text depending on output

queue

  • queue(start?: number, limit?: number, search?: string, nzoIds?: string[]): Promise<Queue>
  • Full queue output with details about all jobs.

    throw

    Error throws error if unable to reach SABnzbd server

    Parameters

    • Optional start: number

      Index of job to start at

    • Optional limit: number

      Number of jobs to display

    • Optional search: string

      Filter jobs names by search term

    • Optional nzoIds: string[]

      Filter jobs by nzo_ids

    Returns Promise<Queue>

    Queue

queuePause

  • Pauses the whole queue

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

queuePurge

  • queuePurge(search?: string): Promise<Results>
  • Remove all jobs from the queue, or only the ones matching search. Returns nzb_id of the jobs removed.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • Optional search: string

      Filter jobs by search term

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

queueResume

  • Resume the whole queue

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Results>

    Results containing the status and affected nzo_ids.

queueSort

queueSpeedLimit

  • queueSpeedLimit(value: string): Promise<Results>
  • Sets the speedlimit to value in percentage of the maximum line speed (set by user).

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • value: string

      The speed limit value in either percentage. It can also be followed by K,M to define speedlimit in KB/s,MB/s, respectively.

    Returns Promise<Results>

    Results containing the status

showLog

  • showLog(): Promise<string>
  • The log file is automatically anonymized and a copy of the sabnzbd.ini is attached.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<string>

    The anonymized logs

status

  • status(skipDashboard?: Boolean, calculatePerformance?: Boolean): Promise<Status>
  • Get all status information available from SABnzbd.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • skipDashboard: Boolean = false

      Skip detecting public IPv4 address which can take some time.

    • calculatePerformance: Boolean = false

      Calculate performance measures

    Returns Promise<Status>

    Status

statusDeleteOrphaned

  • statusDeleteOrphaned(folder: string): Promise<Results>
  • Delete orphaned job based on the folder name from the status.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • folder: string

      Name of the folder

    Returns Promise<Results>

    Results containing the status

statusRetryOrphaned

  • statusRetryOrphaned(folder: string): Promise<Results>
  • Retry orphaned job based on the folder name from the status.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • folder: string

      Name of the folder

    Returns Promise<Results>

    Results containing the status

statusUnblockServer

  • statusUnblockServer(name: string): Promise<Results>
  • Unblock server based on servername from the status.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Parameters

    • name: string

      Name of the server to unblock

    Returns Promise<Results>

    Results containing the status

Stats Methods

serverStats

  • serverStats(): Promise<Stats>
  • Return download statistics in bytes, total and per-server.

    throw

    Error throws error if unable to reach SABnzbd server or an invalid response

    Returns Promise<Stats>

    Stats containing all the statistic information

Generated using TypeDoc