Jump to content

Runescape API--.NET 4.0


geel9

Recommended Posts

CURRENT VERSION: Development 0.5

 

Hi guys! I'm Geel9, obviously, and I've been working on a Runescape API for .NET 4.0. It will, eventually, have all the features that you need to make a sick Runescape application. This is not released yet!

 

Requirements:

Using .NET 4.0

 

 

 

Classes so far:

  • Main--This does nothing for the programmer.
  • Highscores--Used to get Highscore info
  • GERequest--Used to get item prices
  • AdvLog---used to get a player's Adventurer's Log

 

 

 

 

 

 

 

Highscores Documentation

 

 

 

 

List<string> getPlayerStats(string username)

This returns a List<string> of the player's stats on the highscores, organized as such:

rank,level,experience

So, using getPlayerStats("geel9"), we'd get this(each new line is a different index in the List<string>)


271359,1680,19892015
501891,80,1986588
356390,80,2049194
674117,81,2193428
524442,82,2535620
808048,71,862653
347988,62,343981
458023,78,1631821
511026,75,1229818
1199423,72,959218
1025156,61,307352
681006,70,776987
805021,62,341688
368200,64,407219
385690,63,370343
942282,64,408310
218843,61,305852
271077,62,348847
149865,69,670244
310833,66,498125
186129,63,371423
307348,55,174781
450877,59,261531
221601,60,279390
213971,63,368840
95647,57,208762
-1,-1
-1,-1
-1,-1
-1,-1
-1,-1
150386,738
-1,-1
251180,510
25954,2451
-1,-1
-1,-1

 

Note that after a certain point, they only have two commas per skill. Those aren't skills, those are minigames, and are formatted as:

rank,score

 

Here's a fully commented example of using the Highscores.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RSapi;

namespace APItest
{
   class APItest
   {
       static void Main(string[] args)
       {
           //Make the list to hold our highscores
           List<string> scores = new List<string>();
           //Get the username to find
           Console.WriteLine("What is your username?");
           string username = Console.ReadLine();
           //Get the scores, and output them.
           scores = RSapi.Highscores.getPlayerStats(username);
           //If the username is found
           if (scores.Count > 0)
           {
               foreach (string l in scores)
               {
                   Console.WriteLine(l);
               }
           }
           Console.ReadLine();

       }
   }
}

 

 

 

GERequest Documentation

 

The GERequest class is an instance-based class, or rather, it's not static. You need to create an instance of it first.

 

Here's how it works.

 

GERequest(string search)

The GErequest class is what you use to make a GE price search. It takes a string in its constructor and uses that as the search.

Example:

GERequest request = new GERequest("dragon longsword");

 

 

List<string> getItems()

Returns the list of items that the GERequest found.

Example:

List<string> list = new List<string>();
list = request.getItems();

 

 

List<string> getPrices()

Returns the list of prices that the GERequest found. Note that the prices are just prices; to get the item names, you must use the same index as the price. For example, to get the item name of prices[4], use items[4].

 

 

List<string> getChange()

Returns the change in price for each item the GERequest found.

 

 

string getFirstItem()

Returns the first item the GERequest found.

 

string getFirstPrice()

Returns the price for the first item the GERequest found.

 

string getFirstChange()

Returns the change in price today for the first item the GERequest found.

 

 

 

Example of GERequest:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RSapi;

namespace APItest
{
   class APItest
   {
       static void Main(string[] args)
       {
           //Make the lists for our items, prices and price changes
           List<string> items = new List<string>();
           List<string> prices = new List<string>();
           List<string> changes = new List<string>();
           //Get the search term
           Console.WriteLine("What would you like to search for?");
           string search = Console.ReadLine();
           //Make a new GERequest instance and pass the search term to it.
           GERequest request = new GERequest(search);
           //Get the items from the request
           items = request.getItems();
           //Get the prices
           prices = request.getPrices();
           //Get the change in prices
           changes = request.getChange();
           //Print it all out
           if (items.Count > 0)
           {
               for (int i = 0; i < items.Count; i++)
               {
                   Console.WriteLine(items[i] + " cost(s) " + prices[i] + " and changed " + changes[i] + " today.");
               }
           }
           Console.ReadLine();
       }
   }
}

 

 

 

 

