Skip to content

Commit 82c1c3b

Browse files
committed
API Changes
1 parent ef18833 commit 82c1c3b

File tree

3 files changed

+127
-25
lines changed

3 files changed

+127
-25
lines changed

source/includes/_account.md

Lines changed: 123 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Create company groups
44

55
```shell
6-
curl https://api.simplyprint.io/{id}/account/settings/rank/Create \
6+
curl https://api.simplyprint.io/{id}/account/settings/groups/Create \
77
-X POST \
88
-H 'accept: application/json' \
99
-H 'X-API-KEY: {API_KEY}'
@@ -56,7 +56,7 @@ This endpoint creates a new group in the company.
5656

5757
### Request
5858

59-
`POST /{id}/account/settings/rank/Create`
59+
`POST /{id}/account/settings/groups/Create`
6060

6161
| Parameter | Type | Required | Description |
6262
| --------- | ---- | -------- | ----------- |
@@ -77,7 +77,7 @@ This endpoint creates a new group in the company.
7777
## Update company groups
7878

7979
```shell
80-
curl https://api.simplyprint.io/{id}/account/settings/rank/Update \
80+
curl https://api.simplyprint.io/{id}/account/settings/groups/Update \
8181
-X POST \
8282
-H 'accept: application/json' \
8383
-H 'X-API-KEY: {API_KEY}'
@@ -132,7 +132,7 @@ This endpoint updates the groups in the company.
132132

133133
### Request
134134

135-
`POST /{id}/account/settings/rank/Update`
135+
`POST /{id}/account/settings/groups/Update`
136136

137137
| Parameter | Type | Required | Description |
138138
| --------- | ---- | -------- | ----------- |
@@ -218,7 +218,7 @@ This endpoint returns a list of groups that exist in the company.
218218
## Delete company group
219219

