About XML-RPC and JSON-RPC in NZBGet
Description of methods
pause
resume
shutdown
version
rate
status
log
listfiles
listgroups
postqueue
editqueue
append
Examples
From the version 0.4.0 NZBGet has supported XML-RPC and JSON-RPC. It allows to control the server from other applications. Many programming languages have libraries, which make the usage of XML-RPC and JSON-RPC very simple. The implementations of both 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:
for XML-RPC: http://nzbget:yourpassword@localhost:6789/xmlrpc
for JSON-RPC: http://nzbget:yourpassword@localhost:6789/jsonrpc
Security warning: HTTP authentication is not secure. Although the password is encoded using Base64 it is no encrypted.
This document describes the methods available in NZBGet-server.
Signature:
bool pause()
Pause server.
This method is equivalent for command "nzbget -P".
Return value:
Always "True".
Signature:
bool resume()
Resume (previously paused) server.
This method is equivalent for command "nzbget -U".
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:
Limit - new download speed limit in KBytes/second. Value "0" disables
speed throttling.
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 pro 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). |
UpTimeSec | int | Server uptime in seconds. |
DownloadTimeSec | int | Server download time in seconds. |
ServerPaused | boolean | "True" if server is currently in paused-state. |
ServerStandBy | boolean | "False" - there are currently downloads running, "True" - no downloads in progress (server paused or all jobs completed). |
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:
IDFrom - The first ID to be returned.
NumberOfEntries - Number of entries, which should be returned.
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)
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:
IDFrom - The first ID of file range to be returned. To return all files
set this parameter to 0;
IDTo - The first ID of file range to be returned.
Return value:
This method returns an array of structures with following fields:
| Field | Type | Description |
ID | int | ID of file. |
NZBFilename | string | Name of nzb-file. The filename could include fullpath (if client sent it by adding the file to queue). |
NZBNicename | string | The name of nzb-file without path, "msgid_"-prefix and extension. Ready for user-friendly output. |
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. |
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 |
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). |
NZBNicename | string | The name of nzb-file without path, "msgid_"-prefix and extension. Ready for user-friendly output. |
DestDir | string | Destination directory for output file. |
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. |
Signature:
struct[] postqueue(int NumberOfLogEntries)
Request for list of items in post-processor-queue.
Parameters:
NumberOfLogEntries - Number of log-entries, saved from post-process-script,
which should be returned for the top (currently processing item in post-processor-queue).
Return value:
This method returns an array of structures with following fields:
| Field | Type | Description |
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). |
NZBNicename | string | The name of nzb-file without path, "msgid_"-prefix and extension. Ready for user-friendly output. |
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.
Signature:
bool editqueue(string Command, int Offset, int[] IDs)
Pause/unpause/move/delete files or groups.
This method is equivalent for command "nzbget -E <args>".
Parameters:
Command - one of the following commands:
| 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). |
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). |
Offset - offset for commands FileMoveOffset and
GroupMoveOffset. For all other commands must be "0".
IDs - array of file-ids (as integers). File-commands need ID of
file. For group-command ID of any file in this group can be used, for example
filed FirstID or LastID of group-structure (the
using of LatsID is preferred, because the file with first ID has more chances
to be completed and deleted from queue before edit-command is received
by the server).
Return value:
"True" on success or "False" on failure.
Signature:
bool append(string NZBFilename, bool AddToTop, string Content)
Add nzb-file to download queue.
This method is equivalent for command "nzbget -A [T] <filename>".
Parameters:
NZBFilename - name of nzb-file. Server uses the name to build
destination directory. This name can contain fullpath or only filename.
AddToTop - "True" if the file should be added to the top of
the download queue or "False" if to the end.
Content - Content of nzb-file encoded with
Base64.
Return value:
"True" on success or "False" on failure.
The most comprehensive example on using XML-RPC and JSON-RPC with NZBGet would be 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.
|
|
|
Last updated: 8 Apr. 2008 Copyright © 2007-2008 - Andrei Prygounkov - all rights reserved |
|