{"leaderboard_users":[{"rank": 1,"external_user": {"username": "jeanguy"},"challenge_count": 1,"task_count": 3,"score": 100,"total_xp": 1400},{"rank": 2,"external_user": {"username": "user111222"},"challenge_count": 1,"task_count": 1,"score": 100,"total_xp": 1100},{"rank": 3,"external_user": {"username": "jimbo"},"challenge_count": 0,"task_count": 0,"score": 0,"total_xp": 200}],"total_users": 3,"message": null,"is_valid": true}
{is_valid: false,"message": "App id not found"}
curl --request GET--url 'https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040'--header 'authorization: Bearer <<YOUR_API_KEY>>'--data '{}'​
var client = new RestClient("https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040");var request = new RestRequest(Method.GET);request.AddHeader("authorization", "Bearer <<YOUR_API_KEY>>");request.AddParameter("application/json", "{}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);​
var data = "{}";​var xhr = new XMLHttpRequest();​xhr.addEventListener("readystatechange", function () {if (this.readyState === this.DONE) {console.log(this.responseText);}});​xhr.open("GET", "https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040");xhr.setRequestHeader("authorization", "Bearer <<YOUR_API_KEY_HERE>>");​xhr.send(data);​
import http.client​conn = http.client.HTTPSConnection("api.bountyblok.io")​payload = "{}"​headers = { 'authorization': "Bearer <<YOUR_API_KEY>>" }​conn.request("GET", "/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040", payload, headers)​res = conn.getresponse()data = res.read()​print(data.decode("utf-8"))​
<?php​$curl = curl_init();​curl_setopt_array($curl, array(CURLOPT_URL => "https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040",CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => "",CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 30,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => "GET",CURLOPT_POSTFIELDS => "{}",CURLOPT_HTTPHEADER => array("authorization: Bearer <<YOUR_API_KEY_HERE>>"),));​$response = curl_exec($curl);$err = curl_error($curl);​curl_close($curl);​if ($err) {echo "cURL Error #:" . $err;} else {echo $response;}​
​
The App Leaderboard can be retrieved in HTML by specifying &widget_response=html
.
Create an empty div for the leaderboard HTML and insert the HTML:
<div id="bb-leaderboard">Loading ... </div>
var data = "{}";var xhr = new XMLHttpRequest();​xhr.addEventListener("readystatechange", function () {if (this.readyState === this.DONE) {document.getElementById('bb-leaderboard').innerHTML = JSON.parse(this.responseText).html;}});​xhr.open("GET", "https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040&widget_response=html&leaderboard_type=score");xhr.setRequestHeader("authorization", "Bearer <<YOUR_API_KEY_HERE>>");​xhr.send(data);​
var settings = {"async": true,"url": "https://api.bountyblok.io/v1/get_leaderboard?app_id=7e5deae7-483b-4153-931a-2fe71aa3f036&widget_response=html&leaderboard_type=score","method": "GET","headers": {"authorization": "Bearer <<YOUR_API_KEY_HERE>>"},"data": "{}"}​$.ajax(settings).done(function (response) {$('#bb-leaderboard').html(response.html);});​