Ratings
Summary
Allows to support an online leaderboard or system of ratings/voting of any kind for your app. Great way to engage users with your project is to introduce an element of competition where users are able to compete and compare their results with real users from all over the world. Supports features such as country flags, various formatting and sorting modes, OpenGL mode for game apps. High scores can be also exported to HTML to display at your website.
Need to know information
Before using the Users module please read the following:
Ratings API
Typical use сases
Base way how to use Ratings:
- Create Table (GameMode) in Admin panel
- Create Score for User
- See Top N scores
Custom parameters:
- Create Extra parameters (GameModeParameters) in Admin panel
- Set value for extra parameter
- See extra parameter value
Requests and Responses
Create GameMode
Create a game mode
Parameters
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| gamemode[title] | Yes | String | chess | Name of game modes |
Request
curl -X POST -d "token=d28fadea6fd9579c57430539b84a9a7e01e30633&gamemode[title]=chess" http://api.quickblox.com/gamemodes.xml
curl -X POST -H "Content-Type: application/json" -d '{gamemode: {title: MyCurrentPosition}, token: 6142de6cb6d172227717ae73010dfbb6a07241c5}' http://api.quickblox.com/gamemodes.json
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode> <application-id type='integer'>6</application-id> <id type='integer'>1</id> <title>chess</title> <user-id type="integer">3</user-id> </game-mode>
{ "game_mode": { "application_id": 2, "id": 203, "title": "MyCurrentPosition", "user_id": 3 } }
Update GameMode by identifier
Update game mode
Parameters
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| gamemode[title] | Yes | String | chess | Name of game modes |
Request
curl -X PUT -d "http://api.quickblox.com/gamemodes/1.xml?gamemode[title]=chess&token=e329a0ebebc15cb0bc74885e79b5fea12cb34d86"
curl -X PUT -H "Content-Type: application/json" -d '{gamemode: {title: vegetables}, token: fd0dd186107eb0e1cd0b7187e9523dc0b01b7363}' http://api.quickblox.com/gamemodes/30.json
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode> <application-id type='integer'>6</application-id> <id type='integer'>1</id> <title>chess</title> <user-id type="integer">3</user-id> </game-mode>
{ "game_mode": { "application_id": 140, "id": 30, "title": "vegetables", "user_id": 1326 } }
Retrieve GameMode by identifier
Retrieve GameMode by identifier
Request
curl -X GET -d "http://api.quickblox.com/gamemodes/30.xml?token=e329a0ebebc15cb0bc74885e79b5fea12cb34d86"
curl -X GET -d "http://api.quickblox.com/gamemodes/203.json?token=e329a0ebebc15cb0bc74885e79b5fea12cb34d86"
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode> <application-id type='integer'>140</application-id> <id type='integer'>30</id> <title>vegetables</title> <user-id type='integer'>1326</user-id> </game-mode>
{ "game_mode": { "application_id": 2, "id": 203, "title": "Smile", "user_id": 3 } }
Retrieve GameModes for current application
Retrieve GameModes for current application. The application ID is specified in the authorization token
Request
curl -X GET -d "http://api.quickblox.com/application/gamemodes.xml?token=0898e87c990c961b13bb209d15df47fca4352477"
curl -X GET -d "http://api.quickblox.com/application/gamemodes.json?token=131a63c5575ffbbaca0a8d650b286dd00ef0f95a"
Response
<?xml version='1.0' encoding='UTF-8'?> <game-modes type='array'> <game-mode> <application-id type='integer'>140</application-id> <id type='integer'>1</id> <title>111</title> <user-id type='integer'>563</user-id> </game-mode> … </game-modes>
[ { "game_mode": { "application_id": 140, "id": 1, "title": "111", "user_id": 563 } }, { "game_mode": { "application_id": 140, "id": 3, "title": "343666", "user_id": 385 } }, ... ]
Delete GameMode by identifier
Delete GameMode by identifier
Request
curl -X DELETE -d "http://api.quickblox.com/gamemodes/2.xml?token=e329a0ebebc15cb0bc74885e79b5fea12cb34d86"
curl -X DELETE -d "http://api.quickblox.com/gamemodes/203.json?token=e329a0ebebc15cb0bc74885e79b5fea12cb34d86"
Response
Create Score
Create Score
Parameters
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| score[game_mode_id] | Yes | Unsigned Integer | 12 | ID of Game mode instance |
| score[value] | Yes | Unsigned Integer | 100 | Scores value |
Request
curl -X POST -d "token=d28fadea6fd9579c57430539b84a9a7e01e30633&score[game_mode_id]=1&score[value]=100" http://api.quickblox.com/scores.xml
curl -X POST -H "Content-Type: application/json" -d '{score: {game_mode_id: 203, value: 285 }, token: 6142de6cb6d172227717ae73010dfbb6a07241c5}' http://api.quickblox.com/scores.json
Response
<?xml version='1.0' encoding='UTF-8'?> <score> <created-at type='datetime'>2012-03-15T11:02:58Z</created-at> <game-mode-id type='integer'>7</game-mode-id> <id type='integer'>11</id> <user-id type='integer'>3</user-id> <value type='integer'>100</value> </score>
{ "score": { "created_at": "2012-03-23T08:58:09Z", "game_mode_id": 203, "id": 148, "user_id": 3, "value": 285 } }
Update Score by identifier
Update Score by identifier
Parameters
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| score[game_mode_id] | Yes | Unsigned Integer | 12 | ID of Game mode instance |
| score[value] | Yes | Unsigned Integer | 100 | Scores value |
Request
curl -X PUT -d "http://api.quickblox.com/scores/1.xml?score[value]=25&token=a97a361b7ad8dae716241fea176a1715bef0d77d"
curl -X PUT -H "Content-Type: application/json" -d '{score: {value: 25}, token: bb113ff91f8270925155ee8c214ccbe988f0e994}' http://api.quickblox.com/scores/30.json?
Response
<?xml version='1.0' encoding='UTF-8'?> <score> <created-at type='datetime'>2012-02-27T13:33:10Z</created-at> <game-mode-id type='integer'>25</game-mode-id> <id type='integer'>1</id> <user-id type='integer'>25</user-id> <value type='integer'>25</value> </score>
{ "score": { "created_at": "2012-04-23T16:37:24Z", "game_mode_id": 30, "id": 39, "user_id": 1326, "value": 25 } }
Retrieve Score by identifier
Retrieve Score by identifier
Request
curl -X GET -d "http://api.quickblox.com/scores/1.xml?token=a97a361b7ad8dae716241fea176a1715bef0d77d"
curl -X GET -d "http://api.quickblox.com/scores/203.json?token=a97a361b7ad8dae716241fea176a1715bef0d77d"
Response
<?xml version='1.0' encoding='UTF-8'?> <score> <created-at type='datetime'>2012-02-27T13:33:10Z</created-at> <game-mode-id type='integer'>25</game-mode-id> <id type='integer'>1</id> <user-id type='integer'>25</user-id> <value type='integer'>25</value> </score>
{ "score": { "created_at": "2012-03-15T16:40:33Z", "game_mode_id": 100, "id": 148, "user_id": 3, "value": 777 } }
Retrieve top N results by GameMode identifier
Retrieve top N results by GameMode identifier. Top N - is a number of the results, which is specified as a limit in the construction "top.limit.xml". The request can contain the parameters for filtering the results. If this option is set, its value - the object to validate. Also, the sort direction can be explicitly specified in the request by the parameter "value".
Parameters (filters & sort)
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| page | No | Unsigned Integer | 3 | Page number of the book of the results that you want to get. By default: 1 |
| per_page | No | Unsigned Integer | 15 | The maximum number of results per page. Min: 1. Max: 100. By default: 10 |
| filters | No | key=value | frags=250 | One of the additional parameters of the game mode. If a parameter is specified and exists for the current game mode, it's necessary to show all instances with the parameter which is equal to the specified. |
| sort | No | sort_asc | 1 | Indicates that the sorting should be ascending by the parameter. If this parameter is not present, then the sort is descending. |
Request
curl -X GET -d "http://api.quickblox.com/gamemodes/7/top.10.xml?token=0898e87c990c961b13bb209d15df47fca4352477"
curl -X GET -d "http://api.quickblox.com/gamemodes/100/top.5.json?&token=131a63c5575ffbbaca0a8d650b286dd00ef0f95a"
Response
<?xml version='1.0' encoding='UTF-8'?> <scores type='array' current_page='1' per_page='10' total_entries='1'> <score> <created-at type='datetime'>2012-03-15T11:02:58Z</created-at> <game-mode-id type='integer'>7</game-mode-id> <id type='integer'>11</id> <user-id type='integer'>3</user-id> <value type='integer'>25</value> <game-mode-parameter-values type='array'/> </score> ... </scores>
{ "current_page": 1, "per_page": 5, "total_entries": 1, "items": [ { "score": { "created_at": "2012-03-16T09:53:54Z", "game_mode_id": 100, "id": 148, "user_id": 3, "value": 777, "game_mode_parameter_values": [ ] } } ... ] }
Retrieve Scores for user
Retrieve Scores for the specified user. The request can contain the parameters for filtering the results. If this option is set, its value - the object to validate. As a parameter for sorting in the request can be specified any of the values for sorting or does not specified at all. The presence of the other values - validation error .
Parameters (filters & sort)
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| gamemode_id | No | Unsigned integer |
5 |
If this parameter is specified, there should be shown only the instances with the corresponding gamemode_id. If none - in this case 404. |
| "filters" | No | key=value | place=34 | One of the additional parameters of the game mode. If a parameter is specified and exists for the current game mode, it's necessary to show all instances with the parameter which is equal to the specified. |
| sort_by | No | enum
|
sort_by=created_at | created_at - values should be sorted by date.
value (by default) - value should be sorted by points Format: enum |
| sort_asc | No | Integer | 1 | Indicates that the sorting should be ascending by the parameter. If this parameter is not present, then the sort is descending. |
Request
curl -X GET -d "http://api.quickblox.com/users/3/scores.xml?token=0898e87c990c961b13bb209d15df47fca4352477"
curl -X GET -d "http://api.quickblox.com/users/3/scores.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
<?xml version='1.0' encoding='UTF-8'?> <scores type='array' current_page='1' per_page='30' total_entries='5'> <score> <created-at type='datetime'>2012-03-15T11:54:11Z</created-at> <game-mode-id type='integer'>18</game-mode-id> <id type='integer'>12</id> <user-id type='integer'>3</user-id> <value type='integer'>100</value> <game-mode-parameter-values type='array'/> </score> … </scores>
{ "current_page": 1, "per_page": 30, "total_entries": 23, "items": [ { "score": { "created_at": "2012-03-15T16:40:13Z", "game_mode_id": 11, "id": 35, "user_id": 3, "value": 2147483647, "game_mode_parameter_values": [ ] } }, { "score": { "created_at": "2012-03-15T15:30:11Z", "game_mode_id": 11, "id": 27, "user_id": 3, "value": 4695, "game_mode_parameter_values": [ ] } }, ... ] }
Retrieve average scores by GameMode identifier for all users
Retrieve average scores by GameMode identifier for all users of the current game mode
Request
curl -X GET -d "http://api.quickblox.com/gamemodes/1/average.xml?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X GET -d "http://api.quickblox.com/gamemodes/100/average.json?token=131a63c5575ffbbaca0a8d650b286dd00ef0f95a"
Response
<?xml version='1.0' encoding='UTF-8'?> <average> <value type='decimal'> 71.6667 </value> </average>
{ "value": "71.6667" }
Retrieve average Scores for current application
Retrieve average Scores for current application. Application ID is specified in the authorization token
Request
curl -X GET -d "http://api.quickblox.com/application/averages.xml?token=0898e87c990c961b13bb209d15df47fca4352477"
curl -X GET -d "http://api.quickblox.com/application/averages.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
<?xml version='1.0' encoding='UTF-8'?> <averages type='array'> <average> <game-mode-id type='integer'>1</game-mode-id> <value type='decimal'>390.5</value> </average> <average> <game-mode-id type='integer'>5</game-mode-id> <value type='decimal'>111.0</value> </average> ... </averages>
[ { "game_mode_id": 12, "value": "34534.0" }, { "game_mode_id": 18, "average": "438.5" }, ... ] }
Delete Score by identifier
Delete Score by identifier
Request
curl -X DELETE -d "http://api.quickblox.com/scores/13.xml?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X DELETE -d "http://api.quickblox.com/scores/13.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
Create GameModeParameter
Create a parameter for the gamemode
Parameters
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| gamemodeparameter[game_mode_id] | Yes | Unsigned Integer | 3 | ID of GameMode instance |
| gamemodeparameter[name] | Yes | String | 15 | Name of Game Mode parameter Min: 3 chars. Max: 50 chars. |
Request
curl -X POST -d "token=b284ddf44f5369611fe14e0e588f1cfa855116c8&gamemodeparameter[game_mode_id]=1&gamemodeparameter[name]=flags" http://api.quickblox.com/gamemodeparameters.xml
curl -X POST -H "Content-Type: application/json" -d '{gamemodeparameter: {game_mode_id: 203, name: MyParameter }, token: 6142de6cb6d172227717ae73010dfbb6a07241c5}' http://api.quickblox.com/gamemodeparameters.json
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode-parameter> <game-mode-id type='integer'>1</game-mode-id> <id type='integer'>1</id> <name>flags</name> </game-mode-parameter>
{ "game_mode_parameter": { "game_mode_id": 203, "id": 244, "name": "MyParameter" } }
Update GameModeParameter by identifier
Update GameModeParameter by the identifier
Parameters
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| gamemodeparameter[game_mode_id] | No | Unsigned Integer | 3 | ID of GameMode instance |
| gamemodeparameter[name] | No | String | 15 | Name of Game Mode parameter Min: 3 chars. Max: 50 chars. |
Request
curl -X PUT -d "http://api.quickblox.com/gamemodeparameters/2.xml?gamemodeparameter[name]=flags&token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X PUT -H "Content-Type: application/json" -d '{gamemodeparameter: {name: MyParam}, token: c71264f4c5680fbdd865196e2053c6d3301d4076}' http://api.quickblox.com/gamemodeparameters/244.json
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode-parameter> <game-mode-id type='integer'>2</game-mode-id> <id type='integer'>2</id> <name>flags</name> </game-mode-parameter>
{ "game_mode_parameter": { "game_mode_id": 100, "id": 244, "name": "MyParam" } }
Retrieve GameModeParameter by identifier
Retrieve GameModeParameter by identifier
Request
curl -X GET -d "http://api.quickblox.com/gamemodeparameters/1.xml?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X GET -d "http://api.quickblox.com/gamemodeparameters/244.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode-parameter> <game-mode-id type='integer'>1</game-mode-id> <id type='integer'>1</id> <name>Hello</name> </game-mode-parameter>
{ "game_mode_parameter": { "game_mode_id": 203, "id": 244, "name": "MyParam" } }
Retrieve GameModeParameters by GameMode identifier
Retrieve all GameModeParameters by GameMode identifier
Request
curl -X GET -d "http://api.quickblox.com/gamemodes/1/gamemodeparameters.xml?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X GET -d "http://api.quickblox.com/gamemodes/100/gamemodeparameters.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode-parameters type='array'> <game-mode-parameter> <game-mode-id type='integer'>1</game-mode-id> <id type='integer'>1</id> <name>Hello</name> </game-mode-parameter> … </game-mode-parameters>
[ { "game_mode_parameter": { "game_mode_id": 100, "id": 15, "name": "Hello" } }, … ]
Delete GameModeParameters by identifier
Delete GameModeParameters by identifier
Request
curl -X DELETE -d "http://api.quickblox.com/gamemodeparameters/5.xml?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X DELETE -d "http://api.quickblox.com/gamemodeparameters/203.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
Create GameModeParameterValue
Create the values for the parameters of the game mode (GameModeParameter). A "game_mode_id" which has been specified while creating a game mode parameter and score should be the same.
Parameters
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| gamemodeparametervalue[game_mode_parameter_id] | Yes | Unsigned Integer | 3 | ID of GameModeParameter instance |
| gamemodeparametervalue[score_id] | Yes | Unsigned Integer | 15 | ID of Score instance |
| gamemodeparametervalue[value] | Yes | String | 200 | Parameter value. Max: 50 chars. |
Request
curl -X POST -d "token=b284ddf44f5369611fe14e0e588f1cfa855116c8&gamemodeparametervalue[game_mode_parameter_id]=1&gamemodeparametervalue[score_id]=1&gamemodeparametervalue[value]=1" http://api.quickblox.com/gamemodeparametervalues.xml
curl -X POST -H "Content-Type: application/json" -d '{gamemodeparametervalue: {game_mode_parameter_id: 244, score_id: 148, value: 123 }, token: 6142de6cb6d172227717ae73010dfbb6a07241c5}' http://api.quickblox.com/gamemodeparametervalues.json
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode-parameter-value> <created-at type='datetime'>2012-02-27T16:15:31Z</created-at> <game-mode-parameter-id type='integer'>1</game-mode-parameter-id> <id type='integer'>1</id> <score-id type='integer'>1</score-id> <value>1</value> </game-mode-parameter-value>
{ "game_mode_parameter_value": { "created_at": "2012-03-23T09:03:56Z", "game_mode_parameter_id": 244, "id": 167, "score_id": 148, "value": 123 } }
Update GameModeParameterValue by identifier
Update GameModeParameterValue by identifier
Parameters
| Param | Required | Type | Value Example | Description |
|---|---|---|---|---|
| gamemodeparametervalue[game_mode_parameter_id] | No | Unsigned Integer | 3 | ID of GameModeParameter instance |
| gamemodeparametervalue[score_id] | No | Unsigned Integer | 15 | ID of Score instance |
| gamemodeparametervalue[value] | No | String | 200 | Parameter value. Max: 50 chars. |
Request
curl -X PUT -d "http://api.quickblox.com/gamemodeparametervalues/2.xml?gamemodeparametervalue[score_id]=3&token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X PUT -H "Content-Type: application/json" -d '{gamemodeparametervalue: {score_id: 48}, token: 2c130c0c14881d9e2d8a933b94d7dbb6609731b1}' http://api.quickblox.com/gamemodeparametervalues/167.json
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode-parameter-value> <created-at type='datetime'>2012-02-27T16:19:55Z</created-at> <game-mode-parameter-id type='integer'>3</game-mode-parameter-id> <id type='integer'>2</id> <score-id type='integer'>3</score-id> <value>hello</value> </game-mode-parameter-value>
{ "game_mode_parameter_value": { "created_at": "2012-03-16T11:55:17Z", "game_mode_parameter_id": 244, "id": 167, "score_id": 48, "value": "123" } }
Retrieve GameModeParameterValue by identifier
Retrieve GameModeParameterValue by identifier
Request
curl -X GET -d "http://api.quickblox.com/gamemodeparametervalues/2.xml?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X GET -d "http://api.quickblox.com/gamemodeparametervalues/2.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode-parameter-value> <created-at type='datetime'>2012-02-27T16:19:55Z</created-at> <game-mode-parameter-id type='integer'>3</game-mode-parameter-id> <id type='integer'>2</id> <score-id type='integer'>3</score-id> <value>hello world</value> </game-mode-parameter-value>
{ "game_mode_parameter_value": { "created_at": "2012-03-16T11:55:17Z", "game_mode_parameter_id": 244, "id": 167, "score_id": 48, "value": "123" } }
Retrieve GameModeParameterValues by Score identifier
Retrieve GameModeParameterValues by Score identifier
Request
curl -X GET -d "http://api.quickblox.com/scores/1/gamemodeparametervalues.xml?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X GET -d "http://api.quickblox.com/scores/48/gamemodeparametervalues.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode-parameter-values type='array'> <game-mode-parameter-value> <created-at type='datetime'>2012-02-27T16:15:31Z</created-at> <game-mode-parameter-id type='integer'>1</game-mode-parameter-id> <id type='integer'>1</id> <score-id type='integer'>1</score-id> <value>1</value> </game-mode-parameter-value> … </game-mode-parameter-values>
[ { "game_mode_parameter_value": { "created_at": "2012-03-16T11:55:17Z", "game_mode_parameter_id": 244, "id": 167, "score_id": 48, "value": "123" } } ]
Retrieve API GameModeParameterValue by Score identifier
Retrieve API GameModeParameterValue by the Score identifier and the GameModeParameter identifier
Request
curl -X GET -d "http://api.quickblox.com/scores/1/gamemodeparameters/2/value.xml?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X GET -d "http://api.quickblox.com/scores/48/gamemodeparameters/244/value.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
<?xml version='1.0' encoding='UTF-8'?> <game-mode-parameter-value> <created-at type='datetime'>2012-03-19T12:53:40Z</created-at> <game-mode-parameter-id type='integer'>28</game-mode-parameter-id> <id type='integer'>18</id> <score-id type='integer'>66</score-id> <value>cookie</value> </game-mode-parameter-value>
[ { "game_mode_parameter_value": { "created_at": "2012-03-16T11:55:17Z", "game_mode_parameter_id": 244, "id": 167, "score_id": 48, "value": "123" } } ]
Delete GameModeParameterValue by identifier
Delete GameModeParameterValue by identifier
Request
curl -X DELETE -d "http://api.quickblox.com/gamemodeparametervalues/5.xml?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
curl -X DELETE -d "http://api.quickblox.com/gamemodeparametervalues/167.json?token=c71264f4c5680fbdd865196e2053c6d3301d4076"
Response
