|
| 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 | +
|
0 commit comments