CS-Coursework/documentation/html/get_leaderboard.html

71 lines
4.2 KiB
HTML

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="github-markdown.css">
</head>
<body class="markdown-body">
<style>
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
}
</style>
<div class="markdown-heading"><h1 class="heading-element">Leaderboard API Endpoint</h1><a id="user-content-leaderboard-api-endpoint" class="anchor" aria-label="Permalink: Leaderboard API Endpoint" href="#leaderboard-api-endpoint"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<div class="markdown-heading"><h2 class="heading-element">GET <code>/api/leaderboard</code>
</h2><a id="user-content-get-apileaderboard" class="anchor" aria-label="Permalink: GET /api/leaderboard" href="#get-apileaderboard"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>Returns the highest test data from each user as a JSON array. The data includes metrics such as username, words per minute (WPM), accuracy percentage, the time taken for the test, and the length of the test for a comprehensive overview of user performance.</p>
<div class="markdown-heading"><h2 class="heading-element">Request Parameters</h2><a id="user-content-request-parameters" class="anchor" aria-label="Permalink: Request Parameters" href="#request-parameters"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<ul>
<li>
<code>username</code>: The name of the user.</li>
<li>
<code>wpm</code>: Words per minute, indicating the typing speed.</li>
<li>
<code>accuracy</code>: The accuracy of the user's typing, in percentage.</li>
<li>
<code>test_time</code>: The total time taken to complete the test, in seconds.</li>
<li>
<code>test_length</code>: The length of the test, typically measured in number of words.</li>
</ul>
<div class="markdown-heading"><h2 class="heading-element">Responses</h2><a id="user-content-responses" class="anchor" aria-label="Permalink: Responses" href="#responses"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<ul>
<li>
<code>200 OK</code>: Successfully retrieves the leaderboard data.</li>
<li>
<code>404 Not Found</code>: Indicates that the leaderboard was not found.</li>
<li>
<code>500 Internal Server Error</code>: Indicates an issue with accessing the database.</li>
</ul>
<div class="markdown-heading"><h2 class="heading-element">Example Request</h2><a id="user-content-example-request" class="anchor" aria-label="Permalink: Example Request" href="#example-request"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<div class="highlight highlight-source-shell"><pre>curl -X GET <span class="pl-s"><span class="pl-pds">"</span>https://url/api/leaderboard<span class="pl-pds">"</span></span></pre></div>
<div class="markdown-heading"><h2 class="heading-element">Example Response</h2><a id="user-content-example-response" class="anchor" aria-label="Permalink: Example Response" href="#example-response"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<div class="highlight highlight-source-json"><pre>[
{
<span class="pl-ent">"username"</span>: <span class="pl-s"><span class="pl-pds">"</span>user1<span class="pl-pds">"</span></span>,
<span class="pl-ent">"wpm"</span>: <span class="pl-c1">75</span>,
<span class="pl-ent">"accuracy"</span>: <span class="pl-c1">97</span>,
<span class="pl-ent">"test_time"</span>: <span class="pl-c1">120</span>,
<span class="pl-ent">"test_length"</span>: <span class="pl-c1">250</span>
},
{
<span class="pl-ent">"username"</span>: <span class="pl-s"><span class="pl-pds">"</span>user2<span class="pl-pds">"</span></span>,
<span class="pl-ent">"wpm"</span>: <span class="pl-c1">73</span>,
<span class="pl-ent">"accuracy"</span>: <span class="pl-c1">95</span>,
<span class="pl-ent">"test_time"</span>: <span class="pl-c1">115</span>,
<span class="pl-ent">"test_length"</span>: <span class="pl-c1">240</span>
}
]</pre></div>
</body>
</html>