Page 1 of 1

[API Question] How to use the API ?

Posted: October 22nd, 2010, 2:18 pm
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]

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

Posted: October 22nd, 2010, 2:40 pm
by shypike
If you look through the code of the Plush skin, you'll find plenty of examples.
/interfaces/Plush/templates/static/javascripts/

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

Posted: October 22nd, 2010, 3:58 pm
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.

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

Posted: October 22nd, 2010, 4:09 pm
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?

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

Posted: October 22nd, 2010, 4:28 pm
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.

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

Posted: October 24th, 2010, 12:48 pm
by RedFalcon
So i figured it out.

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

This topic can be closed.