API to change server settings?

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
iop
Newbie
Newbie
Posts: 2
Joined: October 2nd, 2017, 9:23 am

API to change server settings?

Post by iop »

I wrote a small script to fetch the new login data to the server and stated in the documentation to the API i can insert/get/change the data i provided. But when i try the keyword param nothing gets returned. Is there someone who can help me with the API to change/set the new server data?

Greetings
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: API to change server settings?

Post by sander »

See https://sabnzbd.org/wiki/advanced/api starting from "Get config item(s)" at the bottom.

Example:

Code: Select all

$ curl 'http://127.0.0.1:8080/api?mode=get_config&section=servers&keyword=newszilla.xs4all.nl'
{u'servers': [{'username': u'nobody', 'priority': 0, 'enable': 0, 'displayname': u'newszilla.xs4all.nl', 'name': u'newszilla.xs4all.nl', 'notes': u'', 'connections': 4, 'ssl': 0, 'host': u'newszilla.xs4all.nl', 'timeout': 120, 'ssl_verify': 2, 'send_group': 0, 'password': '*******', 'optional': 0, 'port': 119, 'retention': 0}]}
iop
Newbie
Newbie
Posts: 2
Joined: October 2nd, 2017, 9:23 am

Re: API to change server settings?

Post by iop »

Code: Select all

&keyword=newszillaDOTxs4allDOTnl
That was it. I didnt know you have to insert the ServerName here. I tought the keyword=ServerName was a static var.

Thank you very much :)
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: API to change server settings?

Post by safihre »

It requires a section to be given. The keyword is not required, but helps to limit the results!

But for security, passwords are always displayed as *.
You can only set passwords, not read them.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Kiwifranky
Newbie
Newbie
Posts: 4
Joined: February 5th, 2014, 10:10 am

Re: API to change server settings?

Post by Kiwifranky »

Hi,

I also wanted to change the user and password of a server automatically by an external application.
Unfortunately when I use the following command it will create a new server which has only this parameter set, everything else is empty/default.
(FYI: There will be only one server in my list of servers)

http://{sabnzbd-address}/api?mode=set_config&section=servers&keyword=username&value={New name}

How can I achive this task?

Thanks in advance

Frank

P.S: Unfortunately the starter of the thread did only say he has got the problem solved, instead of publishing the solution for others that have the same problem :-(
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: API to change server settings?

Post by safihre »

In order to update a server, you need to specify the server name.
This is a bit hidden information, but you can find it in your sabnzbd.ini or by inspecting the source/requests from the Config > Servers page.

For example this is in my sabnzbd.ini because I have multiple servers with same hostname:

Code: Select all

[servers]
[[eunews.frugalusenet.com@2]]
blabla
In this case you have to also include the

Code: Select all

&server=eunews.frugalusenet.com@2
To indicate which server to update with new info.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: API to change server settings?

Post by safihre »

Actually I was even wrong before, sorry.
The `servers` one is a bit strange, but I think the command should look like this:

Code: Select all

 http://{sabnzbd-address}/api?mode=set_config&section=servers&keyword=eunews.frugalusenet.com@2&username=NEW_USERNAME&password=NEW_PASSWORD
Maybe I should add this info to the wiki..

EDIT: Added to wiki.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Kiwifranky
Newbie
Newbie
Posts: 4
Joined: February 5th, 2014, 10:10 am

Re: API to change server settings?

Post by Kiwifranky »

Just wanted to say thanks!

Worked great!

Franky
Post Reply