[API Question] How to use the API ?

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
RedFalcon
Newbie
Newbie
Posts: 4
Joined: October 22nd, 2010, 1:25 pm

[API Question] How to use the API ?

Post by RedFalcon »

Hello everyone,

this might be a simple question but i was wondering how i could use the API in Java?
Whenever i try to access the follow url i get an error:
url: http://localhost:8080/api?mode=qstatus& ... d05f70efe9
Java error: java.net.ConnectException: Connection refused: connect
Java code:

Code: Select all

try{	
	DocumentBuilderFactory dbfFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dbBuilder = dbfFactory.newDocumentBuilder();
	Document doc = dbBuilder.parse("http://localhost:8080/api?mode=qstatus&output=xml&apikey=711de66ca57dae90338267d05f70efe9");
	doc.getDocumentElement().normalize();
		
	System.out.println("Root element: " + doc.getDocumentElement().getNodeName());
} catch(Exception e){
	System.err.println(e);
}
result when i go to the site in my browser:

Code: Select all

<result>
    <status>False</status>
    <error>API Key Incorrect</error>
</result>
The output i was looking for should be "result" because the apikey entered is wrong and a wanted to read the entire xml file (but only printing out the first node name).

Could someone explain to me how to work with the api?

[edit]
Also adding the &ma_username=USERNAME&ma_password=PASSWORD didn't work (obviously i did enter the correct username and password. i used USERNAME and PASSWORD here just for example purposes).
[/edit]
Last edited by RedFalcon on October 22nd, 2010, 2:22 pm, edited 1 time in total.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: [API Question] How to use the API ?

Post by shypike »

If you look through the code of the Plush skin, you'll find plenty of examples.
/interfaces/Plush/templates/static/javascripts/
RedFalcon
Newbie
Newbie
Posts: 4
Joined: October 22nd, 2010, 1:25 pm

Re: [API Question] How to use the API ?

Post by RedFalcon »

shypike wrote: If you look through the code of the Plush skin, you'll find plenty of examples.
/interfaces/Plush/templates/static/javascripts/
thats javascript. I'm actually looking for java. I want to make a desktop application that can eg. read the entire queue.
rastoma
Newbie
Newbie
Posts: 22
Joined: October 21st, 2010, 12:47 pm

Re: [API Question] How to use the API ?

Post by rastoma »

RedFalcon wrote:
I want to make a desktop application that can eg. read the entire queue.
It's always good when people want to make addons and provide more functionality to opensource software.  I more so appreciate it because I don't have the programming knowledge to do it myself :)

But I'm just curious... how would a PC desktop app be better than the web interface?
RedFalcon
Newbie
Newbie
Posts: 4
Joined: October 22nd, 2010, 1:25 pm

Re: [API Question] How to use the API ?

Post by RedFalcon »

rastoma wrote:
RedFalcon wrote:
I want to make a desktop application that can eg. read the entire queue.
It's always good when people want to make addons and provide more functionality to opensource software.  I more so appreciate it because I don't have the programming knowledge to do it myself :)

But I'm just curious... how would a PC desktop app be better than the web interface?
It's not particularly better, but i prefer a desktop application instead of opening my web browser every time. Especially when all my downloads are already on and i just want to see the progress. A small application would be far faster than opening my browser.
RedFalcon
Newbie
Newbie
Posts: 4
Joined: October 22nd, 2010, 1:25 pm

Re: [API Question] How to use the API ? [solved]

Post by RedFalcon »

So i figured it out.

The problem was that sabnzbd wasn't accepted to the firewall yet.

This topic can be closed.
Last edited by shypike on October 24th, 2010, 1:45 pm, edited 1 time in total.
Post Reply