need help using an api

Discussion in 'Software' started by red death68, Feb 28, 2013.

  1. red death68

    red death68 Command Sergeant Major

    So basicly I am working on retrieving price data from a game they game provides an api for fan sites to use and I am looking for a way to incorperate it into my program here is a link to the api information. I am using java to write this I need a way to look up several items add them to different colums in a JTable. My main question is how would I utalize this api with java?

    If it matters apperently the api returns everything as JSON Strings
     
  2. PC-XT

    PC-XT Master Sergeant

    Sorry, I don't see a link. I used to have code for something like that. It may depend on the api, though. There are libraries that can parse most apis' results, or custom code may be relatively simple, if the api is.
     
  3. red death68

    red death68 Command Sergeant Major

  4. PC-XT

    PC-XT Master Sergeant

    Is this for an applet? Because of security protocols, most applets only talk with their own servers. You can get around this, but it would complicate the code. (You can either have your server retrieve the information and forward it to your applet, or JavaScript can do this.) Otherwise, it's pretty straightforward. First, you construct the url, which is just string manipulation. The api shows how to construct, say, "http://services.runescape.com/m=itemdb_rs/api/catalogue/detail.json?item=4798" for item#4798: "Adamant brutal." Next, retrieve the text from the url, and parse it as JSON. Here's some examples for the last two parts, using different libraries, which are probably best to use in this case:
    http://stackoverflow.com/questions/7467568/parsing-json-from-url
    http://stackoverflow.com/questions/4308554/simplest-way-to-read-json-from-a-url-in-java
    If you want more choices, there are more libraries: http://www.rojotek.com/blog/2009/05/07/a-review-of-5-java-json-libraries/ Even more are given in those comments.
    http://www.matjazcerkvenik.si/Site/Java::JSON.html shows another method for getting the url.
     
  5. red death68

    red death68 Command Sergeant Major

    Thank you I will review these tomorrow when I have some free time and post back if I need any more help. I am still a beginner when it comes to most programing.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds