- Joined
- Nov 8, 2013
- Messages
- 2
- Thread Author
- #1
Runescape Bot Stats
RSBotStats is an API that allows scripters to easily track tasks their scripts have accomplished.
Add stats tracking to your script with a simple JSON POST request!
Use to showoff and market your script!
Check it out here.
Real stats from a cooking script!
Getting Started with the API
URL:
http://pure-woodland-47666.herokuap...user_email=YOUR_EMAIL&user_token=YOUR_API_KEY
Body:
Parameter Notes
Eager to continue development of this, open to all suggestions and constructive criticism!
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 are two examples from scripters:
java integration for scriptwriters by anondinh · Pull Request #14 · AakLak/rs_script_stats
: - ] Please integrate and enjoy!
RSBotStats is an API that allows scripters to easily track tasks their scripts have accomplished.
Add stats tracking to your script with a simple JSON POST request!
Use to showoff and market your script!
Check it out here.
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.
URL:
http://pure-woodland-47666.herokuap...user_email=YOUR_EMAIL&user_token=YOUR_API_KEY
Body:
Code:
{
"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.
Eager to continue development of this, open to all suggestions and constructive criticism!
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 are two examples from scripters:
java integration for scriptwriters by anondinh · Pull Request #14 · AakLak/rs_script_stats
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) {
}
}
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) {
}
}
: - ] Please integrate and enjoy!