API

Official Netstats API

Tutorial (JavaScript)

/**
 * <host> = server hostname or IP.
 * <port> = config's "port=" setting. Default is 9999.
 */

// Create a new request
var xhr = new XMLHttpRequest();

// Open the connection to the server
xhr.open("POST", "//<host>:<port>/data", true);

// Set headers to correct Content-Type
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

// Ask server for all stats from every world
xhr.send("players=all");

// Handle the response from the server
xhr.onload = function(e) {
    console.log(e.target.responseText);
}


API Examples

// For all worlds the player(s) have been in
xhr.send("players=player1,player2,player4");

// For specific worlds, i.e. world named "nether"
xhr.send("players=player1,player3&worlds=nether");

Comments

Posts Quoted:
Reply
Clear All Quotes