-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-docs.php
85 lines (74 loc) · 3.13 KB
/
api-docs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
require_once 'config.php';
?>
<!DOCTYPE html>
<html lang="en">
<?php include 'includes/head.php'; ?>
<body>
<?php include 'includes/header.php'; ?>
<?php include 'includes/nav.php'; ?>
<div class="content">
<div class="api-docs">
<h1>API Documentation</h1>
<p>Welcome to the Code to Adventure API! Below are the details of the available endpoints, rate limits, and usage instructions.</p>
<h2>Endpoints</h2>
<h3>1. Fetch a Random Referral Code</h3>
<p><strong>URL:</strong> <code>GET /api.php?path=random</code></p>
<p><strong>Description:</strong> Returns a random referral code from the database.</p>
<p><strong>Example Response:</strong></p>
<pre><code>{
"name": "John Doe",
"username": "johndoe123",
"referral_code": "ABC123",
"link": "https://rivian.com/configurations/list?reprCode=ABC123"
}</code></pre>
<h3>2. Fetch All Referral Codes</h3>
<p><strong>URL:</strong> <code>GET /api.php?path=codes</code></p>
<p><strong>Description:</strong> Returns all referral codes stored in the database.</p>
<p><strong>Example Response:</strong></p>
<pre><code>[
{
"name": "John Doe",
"username": "johndoe123",
"referral_code": "ABC123",
"link": "https://rivian.com/configurations/list?reprCode=ABC123"
},
{
"name": "Jane Smith",
"username": "janesmith456",
"referral_code": "XYZ456",
"link": "https://rivian.com/configurations/list?reprCode=XYZ456"
}
]</code></pre>
<h3>3. Invalid API Path</h3>
<p>If an invalid endpoint is requested, the API will return the following response:</p>
<pre><code>{
"error": "Invalid API endpoint"
}</code></pre>
<h2>Rate Limiting</h2>
<div class="rate-limit">
<p><strong>Limit:</strong> 100 requests per minute per IP.</p>
<p><strong>Exceeding the limit:</strong> Returns the following response:</p>
<pre><code>{
"error": "Rate limit exceeded. Try again later."
}</code></pre>
</div>
<h2>Response Codes</h2>
<p>The API uses standard HTTP response codes:</p>
<ul>
<li><strong>200 OK:</strong> Request successful.</li>
<li><strong>404 Not Found:</strong> Endpoint does not exist.</li>
<li><strong>429 Too Many Requests:</strong> Rate limit exceeded.</li>
<li><strong>500 Internal Server Error:</strong> Server issue.</li>
</ul>
<h2>Usage Instructions</h2>
<p>To use the API, send a <code>GET</code> request to the specified endpoint. You can test it using a browser, tools like Postman, or integrate it into your application.</p>
<p>Respect the rate limit for consistent access.</p>
<a href="index.php" class="back-link">Back to Home</a>
</div>
</div>
<?php include 'includes/footer.php'; ?>
<?php include 'includes/modal.php'; ?>
<script src="js/main.js"></script>
</body>
</html>