From the version 0.4.0 NZBGet has supported XML-RPC and JSON-RPC. From the version 0.7.0 NZBGet has also supported JSON-P-RPC. RPC-protocols allow to control the server from other applications. Many programming languages have libraries, which make the usage of XML-RPC, JSON-RPC and JSON-P-RPC very simple. The implementations of all three protocols in NZBGet are equal: all methods are identical. You may choose the protocol, which is better supported by your programming language.
The RPC server uses HTTP authentication with username "nzbget" and the password from server's configuration file. The URL would be something like:
Security warning: HTTP authentication is not secure. Although the password is encoded using Base64 it is not encrypted.
This document describes the methods available in NZBGet version 0.6.0 and later.
Signature:
bool pause()
Pause download queue on server. This method is equivalent for command "nzbget -P".
Return value: Always "True".
| NZBGet version: | 0.7.0 | and after |
bool pause2()
Pause download queue on server via second pause register. This method is equivalent for command "nzbget -P D2".
Options "ParPauseQueue", "PostPauseQueue", "TaskX.Command=PauseDownload" and "TaskX.Command=UnpauseDownload" use the so called first pause-register. To not interfere with the pause-state maintained by these commands the manual pause performed by user should use the second pause register.
Return value: Always "True".
Signature:
bool resume()
Resume (previously paused) download queue on server. This method is equivalent for command "nzbget -U".
Return value: Always "True".
| NZBGet version: | 0.7.0 | and after |
bool resume()
Resume (previously paused) download queue on server via second pause register. This method is equivalent for command "nzbget -U D2".
Return value: Always "True".
Signature:
bool shutdown()
Shutdown server. This method is equivalent for command "nzbget -Q".
Return value: Always "True".
Signature:
string version()
Request the version-string of server. This method is equivalent for command "nzbget -V".
Return value: Version string.
Signature:
bool rate(int Limit)
Set download speed limit. This method is equivalent for command "nzbget -R <Limit>".
Parameters:
Return value: "True" on success or "False" on failure.
Signature:
struct status()
Request for current status (summary) information. Parts of informations returned by this method can be printed by command "nzbget -L".
Return value: This method returns a structure with following fields:
| Field | Type | Description | |||
|---|---|---|---|---|---|
| RemainingSizeLo | int | Remaining size of all entries in download queue, in bytes. This field contains the low 32-bits of 64-bit value | |||
| RemainingSizeHi | int | Remaining size of all entries in download queue, in bytes. This field contains the high 32-bits of 64-bit value | |||
| RemainingSizeMB | int | Remaining size of all entries in download queue, in megabytes. | |||
| DownloadedSizeLo | int | Amount of data downloaded since server start, in bytes. This field contains the low 32-bits of 64-bit value | |||
| DownloadedSizeHi | int | Amount of data downloaded since server start, in bytes. This field contains the high 32-bits of 64-bit value | |||
| DownloadedSizeMB | int | Amount of data downloaded since server start, in megabytes. | |||
| DownloadRate | int | Current download speed, in Bytes per Second. | |||
| AverageDownloadRate | int | Average download speed since server start, in Bytes pro Second. | |||
| DownloadLimit | int | Current download limit, in Bytes pro Second. The limit can be changed via method "rate". Be aware of different scales used by the method rate (Kilobytes) and this field (Bytes). | |||
| ThreadCount | int | Number of threads running. It includes all threads, created by the program, not only download-threads. | |||
| ParJobCount | int | Number of ParJobs in Par-Checker queue (including current file). NOTE: deprecated, use PostJobCount instead. | |||
| PostJobCount | int | Number of Par-Jobs or Post-processing script jobs in the post-processing queue (including current file). | |||
| UrlCount | int |
| |||
| UpTimeSec | int | Server uptime in seconds. | |||
| DownloadTimeSec | int | Server download time in seconds. | |||
| ServerStandBy | boolean | "False" - there are currently downloads running, "True" - no downloads in progress (server paused or all jobs completed). | |||
| ServerPaused | boolean | "True" if server is currently in paused-state. NOTE: deprecated, use DownloadPaused instead. | |||
| DownloadPaused | boolean |
| |||
| Download2Paused | boolean |
| |||
| PostPaused | boolean |
| |||
| ScanPaused | boolean |
|
Signature:
array log(int IDFrom, int NumberOfEntries)
Request for screen-log. This method is similar to command "nzbget -G <NumberOfEntries>" but returns more information and can return lines from the specified log-ID. This method returns entries from server's screenlog-buffer. The size of this buffer is limited and can be set via option "LogBufferSize" in server's configuration file. Which messages should be saved to screenlog and which should be saved to log-file can be set via server's options InfoTarget, WarningTarget, ErrorTarget and DebugTarget in server's configuration file.
Parameters:
NOTE: only one parameter - either IDFrom or NumberOfEntries - can be specified. The other parameter must be "0".
TIP: If your application stores log-entries between subsequential calls to method log(), the usage of parameter IDFrom is recommended, since it reduces the amount of transferred data.
Return value: This method returns an array of structures with following fields:
| Field | Type | Description |
|---|---|---|
| ID | int | ID of log-entry. |
| Kind | string | Class of log-entry, one of the following strings: INFO, WARNING, ERROR, DEBUG. |
| Time | int | Time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds. This is what c-function "time" returns. |
| Text | string | Log-message. |
NOTE: if there are no entries for requested criteria, an empty array is returned.
Signature:
struct[] listfiles(int IDFrom, int IDTo, int NZBID)
Request for file's list. This method is similar to command "nzbget -L", but returns much more data for every file and does not return summary information (which can be requested via method status).
Parameters:
| NZBGet version: | 9.0 | and after |
If IDFrom and IDTo are submitted, the parameter NZBID must be 0. If NZBID is submitted, the parameters IDFrom and IDTo must be 0.
To get the list of all files from all groups set all parameters to 0;
Return value: This method returns an array of structures with following fields:
| Field | Type | Description | |||
|---|---|---|---|---|---|
| ID | int | ID of file. | |||
| NZBID | int |
| |||
| NZBFilename | string | Name of nzb-file. The filename could include fullpath (if client sent it by adding the file to queue). | |||
| NZBName | string |
| |||
| NZBNicename | string | The name of nzb-file without path and extension. Ready for user-friendly output. NOTE: deprecated, use NZBName instead. | |||
| Subject | string | Subject of article (read from nzb-file). | |||
| Filename | string | Filename parsed from subject. It could be incorrect since the subject not always correct formated. After the first article for file is read, the correct filename is read from article body. | |||
| FilenameConfirmed | boolean | "True" if filename was already read from article's body. "False" if the name was parsed from subject. For confirmed filenames the destination file on disk will be exactly as specified in field "filename". For unconfirmed filenames the name could change later. | |||
| DestDir | string | Destination directory for output file. | |||
| FileSizeLo | int | Filesize in bytes, Low 32-bits of 64-bit value. | |||
| FileSizeHi | int | Filesize in bytes, High 32-bits of 64-bit value. | |||
| RemainingSizeLo | int | Remaining size in bytes, Low 32-bits of 64-bit value. | |||
| RemainingSizeHi | int | Remaining size in bytes, High 32-bits of 64-bit value. | |||
| Paused | boolean | "True" if file is paused. | |||
| PostTime | int |
| |||
| Priority | int |
| |||
| ActiveDownloads | int |
|
NOTE: it is very unlikely to see a file larger than 2 GB in newsgroups. Large files are always posten in parts (mostly as rar-archives with part-size not greather than 100 MB). Therefore it is almoust safe to ignore fields FileSizeHi and RemainingSizeHi if your programming language does not support 64-bit integers.
Signature:
struct[] listgroups()
Request for groups' list. This method returns summary information for each file group. A group is a collection of files from one nzb-file.
Return value: This method returns an array of structures with following fields:
| Field | Type | Description | |||
|---|---|---|---|---|---|
| NZBID | int |
| |||
| FirstID | int | ID of the first file in download queue, belonging to the group. | |||
| LastID | int | ID of the last file in download queue, belonging to the group. | |||
| NZBFilename | string | Name of nzb-file, this file was added to queue from. The filename could include fullpath (if client sent it by adding the file to queue). | |||
| NZBName | string |
| |||
| NZBNicename | string | The name of nzb-file without path and extension. Ready for user-friendly output. NOTE: deprecated, use NZBName instead. | |||
| DestDir | string | Destination directory for output file. | |||
| Category | string | Category for group or empty string if none category is assigned. | |||
| FileSizeLo | int | Initial size of all files in group in bytes, Low 32-bits of 64-bit value. | |||
| FileSizeHi | int | Initial size of all files in group in bytes, High 32-bits of 64-bit value. | |||
| FileSizeMB | int | Initial size of all files in group in megabytes. | |||
| RemainingSizeLo | int | Remaining size of all (remaining) files in group in bytes, Low 32-bits of 64-bit value. | |||
| RemainingSizeHi | int | Remaining size of all (remaining) files in group in bytes, High 32-bits of 64-bit value. | |||
| RemainingSizeMB | int | Remaining size of all (remaining) files in group in megabytes. | |||
| PausedSizeLo | int | Size of all paused files in group in bytes, Low 32-bits of 64-bit value. | |||
| PausedSizeHi | int | Size of all paused files in group in bytes, High 32-bits of 64-bit value. | |||
| PausedSizeMB | int | Size of all paused files in group in megabytes. | |||
| FileCount | int | Initial number of files in group. | |||
| RemainingFileCount | int | Remaining (current) number of files in group. | |||
| RemainingParCount | int | Remaining (current) number of par-files in group. | |||
| MinPostTime | int |
| |||
| MaxPostTime | int |
| |||
| MinPriority | int |
| |||
| MaxPriority | int |
| |||
| ActiveDownloads | int |
| |||
| Parameters | array | Post-processing parameters for group. See below. |
Field Parameters is an array of structures with following fields:
| Field | Type | Description |
|---|---|---|
| Name | string | Name of post-processing parameter. |
| Value | string | Value of post-processing parameter. |
| NZBGet version: | 9.0 | and after |
struct[] urlqueue()
Request for list of items in URL-queue.
Return value: This method returns an array of structures with following fields:
| Field | Type | Description |
|---|---|---|
| ID | int | ID of URL in the queue. |
| NZBFilename | string | Name of nzb-file, if it was passed when the URL was added to queue. May be empty string. |
| URL | string | URL to download file from. |
| Name | string | The name of nzb-file without path and extension (if it was passed) or a part of the URL. Ready for user-friendly output. |
| Category | string | Category assigned to nzb-file when it is added to download queue (after downloading from URL). If the category is empty the category is read from HTTP-response which is usually returned from server hosting the nzb-file. |
| Priority | int | Priority assigned to nzb-file when it is added to download queue (after downloading from URL). |
Since the nzb-files are usually downloaded from URLs very fast, there are no commands provided to manage the URL-queue (delete, move items).
Signature:
struct[] postqueue(int NumberOfLogEntries)
Request for list of items in post-processor-queue.
Parameters:
Return value: This method returns an array of structures with following fields:
| Field | Type | Description | |||
|---|---|---|---|---|---|
| NZBID | int |
| |||
| InfoName | string | Text with user-friendly formatted name of item. For par-jobs consists of NZBNicename and of ParFilename. For script-jobs is equal to NZBNicename. | |||
| NZBFilename | string | Name of nzb-file, this file was added to queue from. The filename could include fullpath (if client sent it by adding the file to queue). | |||
| NZBName | string |
| |||
| NZBNicename | string | The name of nzb-file without path and extension. Ready for user-friendly output. NOTE: deprecated, use NZBName instead. | |||
| DestDir | string | Destination directory for output file. | |||
| ParFilename | string | Name of main par-file. For script-jobs this field is empty. | |||
| Stage | string | Indicate current stage of post-job. On of the predefined text constants: QUEUED, LOADING_PARS, VERIFYING_SOURCES, REPAIRING, VERIFYING_REPAIRED, EXECUTING_SCRIPT, FINISHED. The last constant (FINISHED) is very unlikely, because the post-jobs is deleted from queue right after it is completed. If nzb-file has no par-files or par-check is disabled the par-stages (LOADING_PARS..VERIFYING_REPAIRED) are skipped. If postprocess-script is not defined in program's options the stage EXECUTING_SCRIPT is skipped. | |||
| ProgressLabel | string | Text with short description of current action in post processor. For example: "Verifying file myfile.rar". | |||
| FileProgress | integer | Compeleting of current file. A number in the range 0..1000. Divide it to 10 to get percent-value. | |||
| StageProgress | integer | Compeleting of current stage. A number in the range 0..1000. Divide it to 10 to get percent-value. | |||
| TotalTimeSec | integer | Number of seconds this post-job is beeing processed (after it first changed the state from QUEUED). | |||
| StageTimeSec | integer | Number of seconds the current stage is beeing processed. | |||
| Log | array | Array of structs with log-messages. For description of struct see method log. |
NOTE: postprocessor executes only one job at a time - the first (top) job in post-queue. Fields ProgressLabel, FileProgress, StageProgress, TotalTimeSec, StageTimeSec and Log have meaning only for that job.
| NZBGet version: | 0.7.0 | and after |
struct[] history()
Request for list of items in history-list.
Return value: This method returns an array of structures with following fields:
| Field | Type | Description | |||
|---|---|---|---|---|---|
| ID | int |
| |||
| NZBID | int | ID of history item. NOTE: deprecated, use ID instead. | |||
| Kind | string |
| |||
| NZBFilename | string | Name of nzb-file, this file was added to queue from. The filename could include fullpath (if client sent it by adding the file to queue). | |||
| Name | string |
| |||
| NZBNicename | string | The name of nzb-file without path and extension. Ready for user-friendly output. NOTE: deprecated, use Name instead. | |||
| URL | string |
| |||
| DestDir | string | Destination directory for output files. | |||
| Category | string | Category for group or empty string if none category is assigned. | |||
| FileSizeLo | int | Initial size of all files in group in bytes, Low 32-bits of 64-bit value. | |||
| FileSizeHi | int | Initial size of all files in group in bytes, High 32-bits of 64-bit value. | |||
| FileSizeMB | int | Initial size of all files in group in megabytes. | |||
| FileCount | int | Initial number of files in group. | |||
| RemainingFileCount | int | Number of parked files in group. If this number is greater than "0", the history item can be returned to download queue using command "HistoryReturn" of method "editqueue". | |||
| HistoryTime | int | Date/time when the file was added to history(Timestamp in Unix format). | |||
| ParStatus | string | Result of par-check/repair. One of the predefined text constants: NONE, FAILURE, REPAIR_POSSIBLE, SUCCESS. | |||
| ScriptStatus | string | Result of post-processing script. One of the predefined text constants: NONE, UNKNOWN, FAILURE, SUCCESS. | |||
| UrlStatus | string |
| |||
| Parameters | array | Post-processing parameters for group. For description of struct see method listgroups. | |||
| Log | array | Log-messages added to history item by a post-processing script. For description of struct see method log. |
Signature:
bool editqueue(string Command, int Offset, string EditText, int[] IDs)
Pause/unpause/move/delete files or groups. This method is equivalent for command "nzbget -E <args>".
Parameters:
| Command | Description | |||
|---|---|---|---|---|
| FileMoveOffset | Move files to Offset relative to the current position in queue. | |||
| FileMoveTop | Move files to top of queue. | |||
| FileMoveBottom | Move files to bottom of queue. | |||
| FilePause | Pause files. | |||
| FileResume | Resume (unpause) files. | |||
| FileDelete | Delete files. | |||
| FilePauseAllPars | Pause only pars (does not affect other files). | |||
| FilePauseExtraPars | Pause only pars, except main par-file (does not affect other files). | |||
| FileSetPriority |
| |||
| FileReorder |
| |||
| GroupMoveOffset | Move groups to Offset relative to the current position in queue. | |||
| GroupMoveTop | Move groups to top of queue. | |||
| GroupMoveBottom | Move groups to bottom of queue. | |||
| GroupPause | Pause groups. | |||
| GroupResume | Resume (unpause) groups. | |||
| GroupDelete | Delete groups. | |||
| GroupPauseAllPars | Pause only pars (does not affect other files). | |||
| GroupPauseExtraPars | Pause only pars, except main par-file (does not affect other files). | |||
| GroupSetPriority |
| |||
| GroupSetCategory | Set category for group. | |||
| GroupMerge | Merge groups. | |||
| GroupSetParameter | Set post-processing parameter for group. | |||
| GroupSetName |
| |||
| PostMoveOffset |
| |||
| PostMoveTop |
| |||
| PostMoveBottom |
| |||
| PostDelete |
| |||
| HistoryDelete |
| |||
| HistoryReturn |
| |||
| HistoryProcess |
|
Return value: "True" on success or "False" on failure.
Signature:
bool append(string NZBFilename, string Category, int Priority, bool AddToTop, string Content)
Add nzb-file to download queue. This method is equivalent for command "nzbget -A [T] -K <category> <filename>".
Parameters:
Return value: "True" on success or "False" on failure.
| NZBGet version: | 9.0 | and after |
bool appendurl(string NZBFilename, string Category, int Priority, bool AddToTop, string URL)
Add URL to download queue. This method is similar to command "nzbget -A U [T] -K <category> <URL>".
Parameters:
NOTE: The command returns immediately after adding the URL to URL-queue before the actual file is downloaded.
Return value: "True" on success or "False" on failure.
Signature:
bool writelog(string Kind, string Text)
Append log-entry into server's log. This method is equivalent for command "nzbget -W <D|I|W|E|G> <text>".
Parameters:
Return value: Always "True".
Signature:
bool scan()
Request rescanning of incoming directory for nzb-files. This method is equivalent for command "nzbget -S".
Return value: Always "True".
| NZBGet version: | 9.0 | and after |
struct[] config()
Returns current configuration loaded into program. Please note that the configuration file on disk may differ from the loaded configuration. This may occur if the configuration file on disk was changed after the program was launched or the program may become some options passed via command line.
Return value: This method returns an array of structures with following fields:
| Field | Type | Description |
|---|---|---|
| Name | string | Option name. |
| Value | string | Option value. |
Notes:
| NZBGet version: | 9.0 | and after |
struct[] loadconfig(string domain)
Reads configuration file from the disk.
Parameters:
Return value: This method returns an array of structures with following fields:
| Field | Type | Description |
|---|---|---|
| Name | string | Option name. |
| Value | string | Option value. |
Notes:
| NZBGet version: | 9.0 | and after |
bool saveconfig(string domain, struct[] options)
Saves configuration file to the disk.
Parameters:
| Field | Type | Description |
|---|---|---|
| Name | string | Option name. |
| Value | string | Option value. |
Return value: "True" on success or "False" on failure.
The most comprehensive example on using XML-RPC and JSON-RPC with NZBGet is NZBGetWeb - web-interface for NZBGet, written in PHP. Look in download section for source code.
Two following examples show how to interact with NZBGet from Python using XML-RPC.
C:\>C:\Programme\Python25\python.exe
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from xmlrpclib import ServerProxy
>>> server = ServerProxy('http://nzbget:tegbzn6789@localhost:6789/xmlrpc')
>>> filename="C:\\ubuntu-7.10.nzb"
>>> in_file = open(filename, "r")
>>> nzbcontent = in_file.read()
>>> in_file.close()
>>> from base64 import standard_b64encode
>>> nzbcontent64=standard_b64encode(nzbcontent)
>>> server.append(filename, 'software', False, nzbcontent64)
True
>>>
C:\>C:\Programme\Python25\python.exe
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from xmlrpclib import ServerProxy
>>> server = ServerProxy('http://nzbget:tegbzn6789@localhost:6789/xmlrpc')
>>> server.log(1, 0)
[{'Text': 'nzbget server-mode', 'Kind': 'INFO', 'ID': 1, 'Time': 1202409509},
{'Text': 'Downloading ubuntu-7.10\ubuntu-7.10-desktop-i386.part04.rar [1/131]',
'Kind': 'INFO', 'ID': 2, 'Time': 1202409509},
{'Text': 'Downloading ubuntu-7.10\ubuntu-7.10-desktop-i386.part04.rar [2/131]',
'Kind': 'INFO', 'ID': 3, 'Time': 1202409509},
{'Text': 'Downloading ubuntu-7.10\ubuntu-7.10-desktop-i386.part04.rar [3/131]',
'Kind': 'INFO', 'ID': 4, 'Time': 1202409509},
{'Text': 'Downloading ubuntu-7.10\ubuntu-7.10-desktop-i386.part04.rar [4/131]',
'Kind': 'INFO', 'ID': 5, 'Time': 1202409509},
{'Text': 'Pausing download', 'Kind': 'INFO', 'ID': 6, 'Time': 1202409513}]
>>>