Api

This is the start of new API documentation aimed at a future release.
The proposed API commands may not be implemented in current or SVN copies of sabnzbd.


Queue XML/JSON Output

Simple Queue Output - XML

URL: api?mode=qstatus&output=xml
Description: Depreciated now by the advanced queue output, this is the old api that just provides limited details on the current queue and state of sabnzbd
Example:

<?xml version="1.0" encoding="UTF-8" ?> 
<queue> 
    <paused>True</paused> 
    <kbpersec>0.0</kbpersec> 
    <mbleft>854.697840691</mbleft> 
    <mb>854.697840691</mb> 
    <noofslots>1</noofslots> 
    <diskspace1>21.980682373</diskspace1> 
    <diskspace2>21.980682373</diskspace2> 
    <timeleft>0:00:00</timeleft>     
    <jobs>
        <job> 
        <id>SABnzbd_nzo_zt2syz</id> 
        <msgid>3066202</msgid> 
        <filename>Ubuntu 8.04 (Hardy Heron) - Desktop CD x64</filename> 
        <mbleft>854.697840691</mbleft> 
        <mb>854.697840691</mb> 
        <index>0</index> 
        <unpackopts>3</unpackopts> 
        <cat>Apps</cat> 
        <script>snarl.exe</script> 
        <status>Queued</status> 
        <percentage>0</percentage> 
        <bytes>896215643.0</bytes> 
        </job>
    </jobs>
</queue>

Simple Queue Output - JSON

URL: api?mode=qstatus&output=json
Description: Depreciated now by the advanced queue output, this is the old api that just provides limited details on the current queue and state of sabnzbd
Example:

{
    "timeleft":"0:00:00",
    "mb":854.697841,
    "noofslots":1,
    "paused":true,
    "mbleft":854.697841,
    "diskspace2":21.980682,
    "diskspace1":21.980682,
    "kbpersec":0.000000,
    "jobs":[
        {"msgid":"3066202",
        "filename":
        "Ubuntu 8.04 (Hardy Heron) - Desktop CD x64",
        "mbleft":854.697841,"id":"SABnzbd_nzo_zt2syz",
        "mb":854.697841}
    ]
}

Advanced Queue Output - XML

URL: api?mode=queue&output=xml
Description: A verbose output that as well as reporting items in the queue, will report on finished items being processed (verify/repaired/extracted) and other details such as categories, scripts.
Example:

<?xml version="1.0" encoding="UTF-8" ?>
    <queue> 
        <mainqueue>
            <cache_limit>120</cache_limit>
            <cat_list>
                <item>None</item>
                <item>pda</item>
                <item>resources</item>
                <item>unknown</item>
                <item>consoles</item>
                <item>tv</item>
                <item>emulation</item>
                <item>games</item>
                <item>misc</item>
                <item>movies</item>
                <item>apps</item>
                <item>books</item>
                <item>music</item>
                <item>xxx</item>
            </cat_list>
            <script_list>
                <item>None</item>
                <item>notepad.cmd</item>
                <item>snarl.exe</item>
                <item>snarl.py</item>
                <item>test.cmd</item>
            </script_list>
            <paused>True</paused>
            <new_rel_url></new_rel_url>
            <web_name>smpl</web_name>
            <helpuri>http://sabnzbd.wikidot.com</helpuri>
            <uptime>1d</uptime>
            <refresh_rate></refresh_rate>
            <version>trunk</version>
            <diskspacetotal2>503.32</diskspacetotal2>
            <color_scheme>white.css</color_scheme>
            <new_release></new_release>
            <nt>True</nt>
            <status>Paused</status>
            <isverbose>False</isverbose>
            <cache_art>0</cache_art>
            <finishaction>None</finishaction>
            <noofslots>1</noofslots>
            <mbleft>854.70</mbleft>
            <diskspace2>21.98</diskspace2>
            <diskspace1>21.98</diskspace1>
            <diskspacetotal1>503.32</diskspacetotal1>
            <timeleft>0:00:00</timeleft>
            <mb>854.70</mb>
            <slotinfo>
                <slot>
                    <status>Downloading</status>
                    <index>0</index>
                    <eta>unknown</eta>
                    <timeleft>0:00:00</timeleft>
                    <avg_age>7d</avg_age>
                    <script>snarl.exe</script>
                    <msgid>3066202</msgid>
                    <mb>854.70</mb>
                    <bytes>896215643</bytes>
                    <filename>Ubuntu 8.04 (Hardy Heron) - Desktop CD x64</filename>
                    <priority>Normal</priority>
                    <cat>Apps</cat>
                    <mbleft>854.70</mbleft>
                    <percentage>0</percentage>
                    <nzo_id>SABnzbd_nzo_zt2syz</nzo_id>
                    <unpackopts>3</unpackopts>
                </slot>
            </slotinfo>
            <newzbinDetails>True</newzbinDetails>
            <nzb_quota></nzb_quota>
            <eta>unknown</eta>
            <kbpersec>0.00</kbpersec>
            <cache_size>0</cache_size>
        </mainqueue>
    </queue>

