Jump to content
YoHoJo

RSBotStats - Script Stat Tracking API | Easily Track Your Script Stats!

Recommended Posts

Runescape Bot Stats

RSBotStats is an API that allows scripters to easily track tasks their scripts have accomplished.
Add to your script with a simple JSON POST request. Use to showoff and market your script!

2kXcag3.png

Real stats from a cooking script!

Getting Started with the API

  • Sign up and add your script here
  • Find your API Key and Script ID here
  • Send a POST request to upload your stats. We recommending sending 1 request on script end.

Example Request

URL: http://pure-woodland-47666.herokuapp.com/api/v1/commits?user_email=YOUR_EMAIL&user_token=YOUR_API_KEY

Body:

{"commit":{
    "script_id": "X5VTnp",
    "user_id": "qN4tOb",
    "runtime": 75.666,
    "stats_attributes": [
        {
            "task": "Trout Caught",
            "amount": 28
        },
        {
            "task": "Lobster Caught",
            "amount": 70
        }]
}}

Parameter Notes

  • At the very least, a commit requires `script_id`, `user_id`, and `runtime`
  • `runtime` is in minutes
  • `stats_attributes` are for tracking any sorts of tasks your script does. ex: Fish Caught, Yews Chopped, XP Gained, GP gained, etc.
  • `user_id: qN4tOb` is the catch-all user. Use this as default.

Example Java JSON POST method
I'm not too familiar with Java.
If someone could share a method to create a JSON post request, "that would be great".
Here's an example from a scripter named Encoded which you can use with some minor tweaks:

public static void commit(long runtime, int experience) {
    try {
        runtime = (int) (runtime / 1000 / 60000);
        String payload =
            "{\"commit\":{\"script_id\": \"" + SCRIPT_ID + "\",\"user_id\": \"qN4tOb\",\"runtime\": " + runtime
                + ",\"stats_attributes\": [{\"task\": \"XP Gained\", \"amount\": " + experience + "}]}}";
        URL url = new URL(URL + "?user_email=" + EMAIL + "&user_token=" + API_KEY);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/json");

        conn.connect();

        byte[] data = payload.getBytes(StandardCharsets.UTF_8);
        DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
        wr.write(data);
        wr.flush();

        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        StringBuilder stb = new StringBuilder();
        String line;
        while ((line = rd.readLine()) != null) {
            stb.append(line).append("\n");
        }

        wr.close();
        rd.close();

        if (conn.getResponseCode() == 201) {
            Logging.debug("Successfully sent script statistics to RS Script Stats.");
        } else {
            Logging.debug(stb.toString());
        }
        conn.disconnect();
    } catch (IOException ignored) {

    }
}

More To Come!
Eager to continue development of this, open to all suggestions and constructive criticism!
Scripters, please use this, thank you :)

Are you a script user who wants to showoff their stats for a script?
Bug the script author to implement this API, it's easy!

Edited by YoHoJo
  • Like 4
Link to comment
Share on other sites

18 hours ago, dreameo said:

You could probably modify the example to accept a map (exp:task, quantity:task...). Instead of having to modify the function each time.

Including max, min, avg, and total would probably be good (on the properties) for your site.

I might add this.

I agree! Ideally it'd accept 0 or as many parameters as needed for different task/amounts. 

Please do ?! 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...