Get App Leaderboard
get
https://api.bountyblok.io
/v1/get_leaderboard
Get App Leaderboard
cURL
C#
Javascript
Python
PHP
1
curl --request GET
2
--url 'https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040'
3
--header 'authorization: Bearer <<YOUR_API_KEY>>'
4
--data '{}'
5
Copied!
1
var client = new RestClient("https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040");
2
var request = new RestRequest(Method.GET);
3
request.AddHeader("authorization", "Bearer <<YOUR_API_KEY>>");
4
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
5
IRestResponse response = client.Execute(request);
6
Copied!
1
var data = "{}";
2
3
var xhr = new XMLHttpRequest();
4
5
xhr.addEventListener("readystatechange", function () {
6
if (this.readyState === this.DONE) {
7
console.log(this.responseText);
8
}
9
});
10
11
xhr.open("GET", "https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040");
12
xhr.setRequestHeader("authorization", "Bearer <<YOUR_API_KEY_HERE>>");
13
14
xhr.send(data);
15
Copied!
1
import http.client
2
3
conn = http.client.HTTPSConnection("api.bountyblok.io")
4
5
payload = "{}"
6
7
headers = { 'authorization': "Bearer <<YOUR_API_KEY>>" }
8
9
conn.request("GET", "/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040", payload, headers)
10
11
res = conn.getresponse()
12
data = res.read()
13
14
print(data.decode("utf-8"))
15
Copied!
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 30,
11
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
12
CURLOPT_CUSTOMREQUEST => "GET",
13
CURLOPT_POSTFIELDS => "{}",
14
CURLOPT_HTTPHEADER => array(
15
"authorization: Bearer <<YOUR_API_KEY_HERE>>"
16
),
17
));
18
19
$response = curl_exec($curl);
20
$err = curl_error($curl);
21
22
curl_close($curl);
23
24
if ($err) {
25
echo "cURL Error #:" . $err;
26
} else {
27
echo $response;
28
}
29
Copied!

HTML Leaderboard

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>
XMLHttpRequest
jQuery
1
var data = "{}";
2
var xhr = new XMLHttpRequest();
3
4
xhr.addEventListener("readystatechange", function () {
5
if (this.readyState === this.DONE) {
6
document.getElementById('bb-leaderboard').innerHTML = JSON.parse(this.responseText).html;
7
}
8
});
9
10
xhr.open("GET", "https://api.bountyblok.io/v1/get_leaderboard?app_id=8a205981-61c9-4c27-bea7-ed42ab787040&widget_response=html&leaderboard_type=score");
11
xhr.setRequestHeader("authorization", "Bearer <<YOUR_API_KEY_HERE>>");
12
13
xhr.send(data);
14
Copied!
1
var settings = {
2
"async": true,
3
"url": "https://api.bountyblok.io/v1/get_leaderboard?app_id=7e5deae7-483b-4153-931a-2fe71aa3f036&widget_response=html&leaderboard_type=score",
4
"method": "GET",
5
"headers": {
6
"authorization": "Bearer <<YOUR_API_KEY_HERE>>"
7
},
8
"data": "{}"
9
}
10
11
$.ajax(settings).done(function (response) {
12
$('#bb-leaderboard').html(response.html);
13
});
14
Copied!
Last modified 1yr ago