Advanced Queue Output - JSON

Not yet implemented


History XML/JSON Output

History Output

URL: api?mode=history&output=xml

<?xml version="1.0" encoding="UTF-8" ?> 
<slot>
    <status>Completed</status>
    <added>2008-09-22 03:25:56</added>
    <msgid>310000</msgid>
    <bytes>1548364578</bytes>
    <filename>Nzb Name</filename>
    <loaded>False</loaded>
    <stages>
        <slot>
            <name>Download</name>
            <actions>
                <slot>
                    <name>[Time-Taken]</name>
                    <value>15 minutes </value>
                </slot>
                <slot>
                    <name>[Avg-Speed]</name>
                    <value>1680kB/s</value>
                </slot>
            </actions>
        </slot>
        <slot>
            <name>Par2</name>
            <actions>
                <slot>
                    <name>[PAR-INFO] setname</name>
                    <value>=> Repaired in 110.1s</value>
                </slot>
                <slot>
                    <name>[DEL-INFO] setname</name>
                    <value>=> Deleted 7 file(s)</value>
                </slot>
            </actions>
        </slot>
        <slot>
            <name>Unrar</name>
            <actions>
                <slot>
                    <name>[RAR-INFO] setname-subs</name>
                    <value>=> Unpacked 4 file(s) in 1.6s</value>
                </slot>
                <slot>
                    <name>[RAR-INFO] setname-cd2</name>
                    <value>=> Unpacked 1 file(s) in 33.3s</value>
                </slot>
                <slot>
                    <name>[RAR-INFO] setname-cd1</name>
                    <value>=> Unpacked 1 file(s) in 33.2s</value>
                </slot>
                <slot>
                    <name>[DEL-INFO] setname-subs</name>
                    <value>=> Deleted 1 file(s)</value>
                </slot>
                <slot>
                    <name>[DEL-INFO] setname-cd2</name>
                    <value>=> Deleted 49 file(s)</value>
                </slot>
                <slot>
                    <name>[DEL-INFO] setname-cd1</name>
                    <value>=> Deleted 49 file(s)</value>
                </slot>
            </actions>
        </slot>
        <slot>
            <name>UserScript</name>
            <actions>
                <slot>
                    <name>[USER-SCRIPT]</name>
                    <value>
                    => <a href="./scriptlog?name=name.log">Show script output</a>
                    </value>
                </slot>
            </actions>
        </slot>
    </stages>
    <nzo>1222050356519</nzo>
</slot>

Other output

Return Categories - XML

URL: api?mode=get_cats&output=xml
Description:
Example:

<?xml version="1.0" encoding="UTF-8" ?> 
    <categories>
        <category>
            <id>0</id>
            <name>None</name>
        </category>
        <category>
            <id>1</id>
            <name>Video</name>
        </category>
    </categories>

Return Categories - JSON

URL: api?mode=get_cats&output=json
Description:
Example:

{"categories":["None","Video"]}

Return Scripts - XML

URL: api?mode=get_scripts&output=xml
Description:
Example:

<?xml version="1.0" encoding="UTF-8" ?> 
    <scripts>
        <script>
            <id>0</id>
            <name>None</name>
        </script>
        <scripts>
            <script>
            <id>2</id>
            <name>examplescript.cmd</name>
        </script>
    </scripts>

Return Scripts - JSON

URL: api?mode=get_scripts&output=json
Description:
Example:

{"scripts":["None","examplescript.cmd"]}

Queue Actions

Delete

Deleting a single item:
URL: api?mode=queue&name=delete&value=SABnzbd_nzo_zt2syz
Deleting multiple items:
URL: api?mode=queue&name=delete&value=SABnzbd_nzo_zt2syz,SABnzbd_nzo_df2hyd,SABnzbd_nzo_op3shf
Deleting all items:
URL: api?mode=queue&name=delete&value=all
Description:

Move

Swapping two items
URL: api?mode=switch&value=SABnzbd_nzo_zt2syz&value2=SABnzbd_nzo_df2hyd
Description: "value" is the item you want to move, "value2" is the name of the item where you want to put value one above, shifting value2 down.

Moving to a specific location in the queue.
URL: api?mode=switch&value=SABnzbd_nzo_zt2syz&value2=0
Description: "value2" is the position in the queue where you wish to move the object. 0 is the top of the queue, 1 is the second item, ect..

Pause

URL: api?mode=pause
Description: Pauses the whole queue (do not confuse this will pausing an individual download, this is a global pause)

Resume

URL: api?mode=resume
Description: Resumes the whole queue (do not confuse this will resuming an individual download, this is a global resume)

Shutdown

URL: api?mode=shutdown
Description: Shuts down SABnzbd.

Add by URL

Shortest:
URL: api?mode=addurl&name=http://www.example.com/example.nzb
Full:
URL: api?mode=addurl&name=http://www.example.com/example.nzb
Description: pp, script, cat and priority are all optional. This example adds the nzb into the queue marked as low priority, assigned with a categoriy of "Example", to execute "customscript.cmd" once finished, and with the unpacking option 3 (Repair, Unpack and Delete)

Add by newzbin ID

Full:
URL: api?mode=addid&name=333333&pp=3&script=customscript.cmd&cat=Example&priority=-1
Description: pp, script, cat and priority are all optional. This example will retrieve the newzbin post "33333" and instert it at low priority in the queue, assigned with a categoriy of "Example", to execute "customscript.cmd" once finished, and with the unpacking option 3 (Repair, Unpack and Delete)

Change Script

URL: api?mode=change_script&value=SABnzbd_nzo_zt2syz&value2=examplescript.cmd
Description:

Change Category

URL: api?mode=change_script&value=SABnzbd_nzo_zt2syz&value2=Example
Description:

Action on queue complete

URL: api?mode=queue&name=change_complete_action&value=hybernate_pc
Description: (For a script, append script_ to "value" such as "value=script_examplescript.cmd")

Change Priority

URL: api?mode=queue&name=priority&value=SABnzbd_nzo_zt2syz&value2=0
Description:
Low Priority: -1
Normal Priority: 0
High Priority: 1

Pause individual download

URL: api?mode=queue&value=pause&value2=SABnzbd_nzo_zt2syz
Description:

Resume individual download

URL: api?mode=queue&value=resume&value2=SABnzbd_nzo_zt2syz
Description:

Retrieve Contents of Queue item

URL: api?mode=get_files&output=xml&value=SABnzbd_nzo_zt2syz
Description:


History Actions

Delete

Deleting a single item:
URL: api?mode=history&name=delete&value=SABnzbd_nzo_zt2syz
Deleting multiple items:
URL: api?mode=history&name=delete&value=SABnzbd_nzo_zt2syz,SABnzbd_nzo_df2hyd,SABnzbd_nzo_op3shf
Deleting all items:
URL: api?mode=history&name=delete&value=all
Description:


Config Actions

Set Download Speed limit

URL: api?mode=config&name=speedlimit&value=400
Description:

page_revision: 10, last_edited: 1222110098|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License