API

API introduction

The MushRaider API allows developers to get data from the raid planner like the roster, events, characters, roles thus the details for each. You will be able then to display on your website all kind of informations or create your own plugins.You need at least MushRaider v1.4.

 

My first API request

MushRaider API uses HTTP protocol and HMAC to authenticate you. There are two formats for the requested data : JSON et XML. Returned format is based on the request’s extension.

You first need to enable the API and generate a secret key to get auth with the application. Both can be done in MushRaider admin under Settings => API menu.

To get authenticated you need to sign every requests by using the function hash_hmac (in PHP, use the appropriate function with a different language) with the request’s params and the secret key, see examples below.

Examples :

Get the roles list
$mySecretKey = 'lpKSPD94t9okj4J33ffWruNisVKCrFdn';
// Params string
$params = '/roles/index';
// Generate security key with the private key from the APP
$hmac = hash_hmac('sha1', $params, $mySecretKey);
// Make the request
$params .= '/key:'.$hmac; // add the secret key to the request
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://myawesomewebsite.com/api'.$params.'.json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$rolesJSON = curl_exec($curl);
curl_close($curl);
Get events between 01 january 2014 and 01 august 2014
$mySecretKey = 'lpKSPD94t9okj4J33ffWruNisVKCrFdn';
// Params string
$params = '/events/index/start:1388534400/end:1406851200';
// Generate security key with the private key from the APP
$hmac = hash_hmac('sha1', $params, $mySecretKey);
// Make the request
$params .= '/key:'.$hmac; // add the secret key to the request
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://myawesomewebsite.com/api'.$params.'.json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$eventsJSON = curl_exec($curl);
curl_close($curl);

You can see that the request extension is .json. If you want XML just replace it with .xml

 

API methods

Users roles

GET /roles/index : users roles list

Games

GET /games/index : games list.

GET /games/view/game:{gameID}(integer) : game’s details, param is mandatory.

Characters

GET /characters/index/page:{pageNumber}(integer)/game:{gameID}(integer) : characters list, params are optionnal.

GET /characters/view/character:{characterID}(integer) : character’s details, param is mandatory.

Users

GET /roster/index/page:{pageNumber}(integer) : users list, params are optionnal.

GET /roster/view/user:{userID}(integer) : user’s details, param is mandatory.

Events

GET /events/index/game:{gameID}(integer)/start:{date}(timestamp)/end:{date}(timestamp) : events list, params are optionnal.

GET /events/view/event:{eventID}(integer) : event’s details, param is mandatory.

 

If you have any trouble, got questions or want to share your work please head to the forum !

Si vous aimez (ou pas), partagez...Share on FacebookTweet about this on TwitterShare on Google+Share on Reddit