榜单
curl --request GET \
--url http://127.0.0.1:3000/leaderboardimport requests
url = "http://127.0.0.1:3000/leaderboard"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('http://127.0.0.1:3000/leaderboard', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://127.0.0.1:3000/leaderboard",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:3000/leaderboard"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://127.0.0.1:3000/leaderboard")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:3000/leaderboard")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{}端点
GET /leaderboard
返回首页榜单 JSON;需要已配置的 PostgreSQL 与榜单数据。
GET
/
leaderboard
榜单
curl --request GET \
--url http://127.0.0.1:3000/leaderboardimport requests
url = "http://127.0.0.1:3000/leaderboard"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('http://127.0.0.1:3000/leaderboard', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://127.0.0.1:3000/leaderboard",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:3000/leaderboard"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://127.0.0.1:3000/leaderboard")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:3000/leaderboard")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{}返回首页 榜单 JSON,供前端列表页使用。依赖已连接 PostgreSQL 及库内榜单相关数据(分析写缓存时会更新排行榜等,详见主仓库 README)。
若未配置数据库或尚无数据,行为以服务端实现为准(可能为空列表或错误响应);部署前请在目标环境实测。
查询参数
| 参数 | 说明 |
|---|---|
limit | 返回条数,默认 30,范围 1~100 |
示例
curl -s "http://127.0.0.1:3000/leaderboard?limit=20" | jq .
Query Parameters
返回条数,默认 30,范围 1~100
Required range:
1 <= x <= 100Response
200 - application/json
榜单 JSON
The response is of type object.