74 lines
3.9 KiB
HTML
74 lines
3.9 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">Create Test API Endpoint</h1><a id="user-content-create-test-api-endpoint" class="anchor" aria-label="Permalink: Create Test API Endpoint" href="#create-test-api-endpoint"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
|
|
<div class="markdown-heading"><h2 class="heading-element">POST <code>/api/post_test</code>
|
|
</h2><a id="user-content-post-apipost_test" class="anchor" aria-label="Permalink: POST /api/post_test" href="#post-apipost_test"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
|
|
<p>Post Test Data This API endpoint allows you to post test data, recording the results of a test taken by a user.</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>testType</code> - Type of the test ("words", "time", "quote", etc)</li>
|
|
<li>
|
|
<code>testLength</code> - Length of the test in number of items or</li>
|
|
<li>
|
|
<code>testTime</code> - Duration of the test in seconds</li>
|
|
<li>
|
|
<code>testSeed</code> - Seed for generating randomized test content</li>
|
|
<li>
|
|
<code>quoteId</code> - Identifier for a specific quote, if applicable</li>
|
|
<li>
|
|
<code>wpm</code> - Words per minute (typing speed)</li>
|
|
<li>
|
|
<code>accuracy</code> - Accuracy of responses (e.g., percentage)</li>
|
|
<li>
|
|
<code>userId</code> - Identifier of the user taking the test</li>
|
|
<li>
|
|
<code>secret</code> - Secret key for authentication and authorization</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> - The test has been added to the database sucessfully</li>
|
|
<li>
|
|
<code>401 UNAUTHORIZED</code> - The user has not been authenticated correctly</li>
|
|
<li>
|
|
<code>500 INTERNAL SERVER ERROR</code> - There has been a database error when attempting to</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 POST <span class="pl-s"><span class="pl-pds">"</span>https://example.com/api/post_test<span class="pl-pds">"</span></span> \
|
|
-H <span class="pl-s"><span class="pl-pds">"</span>Content-Type: application/json<span class="pl-pds">"</span></span> <span class="pl-cce">\ </span>
|
|
-d <span class="pl-s"><span class="pl-pds">'</span>{ </span>
|
|
<span class="pl-s"> "testType": "typing", </span>
|
|
<span class="pl-s"> "testLength": 100, </span>
|
|
<span class="pl-s"> "testTime": 600, </span>
|
|
<span class="pl-s"> "testSeed": "random_seed_123", </span>
|
|
<span class="pl-s"> "quoteId": "quote_456", </span>
|
|
<span class="pl-s"> "wpm": 65.5, </span>
|
|
<span class="pl-s"> "accuracy": 98.2, </span>
|
|
<span class="pl-s"> "userId": "user_789", </span>
|
|
<span class="pl-s"> "secret": "your_secret_key_here" </span>
|
|
<span class="pl-s"> }<span class="pl-pds">'</span></span></pre></div>
|
|
</body>
|
|
</html>
|
|
|