AdvLog

 

 

Nothing yet, working on it.

Link to comment
Share on other sites

Hmm, C# eh? I'm working with C++ right now so I couldn't quite help you yet, but best of luck with this.

I was going to eat hot dogs for dinner tonight. I think I will settle for cereal.

 

OPEN WIDE HERE COMES THE HELICOPTER.

Link to comment
Share on other sites

Looks good, could be useful for the runescape client im trying to build.

 

If you want any help with putting the results into a class structure instead of arrays and lists, I could try to throw something together for you?

 

e.g:

HighscoreResult result = RSapi.Highscores.getPlayerStats("username");
Console.WriteLine(result.Skills.Overall.Level);

instead of

List<string> result = RSapi.Highscores.getPlayerStats("username");
Console.WriteLine(result[0].split(',')[1]);

Link to comment
Share on other sites

  • 2 weeks later...

Are you sure that it requires .NET 4? At first glance it doesn't seem to use any of the more recent features - although there's obviously more that you haven't shown.

 

You may also want to get rid of the Linq using directive, I know Express builds automatically stick that in but it doesn't look like you're using it.

 

Would be nice to have this released - save many people re-writing small utility classes to do exactly what this does. I'd contribute if you Open Source it. :)

Link to comment
Share on other sites

Are you sure that it requires .NET 4? At first glance it doesn't seem to use any of the more recent features - although there's obviously more that you haven't shown.

 

You may also want to get rid of the Linq using directive, I know Express builds automatically stick that in but it doesn't look like you're using it.

 

Would be nice to have this released - save many people re-writing small utility classes to do exactly what this does. I'd contribute if you Open Source it. :)

 

System.Linq is only used in the examples, it's not in the API source.

Link to comment
Share on other sites

  • 4 weeks later...

This is what I used for the highscores lookup might help with your api. Taken from RS Regent Toolkit http://www.rsregent.net

WebClient stats = new WebClient();
               Stream statstream = stats.OpenRead("http://hiscore.runescape.com/index_lite.ws?player=" + RSN);
               StreamReader statread = new StreamReader(statstream);
               string sockread = null, sockline = null;
               int aa = 0;
               while ((sockread = statread.ReadLine()) != null)
               {
                   string[] bb = sockread.Split(new string[] { "," }, StringSplitOptions.None);
                   if (bb.Length == 3)
                   {
                       if (bb[0] != "-1")
                       {
                           int r = int.Parse(bb[0]), l = int.Parse(bb[1]), f = int.Parse(bb[2]);
                           string rank = String.Format("{0:0,0}", r), level = String.Format("{0:0,0}", l), exp = String.Format("{0:0,0}", e);
                           // sockline = SkillsArray[aa] + " " + "Rank: " + rank + " Level: " + level + " Exp: " + exp; aa++; Console.WriteLine(sockline);
                           hst[aa].Text = rank;
                           gst[aa].Text = level;
                           aa++;
                       }
                       else { aa++; }
                   }
                   else
                   {
                       if (bb[0] != "-1")
                       {
                           int r = int.Parse(bb[0]), l = int.Parse(bb[1]);
                           string rank = String.Format("{0:0,0}", r), level = String.Format("{0:0,0}", l);
                           // sockline = SkillsArray[aa] + " " + "Rank: " + rank + " Score: " + level; aa++; Console.WriteLine(sockline);
                           hst[aa].Text = rank;
                           gst[aa].Text = level;
                           aa++;
                       }
                       else { aa++; }
                   }

               }

               statstream.Close();
           }

       }

 

I have labels for Rank and Level Referenced in order hst = highscorestext, gst = level. Grabs the highscores lite data and splits it into separate strings and goes from there. Any questions I can probobly help you out.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.