Author Topic: Unofficial Blockland API v1  (Read 1378 times)

I made a little API for fun and to muck around with node.js. It's located at: http://blocklandapi-zack0wack0.dotcloud.com/

Notes:
All output is formatted in JSON. The master server is queried and cached every 2 minutes. All commands can have an optional 'callback' argument to use JSONP. Arguments are parsed as GET parameters (if you are familiar with my Server Status image thing, like that) for example if you wanted to set the host and port arguments you would use '?host=Centhra&port=30000'.

The rank value is a calculated rank for the server. It's formula is: ln(average players + 1) + sqrt(average bricks)^(average players / 100). This'll probably change.

Commands:

/servers
Lists all the current online servers. An example response (normally there'd be more then 5 servers, this is just an example):

http://blocklandapi-zack0wack0.dotcloud.com/servers
Code: [Select]
{
"version": 1,
"status_code": 0,
"status": "",
"servers": [
{
"online": true,
"ip": "67.160.180.221",
"port": 28100,
"dedicated": false,
"passworded": false,
"host": "Kiwibear",
"name": "Kiwibear's Server of Stuff",
"players": 3,
"max_players": 20,
"map": "Adjustable Plate",
"bricks": 538,
"preview_image_url": "http://image.blockland.us/detail.php?q=67-160-180-221_28100",
"preview_thumb_url": "http://image.blockland.us/thumb.php?q=67-160-180-221_28100",
"counted_times": 765,
"counted_players": 1745,
"counted_max_players": 15300,
"counted_bricks": 4038238,
"average_max_players": 20,
"average_players": 2.281045751633987,
"average_bricks": 5278.74248366013,
"rank": 2.2908594994443305,
"last_seen": "2011-09-14T23:10:33.351Z"
},
{
"online": true,
"ip": "92.153.74.137",
"port": 28100,
"dedicated": false,
"passworded": true,
"host": "Surburb",
"name": "Surburb's CityRP [Beta 2.1]",
"players": 8,
"max_players": 16,
"map": "SurburbfulRP",
"bricks": 188696,
"preview_image_url": "http://image.blockland.us/detail.php?q=92-153-74-137_28100",
"preview_thumb_url": "http://image.blockland.us/thumb.php?q=92-153-74-137_28100",
"counted_times": 684,
"counted_players": 1587,
"counted_max_players": 10957,
"counted_bricks": 82365155,
"average_max_players": 16.019005847953217,
"average_players": 2.3201754385964914,
"average_bricks": 120416.8932748538,
"rank": 2.3453734545274747,
"last_seen": "2011-09-14T06:18:33.270Z"
},
{
"online": true,
"ip": "24.12.10.151",
"port": 28100,
"dedicated": false,
"passworded": false,
"host": "zaman101",
"name": "zaman101's Blockland Server",
"players": 1,
"max_players": 32,
"map": "Bedroom",
"bricks": 663,
"preview_image_url": "http://image.blockland.us/detail.php?q=24-12-10-151_28100",
"preview_thumb_url": "http://image.blockland.us/thumb.php?q=24-12-10-151_28100",
"counted_times": 72,
"counted_players": 55,
"counted_max_players": 1782,
"counted_bricks": 185551,
"average_max_players": 24.75,
"average_players": 0.7638888888888888,
"average_bricks": 2577.097222222222,
"rank": 1.5979750034523665,
"last_seen": "2011-09-18T15:56:33.360Z"
},
{
"online": true,
"ip": "75.139.58.241",
"port": 28100,
"dedicated": false,
"passworded": false,
"host": "Saphire Legend",
"name": "Saphire Legend's Grapple Knife TDM",
"players": 5,
"max_players": 20,
"map": "Slate Desert",
"bricks": 6445,
"preview_image_url": "http://image.blockland.us/detail.php?q=75-139-58-241_28100",
"preview_thumb_url": "http://image.blockland.us/thumb.php?q=75-139-58-241_28100",
"counted_times": 12,
"counted_players": 45,
"counted_max_players": 240,
"counted_bricks": 64438,
"average_max_players": 20,
"average_players": 3.75,
"average_bricks": 5369.833333333333,
"rank": 2.7328711160207195,
"last_seen": "2011-09-19T01:32:33.293Z"
},
{
"online": true,
"ip": "72.95.62.58",
"port": 28000,
"dedicated": false,
"passworded": false,
"host": "macy",
"name": "macy's bulide a lab",
"players": 1,
"max_players": 8,
"map": "Plate2",
"bricks": 392,
"preview_image_url": "http://image.blockland.us/detail.php?q=72-95-62-58_28000",
"preview_thumb_url": "http://image.blockland.us/thumb.php?q=72-95-62-58_28000",
"counted_times": 537,
"counted_players": 448,
"counted_max_players": 7536,
"counted_bricks": 289401,
"average_max_players": 14.033519553072626,
"average_players": 0.8342644320297952,
"average_bricks": 538.9217877094972,
"rank": 1.6332265601349283,
"last_seen": "2011-09-16T01:00:33.363Z"
}
]
}

/server
Requests the information for one specific server. It accepts a host argument, an ip argument and a port argument. This works like my Server Status images. If you wanted to find the data for the host 'Centhra' and only on the server port '30000' then you would use '?host=Centhra&port=30000'. The port part is optional, in order to select single servers out of multiple servers for one host or ip. The ip argument or host argument must be set, otherwise it's impossible to find the server. Example response:

http://blocklandapi-zack0wack0.dotcloud.com/server?host=Centhra
Code: [Select]
{
"version": 1,
"status_code": 0,
"status": "Found the server.",
"server": {
"online": true,
"ip": "173.255.214.139",
"port": 30000,
"dedicated": false,
"passworded": true,
"host": "Centhra",
"name": "Centhra's Dueling Beta",
"players": 30,
"max_players": 99,
"map": "Skylands",
"bricks": 9340,
"preview_image_url": "http://image.blockland.us/detail.php?q=173-255-214-139_30000",
"preview_thumb_url": "http://image.blockland.us/thumb.php?q=173-255-214-139_30000",
"counted_times": 2107,
"counted_players": 17958,
"counted_max_players": 66444,
"counted_bricks": 20613428,
"average_max_players": 31.53488372093023,
"average_players": 8.523018509729473,
"average_bricks": 9783.307071665875,
"rank": 3.7330073029851434,
"last_seen": "2011-09-16T02:56:33.332Z"
}
}

/stats
Requests the statistics collected by the API server. There's not too much that is returned yet, and I still have to add 'most_popular_host'. All the returned fields are self explanatory, except 'map_tally' which is just the number of times a map has been counted on the server. Example response (without the entire bit of 'map_tally' because it clutters it up):

http://blocklandapi-zack0wack0.dotcloud.com/stats
Code: [Select]
{
"version": 1,
"status_code": 0,
"status": "",
"stats": {
"counted_bricks": 5097453364,
"counted_players": 745500,
"counted_servers": 323338,
"counted_times": 3477,
"average_players": 214.40897325280415,
"average_bricks": 15765.092145061824,
"average_servers": 92.99338510209951,
"unique_servers": 2138,
"online_servers": 116,
"most_popular_map": "Adjustable Plate",
"map_tally": {
"Slate Fields 2": 3205,
"Slate Desert": 14082,
"Skylands": 37031,
"Plate 3": 24292,
"Bedroom": 38540,
"GSF Paradise": 2016,
"Mikes House-Storm": 36,
"Slate Fields 4": 142,
"Adjustable Plate": 50158,
"Slate": 21838,
"Slate Astro": 3344
}
}
}

Possible future commands: /addon (info about addons), /user (info about Blockland users)

What the forget does it mean?
For coders, it's a little tool to see your server's rank, average bricks, brick count, player count, etc.
For non-coders, it's just collecting useful statistics that'll probably turn into a summary page one day.

This is cool. Will be checking this to see my stats change.

Edit:
Code: [Select]
{
"online": true,
"ip": "69.64.33.32",
"port": 31700,
"dedicated": false,
"passworded": true,
"host": "Munk",
"name": "Munk's Finding Hats!",
"players": 1,
"max_players": 27,
"map": "Bedroom - Dark",
"bricks": 17408,
"preview_image_url": "http://image.blockland.us/detail.php?q=69-64-33-32_31700",
"preview_thumb_url": "http://image.blockland.us/thumb.php?q=69-64-33-32_31700",
"counted_times": 544,
"counted_players": 2486,
"counted_max_players": 13890,
"counted_bricks": 7110197,
"average_max_players": 25.533088235294116,
"average_players": 4.569852941176471,
"average_bricks": 13070.215073529413,
"rank": 2.9591754520151694,
"last_seen": "2011-09-17T03:54:33.345Z"
},

My server isn't passworded and is dedicated?