Skip to content

Commit eb358fa

Browse files
authored
Merge branch 'alexjustesen:main' into main
2 parents 4e408d2 + 82ed9a8 commit eb358fa

File tree

7 files changed

+216
-3
lines changed

7 files changed

+216
-3
lines changed

.gitbook/assets/openapi.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "Speedtest Tracker API",
5+
"version": "1.0.0"
6+
},
7+
"paths": {
8+
"/api/v1/results/latest": {
9+
"get": {
10+
"description": "Get the latest result.",
11+
"operationId": "4b44d6935caeb91d3e687ab4bc176f62",
12+
"responses": {
13+
"200": {
14+
"description": "OK"
15+
},
16+
"404": {
17+
"description": "No result found"
18+
}
19+
}
20+
}
21+
},
22+
"/api/v1/results": {
23+
"get": {
24+
"description": "List results.",
25+
"operationId": "32a45ba8e8e9a81955a178ae686273ce",
26+
"responses": {
27+
"200": {
28+
"description": "OK"
29+
},
30+
"422": {
31+
"description": "Unprocessable Entity"
32+
}
33+
}
34+
}
35+
},
36+
"/api/v1/results/{id}": {
37+
"get": {
38+
"description": "Get result.",
39+
"operationId": "bc182a4008f0ff94a6318893359f3adc",
40+
"responses": {
41+
"200": {
42+
"description": "OK"
43+
},
44+
"404": {
45+
"description": "Result not found"
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: >-
88
# Introduction
99

1010
{% hint style="info" %}
11-
Docs are up to date through version: `v1.0.1`
11+
Docs are up to date through version: `v1.1.0`
1212
{% endhint %}
1313

1414
<figure><img src=".gitbook/assets/dashboard.png" alt=""><figcaption></figcaption></figure>

SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252

5353
## 🖥️ API
5454

55-
* [Latest Result](api/latest-result.md)
55+
* [v1](api/v1.md)
56+
* [Latest Result (deprecated)](api/latest-result.md)
5657

5758
## 🤹 Contributing
5859

api/latest-result.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Latest Result
22

3+
{% hint style="warning" %}
4+
This endpoint is deprecated and will be removed in a future release.
5+
{% endhint %}
6+
37
### Authentication
48

59
No authentication required.

api/v1.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# v1
2+
3+
### Authorization
4+
5+
A "Bearer Token" is required to authenticate into the API, you can generate tokens for your user account on `/admin/api-tokens`.
6+
7+
***
8+
9+
### Get result
10+
11+
<pre class="language-bash"><code class="lang-bash"><strong>curl localhost/api/v1/results/{id}
12+
</strong> -H "Accept: application/json"
13+
-H "Authorization: Bearer yourtokengoeshere"
14+
</code></pre>
15+
16+
#### Parameters
17+
18+
* `id`- record ID of the result to get
19+
20+
#### Responses
21+
22+
* 200: OK
23+
* 404: Result not found
24+
25+
26+
27+
***
28+
29+
### List result
30+
31+
```bash
32+
curl localhost/api/v1/results
33+
-H "Accept: application/json"
34+
-H "Authorization: Bearer yourtokengoeshere
35+
```
36+
37+
#### Filtering
38+
39+
You can filter the results response by the fields: `ping`, `download`, `upload`, `healthy`, `status`, `scheduled`, `created_at` and `updated_at`.
40+
41+
Example: filter dates in a range
42+
43+
```bash
44+
curl localhost/api/v1/results?filter[created_at]=>=2024-01-01&filter[created_at]=<=2024-12-31
45+
-H "Accept: application/json"
46+
-H "Authorization: Bearer yourtokengoeshere"
47+
```
48+
49+
Example: filter for only unhealthy results
50+
51+
```bash
52+
curl localhost/api/v1/results?filter[healthy]=false
53+
-H "Accept: application/json"
54+
-H "Authorization: Bearer yourtokengoeshere"
55+
```
56+
57+
Example: filter for "failed" and "skipped" results
58+
59+
```bash
60+
curl localhost/api/v1/results?filter[status]=failed,skipped
61+
-H "Accept: application/json"
62+
-H "Authorization: Bearer yourtokengoeshere"
63+
```
64+
65+
#### Sorting
66+
67+
You can sort the results response by the fields: `ping`, `download`, `upload`, `created_at` or `updated_at`. Sorting is ascending by default and can be reversed by adding a hyphen (-) to the start of the property name.
68+
69+
```bash
70+
curl localhost/api/v1/results?sort=-created_at
71+
-H "Accept: application/json"
72+
-H "Authorization: Bearer yourtokengoeshere"
73+
```
74+
75+
#### Responses
76+
77+
* 200: OK
78+
* 422: Unprocessable Entity (validation probably failed, see logs)
79+
80+
81+
82+
***
83+
84+
### Get latest result
85+
86+
```bash
87+
curl localhost/api/v1/results/latest
88+
-H "Accept: application/json"
89+
-H "Authorization: Bearer yourtokengoeshere"
90+
```
91+
92+
#### Responses
93+
94+
* 200: OK
95+
* 404: No result found
96+
97+
98+
99+
***
100+
101+
### Data Dictionary
102+
103+
The data structure returned mimic the `results` table but includes the addition of `download_bits`, `upload_bits`, `download_bits_human` and `upload_bits_human`.
104+
105+
```json
106+
{
107+
"data": {
108+
"id": 1009,
109+
"service": "ookla",
110+
"ping": 7.448,
111+
"download": 167270969,
112+
"upload": 115884569,
113+
"download_bits": 1338167752,
114+
"upload_bits": 927076552,
115+
"download_bits_human": "1.34 Gbps",
116+
"upload_bits_human": "927.08 Mbps",
117+
"benchmarks": null,
118+
"healthy": null,
119+
"status": "completed",
120+
"scheduled": true,
121+
"comments": null,
122+
"data": {
123+
},
124+
"created_at": "2025-01-13 16:37:00",
125+
"updated_at": "2025-01-13 16:37:17"
126+
}
127+
}
128+
```
129+
130+
131+
132+
***
133+
134+
### FAQ
135+
136+
<details>
137+
138+
<summary>Can I create, update or delete results through the API?</summary>
139+
140+
No, not at this time its read-only.
141+
142+
</details>
143+
144+
145+

getting-started/environment-variables.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ description: >-
1010

1111
<table><thead><tr><th width="218">Name</th><th width="103" data-type="checkbox">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>PUID</code></td><td>true</td><td>Used to set the user the container should run as.</td><td><code>1000</code></td></tr><tr><td><code>PGID</code></td><td>true</td><td>Used to set the group the container should run as.</td><td><code>1000</code></td></tr><tr><td><code>APP_NAME</code></td><td>false</td><td>Used to define the application's name in the dashboard and in notifications.<br></td><td></td></tr><tr><td><code>APP_KEY</code></td><td>true</td><td><p>Key used to encrypt and decrypt data.</p><p>You can generate a key at <a href="https://speedtest-tracker.dev">https://speedtest-tracker.dev</a>.</p></td><td></td></tr><tr><td><code>ADMIN_NAME</code></td><td>false</td><td>Name of the initial admin user.<br>Note: Only effective during initial setup.</td><td><code>Admin</code></td></tr><tr><td><code>ADMIN_EMAIL</code></td><td>false</td><td>Email of the initial admin user.<br>Note: Only effective during initial setup.</td><td><code>[email protected]</code></td></tr><tr><td><code>ADMIN_PASSWORD</code></td><td>false</td><td>Password of the initial admin user.<br>Note: Only effective during initial setup.</td><td><code>password</code></td></tr><tr><td><code>APP_URL</code></td><td>false</td><td>URL used for links in emails and notifications.</td><td><code>https://speedtest.example.com</code></td></tr><tr><td><code>ASSET_URL</code></td><td>false</td><td>URL used for assets, needed when using a reverse proxy.</td><td><code>https://speedtest.example.com</code></td></tr><tr><td><code>APP_TIMEZONE</code></td><td>false</td><td>Application timezone should be set if your database does not use UTC as its default timezone.</td><td><code>Europe/London</code></td></tr><tr><td><code>CHART_BEGIN_AT_ZERO</code></td><td>false</td><td>Begin the dashboard axis charts at zero.<br><br>- Default: <code>true</code></td><td><code>true</code> or <code>false</code></td></tr><tr><td><code>CHART_DATETIME_FORMAT</code></td><td>false</td><td>Set the formatting of timestamps in charts.<br><br>Formatting: <a href="https://www.php.net/manual/en/datetime.format.php">https://www.php.net/manual/en/datetime.format.php</a></td><td><code>j/m G:i</code><br>(18/10 20:06)</td></tr><tr><td><code>DATETIME_FORMAT</code></td><td>false</td><td>Set the formatting of timestamps in tables and notifications.<br><br>Formatting: <a href="https://www.php.net/manual/en/datetime.format.php">https://www.php.net/manual/en/datetime.format.php</a></td><td><code>j M Y, G:i:s</code><br>(18 Oct 2024, 20:06:01)</td></tr><tr><td><code>DISPLAY_TIMEZONE</code></td><td>false</td><td>Display timestamps in your local time.</td><td><code>America/New_York</code></td></tr><tr><td><code>CONTENT_WIDTH</code></td><td>false</td><td>Width of the content section of each page. Can be set to any value found in the Filament <a href="https://filamentphp.com/docs/3.x/panels/configuration#customizing-the-maximum-content-width">docs</a>.<br><br>- Default:<code>7xl</code></td><td></td></tr><tr><td><code>PUBLIC_DASHBOARD</code></td><td>false</td><td>Enables the public dashboard for guest (unauthenticated) users.<br><br>- Default:<code>false</code></td><td></td></tr><tr><td><code>DASHBOARD_POLLING</code></td><td>false</td><td>Frequency charts and stats refresh on the dashboard. Can be represented using a string in seconds or<code>false</code>to disable.<br><br>- Default:<code>60s</code></td><td></td></tr><tr><td><code>NOTIFICATION_POLLING</code></td><td>false</td><td>Frequency database notifications are polled. Can be represented using a string in seconds or<code>false</code>to disable.<br><br>- Default:<code>60s</code></td><td></td></tr><tr><td><code>RESULTS_POLLING</code></td><td>false</td><td>Frequency data refreshes in the results table. Can be represented using a string in seconds or<code>false</code>to disable.<br><br>- Default:<code>false</code></td><td></td></tr></tbody></table>
1212

13+
14+
15+
***
16+
1317
### Speedtest
1418

1519
<table><thead><tr><th width="221">Name</th><th data-type="checkbox">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>SPEEDTEST_SKIP_IPS</code></td><td>false</td><td>A comma separated list of public IP addresses where tests will be skipped when present.</td><td><code>127.0.0.1</code> or <code>127.0.0.0/16</code></td></tr><tr><td><code>SPEEDTEST_SCHEDULE</code></td><td>false</td><td>Cron expression used to run speedtests on a scheduled basis. https://crontab.guru/ is a helpful tool.</td><td><code>6 */2 * * *</code><br>(<em>At minute 6 past every 2nd hour)</em></td></tr><tr><td><code>SPEEDTEST_SERVERS</code></td><td>false</td><td><p>Comma separated list of server IDs to randomly use for speedtest.</p><p>To find servers near you visit: <a href="https://c.speedtest.net/speedtest-servers-static.php">https://c.speedtest.net/speedtest-servers-static.php</a></p></td><td><code>52365</code> or <code>36998,52365</code></td></tr><tr><td><code>SPEEDTEST_BLOCKED_SERVERS</code></td><td>false</td><td>Comma separated list of server IDs that should not be used when running speedtests.</td><td></td></tr><tr><td><code>SPEEDTEST_INTERFACE</code></td><td>false</td><td>Set the network interface to use for the test. This need to be the network interface available inside the container</td><td><code>eth0</code></td></tr><tr><td><code>THRESHOLD_ENABLED</code></td><td>false</td><td>Enable the thresholds. Note: Only effective during initial setup.</td><td><code>true</code></td></tr><tr><td><code>THRESHOLD_DOWNLOAD</code></td><td>false</td><td><p>Set the Download Threshold</p><p>Note: Only effective during initial setup.</p></td><td><code>900</code></td></tr><tr><td><code>THRESHOLD_UPLOAD</code></td><td>false</td><td><p>Set the Upload Threshold</p><p>Note: Only effective during initial setup.</p></td><td><code>900</code></td></tr><tr><td><code>THRESHOLD_PING</code></td><td>false</td><td><p>Set the Ping Threshold</p><p>Note: Only effective during initial setup.</p></td><td><code>25</code></td></tr><tr><td><code>PRUNE_RESULTS_OLDER_THAN</code></td><td>false</td><td>Set the value to greater than zero to prune stored results. This value should be represented in days, e.g. <code>7</code> will purge all results over 7 days old.</td><td><code>7</code></td></tr></tbody></table>
20+
21+
22+
23+
***
24+
25+
### API
26+
27+
<table><thead><tr><th width="221">Name</th><th data-type="checkbox">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td>API_RATE_LIMIT</td><td>false</td><td>Number of requests per minute to the API.<br><br>- Default: <code>60</code></td><td><code>100</code></td></tr></tbody></table>

other/data-dictionary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
#### Results
66

7-
<table><thead><tr><th width="181.66666666666666">Field</th><th width="188">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>id</code></td><td>primary key</td><td></td></tr><tr><td><code>service</code></td><td>string</td><td>Service user to run the speedtest.</td></tr><tr><td><code>ping</code></td><td>double</td><td>As milliseconds</td></tr><tr><td><code>download</code></td><td>unsigned big int</td><td>As bytes</td></tr><tr><td><code>upload</code></td><td>unsigned big int</td><td>As bytes</td></tr><tr><td><code>comments</code></td><td>text</td><td>User added comments.</td></tr><tr><td><code>data</code></td><td>json</td><td>The raw response from the speedtest.</td></tr><tr><td><code>status</code></td><td>string</td><td><ul><li><strong>Completed</strong> - a speedtest that ran successfully.</li><li><strong>Failed</strong> - a speedtest that failed to run successfully.</li><li><strong>Started</strong> - a speedtest that has been started but has not finished running.</li><li><strong>Skipped</strong> - a speedtest that was skipped. See message for more details.</li></ul></td></tr><tr><td><code>scheduled</code></td><td>boolean</td><td>Was the result scheduled.</td></tr><tr><td><code>created_at</code></td><td>timestamp</td><td>When the record was created.</td></tr><tr><td><code>updated_at</code></td><td>timestamp</td><td>When the record was last updated.</td></tr></tbody></table>
7+
<table><thead><tr><th width="181.66666666666666">Field</th><th width="188">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>id</code></td><td>primary key</td><td></td></tr><tr><td><code>service</code></td><td>string</td><td>Service user to run the speedtest.</td></tr><tr><td><code>ping</code></td><td>double</td><td>As milliseconds</td></tr><tr><td><code>download</code></td><td>unsigned big int</td><td>As bytes</td></tr><tr><td><code>upload</code></td><td>unsigned big int</td><td>As bytes</td></tr><tr><td><code>comments</code></td><td>text</td><td>User added comments.</td></tr><tr><td><code>data</code></td><td>json</td><td>The raw response from the speedtest.</td></tr><tr><td><code>benchmarks</code></td><td>json</td><td>Captures the speedtest's benchmarks at run time.</td></tr><tr><td><code>healthy</code></td><td>boolean</td><td>Indicates if the speedtest was healthy compared to the benchmark.</td></tr><tr><td><code>status</code></td><td>string</td><td><ul><li><strong>Completed</strong> - a speedtest that ran successfully.</li><li><strong>Failed</strong> - a speedtest that failed to run successfully.</li><li><strong>Started</strong> - a speedtest that has been started but has not finished running.</li><li><strong>Skipped</strong> - a speedtest that was skipped. See message for more details.</li></ul></td></tr><tr><td><code>scheduled</code></td><td>boolean</td><td>Was the result scheduled.</td></tr><tr><td><code>created_at</code></td><td>timestamp</td><td>When the record was created.</td></tr><tr><td><code>updated_at</code></td><td>timestamp</td><td>When the record was last updated.</td></tr></tbody></table>

0 commit comments

Comments
 (0)