API function to just test the connection and see if NZB key is correct?

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
User avatar
Tensai
Newbie
Newbie
Posts: 8
Joined: August 12th, 2020, 3:48 am

API function to just test the connection and see if NZB key is correct?

Post by Tensai »

Hi

I am the programmer of NZBDonkey which interacts with Sabnzbd via its API. As far as I know, there is no dedicated API function to just check the connection and see if the NZB key (or API key) is correct. Until version 2.3.9 I somehow misused the addurl function by sending an empty name which nevertheless resulted in status=true (and simply an empty array for the nzo_ids). With version 3.0.0 this has changed and Sabnzbd returns status=false and error="expects one parameter".

I therefore wonder which would be the proposed/best way to test the API connectivity with an NZB key (without actually doing anything to the settings, queue, etc.) which will result in a status=true response?

Looking forward to your help/suggestions.

Regards, Tensai
NZBDonkey
The ultimate NZB file downloader extension for Chrome and Firefox
Perfectly integrates with sabnzbd!
https://tensai75.github.io/NZBDonkey/
User avatar
safihre
Administrator
Administrator
Posts: 5366
Joined: April 30th, 2015, 7:35 am
Contact:

Re: API function to just test the connection and see if NZB key is correct?

Post by safihre »

You can still use it :)
The API-key check is performed before the "expects one parameter" check. So if you get "expects one parameter", the API/NZB-key is correct.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
Tensai
Newbie
Newbie
Posts: 8
Joined: August 12th, 2020, 3:48 am

Re: API function to just test the connection and see if NZB key is correct?

Post by Tensai »

Ok. Thanks for this info.

However, can I then count on it that the error message will always remain "expects one parameter" upon this API call with an empty name argument?
Because I will have to check for this error message explicitly to distinguish it from other errors.

In any case, a dedicated API function for the purpose of testing the NZB/API key (resulting in status=true) would be much more convenient.

Regards, Tensai
NZBDonkey
The ultimate NZB file downloader extension for Chrome and Firefox
Perfectly integrates with sabnzbd!
https://tensai75.github.io/NZBDonkey/
User avatar
safihre
Administrator
Administrator
Posts: 5366
Joined: April 30th, 2015, 7:35 am
Contact:

Re: API function to just test the connection and see if NZB key is correct?

Post by safihre »

If the API key is incorrect, it will give "API-key incorrect". So when it's not that, it should be good.
We don't have such a status-API and right now and don't see the exact need for it right now.
As we have also 5 different API-levels (for internal/external/non-NZB/etc), it would be an API that has to support all these checks.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
Tensai
Newbie
Newbie
Posts: 8
Joined: August 12th, 2020, 3:48 am

Re: API function to just test the connection and see if NZB key is correct?

Post by Tensai »

Ok, I'll work with what I get and implement an error check ;)

However, such a "access test" API endpoint would only be needed for external API access and simply needs to return status=true (or false) after key check is done.
Should be a pretty simple thing to implement.
And the need is definitely there. It is always beneficial for the user to have the possibility to test credentials/connectivity already in the settings instead of encounter the errors later when using the application. Therefore my Add-on gives the possibility to check the connection to Sabnzbd (and also the other supported programs) within the settings page. Other Apps do this similarly. And for this purpose an API endpoint is needed which checks the key but does not perform any other action.

Anyway, thanks for the help!

Tensai
NZBDonkey
The ultimate NZB file downloader extension for Chrome and Firefox
Perfectly integrates with sabnzbd!
https://tensai75.github.io/NZBDonkey/
Post Reply