220220
```shell
221-
curl https://api.simplyprint.io/{id}/account/settings/rank/Delete \
221+
curl https://api.simplyprint.io/{id}/account/settings/groups/Delete \
222222
-X POST \
223223
-H 'accept: application/json' \
224224
-H 'X-API-KEY: {API_KEY}'
@@ -252,7 +252,7 @@ curl https://api.simplyprint.io/{id}/account/settings/rank/Delete \
252252

253253
### Request
254254

255-
`POST /{id}/account/settings/rank/Delete`
255+
`POST /{id}/account/settings/groups/Delete`
256256

257257
| Parameter | Type | Required | Description |
258258
| --------- | ---- | -------- | ----------- |
@@ -265,3 +265,120 @@ curl https://api.simplyprint.io/{id}/account/settings/rank/Delete \
265265
| --------- | ---- | ----------- |
266266
| `status` | boolean | True if the request was successful. |
267267
| `message` | string | Error message if `status` is false. |
268+
269+
270+
## Get statistics
271+
272+
```shell
273+
curl https://api.simplyprint.io/{id}/account/GetStatistics \
274+
-X POST \
275+
-H 'accept: application/json' \
276+
-H 'X-API-KEY: {API_KEY}'
277+
```
278+
279+
> Request body
280+
281+
```json
282+
{
283+
"users": [1234, 1235, 1945],
284+
"printers": [1234, 1235, 1945],
285+
"start_date": "1677629786",
286+
"end_date": "1677629786"
287+
}
288+
```
289+
290+
> Success response
291+
292+
```json
293+
{
294+
"status": true,
295+
"message": null,
296+
"data": {
297+
"total_print_seconds": 1234,
298+
"total_filament_usage_gram": 1241.1231231,
299+
"print_job_count": 123,
300+
"regretted_print_jobs": 123,
301+
"failed_print_jobs": 123,
302+
"printer_error_print_jobs": 123,
303+
"done_print_jobs": 123,
304+
"date_range": {
305+
"from": "2023-02-22",
306+
"to": "2023-03-02",
307+
"general": false
308+
},
309+
"printers": {
310+
"3104": {
311+
"name": "Printer 1",
312+
"done": 0,
313+
"failed": 0,
314+
"printer_error": 0,
315+
"regretted": 0,
316+
"filament_usage_gram": 0
317+
},
318+
...
319+
},
320+
"print_jobs": [
321+
{
322+
"date": "2023-02-27",
323+
"started": "2023-02-27 11:39:34",
324+
"ended": "2023-02-27 11:56:18",
325+
"cancelled": 1,
326+
"failed": 0,
327+
"cancel_reason_type": 5,
328+
"print_seconds": 1004,
329+
"filament_usage_gram": 0.03758012402132279
330+
},
331+
...
332+
]
333+
}
334+
}
335+
```
336+
337+
This endpoint returns statistics for the user / company.
338+
339+
### Request
340+
341+
`POST /{id}/account/GetStatistics`
342+
343+
| Parameter | Type | Required | Description |
344+
| --------- | ---- | -------- | ----------- |
345+
| `users` | array | no | Array of user ids to get statistics for. Don't include this parameter to get statistics for all users. |
346+
| `printers` | array | no | Array of printer ids to get statistics for. Don't include this parameter to get statistics for all printers. |
347+
| `start_date` | string | no | The start date of the statistics. Provide a unix timestamp in seconds. |
348+
| `end_date` | string | no | The end date of the statistics. Provide a unix timestamp in seconds. |
349+
350+
### Response
351+
352+
| Parameter | Type | Description |
353+
| --------- | ---- | ----------- |
354+
| `status` | boolean | True if the request was successful. |
355+
| `message` | string | Error message if `status` is false. |
356+
| `data` | object | Statistics object. |
357+
| `data.total_print_seconds` | integer | Total print seconds. |
358+
| `data.total_filament_usage_gram` | float | Total filament usage in grams. |
359+
| `data.print_job_count` | integer | Total print job count. |
360+
| `data.regretted_print_jobs` | integer | Total regretted print job count. |
361+
| `data.failed_print_jobs` | integer | Total failed print job count. |
362+
| `data.printer_error_print_jobs` | integer | Total printer error print job count. |
363+
| `data.done_print_jobs` | integer | Total successful print job count. |
364+
| `data.date_range` | object | Date range object. |
365+
| `data.date_range.from` | string | Start date of the statistics. |
366+
| `data.date_range.to` | string | End date of the statistics. |
367+
| `data.date_range.general` | boolean | True if the date range is general. |
368+
| `data.printers` | object | Object of printer statistics. |
369+
| `data.printers.{id}` | object | Printer statistics object. |
370+
| `data.printers.{id}.name` | string | Printer name. |
371+
| `data.printers.{id}.done` | integer | Successful print job count. |
372+
| `data.printers.{id}.failed` | integer | Failed print job count. |
373+
| `data.printers.{id}.printer_error` | integer | Printer error print job count. |
374+
| `data.printers.{id}.regretted` | integer | Regretted print job count. |
375+
| `data.printers.{id}.filament_usage_gram` | float | Filament usage in grams. |
376+
| `data.print_jobs` | array | Array of print job statistics. |
377+
| `data.print_jobs[].date` | string | Date of the print job. |
378+
| `data.print_jobs[].started` | string | Start time of the print job. |
379+
| `data.print_jobs[].ended` | string | End time of the print job. |
380+
| `data.print_jobs[].cancelled` | integer | True if the print job was cancelled. |
381+
| `data.print_jobs[].failed` | integer | True if the print job failed. |
382+
| `data.print_jobs[].cancel_reason_type` | integer | The reason for cancelling the print job. |
383+
| `data.print_jobs[].print_seconds` | integer | Print seconds. |
384+
| `data.print_jobs[].filament_usage_gram` | float | Filament usage in grams. |

source/includes/_printers.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Get printer info
44

55
```shell
6-
curl https://api.simplyprint.io/{id}/printers/actions/Get \
6+
curl https://api.simplyprint.io/{id}/printers/Get \
77
-X ? \
88
-H 'accept: application/json' \
99
-H 'X-API-KEY: {API_KEY}'
@@ -13,26 +13,11 @@ curl https://api.simplyprint.io/{id}/printers/actions/Get \
1313
This endpoint has not been implemented yet, and is just a placeholder for now.
1414
</aside>
1515

16-
### Request
17-
18-
`? /{id}/printers/actions/Get`
19-
20-
## List printers
21-
22-
```shell
23-
curl https://api.simplyprint.io/{id}/printers/actions/List \
24-
-X ? \
25-
-H 'accept: application/json' \
26-
-H 'X-API-KEY: {API_KEY}'
27-
```
28-
29-
<aside class="warning">
30-
This endpoint has not been implemented yet, and is just a placeholder for now.
31-
</aside>
16+
TODO: Document this endpoint.
3217

3318
### Request
3419

35-
`? /{id}/printers/actions/List`
20+
`? /{id}/printers/Get`
3621

3722
## Start print / create job
3823

source/index.html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ curl {base_url}/account/Test \
111111

112112
To verify that your API key is valid and that you have access to the desired organization, you can make a request to the `/account/Test` endpoint.
113113

114-
To make any request to the SimplyPrint API, you will need to include your API key in the request header. You can do this by including the `X-API-KEY` header in your request. On the right side of this page, you can see an example of how to make a request to the `/account/Test` endpoint using cURL and Python.
114+
To make any request to the SimplyPrint API, you will need to include your API key in the request header. You can do this by including the `X-API-KEY` header in your request. On the right side of this page, you can see an example of how to make a request to the `/account/Test` endpoint using cURL.
115115

116116
If you are unable to successfully make a request to the `/account/Test` endpoint using the provided example, there may be a few possible issues:
117117

0 commit comments

Comments
 (0)