Leagues¶
This module provides a time-bound free-form tournament (league) structure. It just provides time wrapper on sessions along with an application-specific helper cron-job to roll-over sessions in the previous league duration and to intimate the users of those sessions via notifications.
This module is still very much work-in-progress with more amends coming in near future.
At the end of the league period, the helper cron-job will generate notifications to all users who have played at least one session during the period.
The format of the notification is as follows:
{
"msg": null,
"event": {
"type": "league_completed",
"event": {
"league_id": "<league_id_string>",
"start_time": "<league_start_time_string - format YYYY-MM-DD HH:MM:SS>",
"end_time": "<league_end_time_string - format YYYY-MM-DD HH:MM:SS>"
}
},
"custom": {}
}
API: Get remaining time in the current league¶
URL: {BASE_URL}/app/<APP_ID>/leagues/current/time_remaining
Request Method: HTTP GET
Parameter | Mandatory | Type | Description |
---|---|---|---|
APP_ID | Yes | Alpha-numeric | The application ID issued by the Playblazer platform when the app was created |
secret_key | Yes | Alpha-numeric | The secret key issued by the Playblazer platform when the app was created |
fmt | No | String | One of (json | xml) - the format of output |
This API returns the time remaining for the end of the current league.
Example¶
URL Call:
curl "http://api.playblazer.com/v1/app/1/leagues/current/time_remaining?secret_key=1234"
Output:
{
"status": "ok",
"league": {
"start_time": "<start time of league - format YYYY-MM-DD HH:MM:SS>",
"end_time": "<end time of league - format YYYY-MM-DD HH:MM:SS>",
},
"time_remaining": {
"days": <days remaining>,
"hours": <hours remaining>,
"minutes": <minutes remaining>,
"seconds": <seconds remaining>,
"total_seconds": <total seconds remaining till end of league>,
}
}
If there is no current league defined, the API returns an error with err_str = E_NO_LEAGUE_DATA_FOUND
API: Get results for previous league period¶
Get results for previous league period API
URL: {BASE_URL}/app/<APP_ID>/leagues/last/<MODE>/<USER_ID>/results
Request Method: HTTP GET
Parameter | Mandatory | Type | Description |
---|---|---|---|
APP_ID | Yes | Alpha-numeric | The application ID issued by the Playblazer platform when the app was created |
secret_key | Yes | Alpha-numeric | The secret key issued by the Playblazer platform when the app was created |
MODE | Yes | String | The mode for user ID interpretation |
USER_ID | Yes | String | The user ID for whom the results of previous league period are requested |
fmt | No | String | One of (json | xml) - the format of output |
This API returns the consolidated results for the given user for previous league period. It includes details like:
- Total challenges/rounds played
- Total challenges/rounds won
- Total challenges/rounds lost
- Total opponents faced
- Percentage of wins
- List of opponents against whom wins > losses (win list)
- List of opponents against whom losses > wins (lost list)
Example¶
URL Call:
curl "http://api.playblazer.com/v1/app/1/leagues/last/fb/kunalg/results?secret_key=1234"
Output:
{
"status": "ok",
"results": {
"total_losses": 4,
"win_list": [
{
"wins": 3,
"losses": 2,
"user": {
"first_name": "Kunal",
"last_name": "Gangakhedkar",
"twitterid": null,
"fbid": "abcd",
"email": "kgangakhedkar@gmail.com",
"googleid": null,
}
}
],
"total_oppn": 2,
"total_played": 7,
"loss_list": [
{
"wins": 0,
"losses": 2,
"user": {
"first_name": "Nikhil",
"last_name": "Soman",
"twitterid": null,
"fbid": "nikhilsoman",
"email": "nikhil@playblazer.com",
"googleid": null,
}
}
],
"win_percentage": 42.85,
"total_wins": 3
}
}