Skip to content

Commit d707613

Browse files
committed
Add documentation for new files.simplyprint.io (API Files)
1 parent 5504d6f commit d707613

File tree

5 files changed

+136
-4
lines changed

5 files changed

+136
-4
lines changed

source/includes/_api_files.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# API Files
2+
3+
The base URL for the SimplyPrint Files API is `https://files.simplyprint.io/{id}/`. Use the exact same authentication as the normal api endpoint. It is very important you ensure you send files with the correct file extension. The API will not be able to determine the file type based on the content.
4+
5+
## Upload a file using the API
6+
7+
`POST {id}/files/Upload`
8+
9+
> Example request to upload a file less than 100MB
10+
11+
```shell
12+
curl -X POST "https://files.simplyprint.io/{id}/files/Upload" \
13+
-H 'accept: application/json' \
14+
-H "X-API-KEY: {API_KEY}" \
15+
-F "file=@/path/to/file.gcode"
16+
```
17+
> Success response
18+
19+
```json
20+
{
21+
"status":true,
22+
"message": null,
23+
"file": {
24+
"id": "f568ead4bbc2d881efc8a9a05f3bd585334cd8c662347ba2dfad7250176b0abd",
25+
"name": "file.gcode",
26+
"size": 13439
27+
}
28+
}
29+
```
30+
31+
> Multiple parts for a single file larger than 100MB. The first filename is the filename of the entire file.
32+
33+
```shell
34+
curl -X POST "https://files.simplyprint.io/{id}/files/Upload" \
35+
-H 'accept: application/json' \
36+
-H "X-API-KEY: {API_KEY}" \
37+
-F "file=@/path/to/part1.3mf"
38+
-F "totalSize=3352316"
39+
```
40+
> Success response with continueToken
41+
42+
```json
43+
{
44+
"status":true,
45+
"message":null,
46+
"continueToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzM4NCJ9.eyJ0eXBlIjoiYWN0ao9uX3Rva2VuIiwiYWN0aW9uIjoiZmlsZV9jb250aW51ZV91cGxvYWQiLCJ1c2VyIjo2OTc2LCJjb21wYW55IjoyLCJkYXRhIja7ImJ1Y2tldEhhc2giOiI0MGQ2MzgwNmQwYWUxODhkNjc5YzY0NjA0M2RiYjUxMTc0NTViNTc1NjNlODEzZDc2MGRjMTJkMzVaYjdmY2Y0IiwidG90YWxTaXplIjoxNjc2MTU4NH0sImlhdCI6MTcyNTU2MjEzMywiZXhwIjoxNzI1NjQ4NTMzfQ.9qyNyx9A4Ox_6GrFSxXpxlpLcAKaSr8ln84X3yuWdhT_2O3L8-lGWaXAbQk9VvR-3pu1-a9p40amnt6Fghy49InjzCfNMRp-6-Ft_uMRf6PbmcCCrksvRxNP38ImoXy6"
47+
}
48+
```
49+
50+
> Continue uploading the file (send next part with only the continueToken)
51+
52+
```shell
53+
curl -X POST "https://files.simplyprint.io/{id}/files/Upload" \
54+
-H 'accept: application/json' \
55+
-H "X-API-KEY: {API_KEY}" \
56+
-F "continueToken=eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzM4NCJ9.eyJ0eXBlIjoiYWN0ao9uX3Rva2VuIiwiYWN0aW9uIjoiZmlsZV9jb250aW51ZV91cGxvYWQiLCJ1c2VyIjo2OTc2LCJjb21wYW55IjoyLCJkYXRhIja7ImJ1Y2tldEhhc2giOiI0MGQ2MzgwNmQwYWUxODhkNjc5YzY0NjA0M2RiYjUxMTc0NTViNTc1NjNlODEzZDc2MGRjMTJkMzVaYjdmY2Y0IiwidG90YWxTaXplIjoxNjc2MTU4NH0sImlhdCI6MTcyNTU2MjEzMywiZXhwIjoxNzI1NjQ4NTMzfQ.9qyNyx9A4Ox_6GrFSxXpxlpLcAKaSr8ln84X3yuWdhT_2O3L8-lGWaXAbQk9VvR-3pu1-a9p40amnt6Fghy49InjzCfNMRp-6-Ft_uMRf6PbmcCCrksvRxNP38ImoXy6" \
57+
-F "file=@/path/to/part2.3mf"
58+
```
59+
60+
> Sucessful final response as we ensured to only send exactly the total size of the file.
61+
62+
```json
63+
{
64+
"status":true,
65+
"message":null,
66+
"file": {
67+
"id": "f568ead4bbc2d881efc8a9a05f3bd585334cd8c662347ba2dfad7250176b0abd",
68+
"name": "part1.3mf",
69+
"size": 3352316
70+
}
71+
}
72+
```
73+
74+
### Request
75+
76+
| Parameter | Type | Required | Description |
77+
| --------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
78+
| `file` | file | yes | Uploaded file (Max 100mb) |
79+
| `continueToken` | string | no | Optional token you'll get if you need to continue the upload for files greater than 100MB. |
80+
| `totalSize` | integer | no | Send this if you want a continueToken, by providing the total size of the entire file you want to upload |
81+
82+
### Response
83+
84+
| Parameter | Type | Description |
85+
| ------------ | ------- | -------------------------------------------------------------|
86+
| `status` | boolean | True if the request was successful. |
87+
| `message` | string | Error message if `status` is false. |
88+
| `continueToken` | string | For every subsequent request that still has some pending size based on the total size this will be returned instead of the file. |
89+
| `file.*` | object | Final file object after entire file has been uploaded |
90+
| `file.id` | string | The API File ID you'll need to use other SimplyPrint APIs |
91+
| `file.name` | string | Name used to reference the file |
92+
| `file.size` | int | Total size of uploaded file |
93+

source/includes/_files.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,45 @@
11
# Files
22

33
<aside class="notice">
4-
You cannot upload new files via the API yet - this is coming soon
4+
You can only upload files through the API using <a href="#api-files">API Files</a>
55
</aside>
66

7+
## Add an API File to files
8+
9+
`POST {id}/files/Upload?folder={folder}`
10+
11+
12+
| Parameter | Type | Required | Description |
13+
| --------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14+
| `folder` (GET) | integer | no | Folder ID to get files for. **Defaults to 0 (root folder)** |
15+
| `fileId` (POST) | string | yes | File ID from [API Files](#api-files)
16+
17+
### Response
18+
19+
| Parameter | Type | Description |
20+
| ------------ | ------- | ---------------------------------------------------------- |
21+
| `status` | boolean | True if the request was successful. |
22+
| `message` | string | Error message if `status` is false. |
23+
| `id` | string | User file ID of newly added file |
24+
25+
26+
```shell
27+
curl -X POST https://api.simplyprint.io/{id}/files/Upload?folder=5290 \
28+
-H 'accept: application/json' \
29+
-H 'X-API-KEY: {API_KEY}' \
30+
-F 'fileId=43aaad56548c959f655d0524027b726a7514493ec8436f4942f876bb07eab731'
31+
```
32+
33+
> Success Response
34+
35+
```json
36+
{
37+
"status":true,
38+
"message":null,
39+
"id":"6f7d79212f384c6b8eae2811c37d9338"
40+
}
41+
```
42+
743
## List Files and Folders
844

945
```shell

source/includes/_printers.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ curl https://api.simplyprint.io/{id}/printers/actions/CreateJob?pid=1234&filesys
324324
```
325325

326326
<aside class="notice">
327-
You cannot upload new files via the API yet - only files from your file system or print queue can be printed via the API
327+
You can only upload files through the API using <a href="#api-files">API Files</a>
328328
</aside>
329329

330330
This endpoint can be used to create a print job for one or more printers. The printers have to be in the `operational` state.
@@ -341,6 +341,7 @@ To start a print job you must either specify a `filesystem` ID, a `queue_file` I
341341
| `filesystem` | string | no | The filesystem ID of the file to print. |
342342
| `queue_file` | integer | no | The queue ID of the queue item to print. |
343343
| `next_queue_item` | boolean | no | If true, the next queue item will be printed.<br>**This requires the Print Farm plan** |
344+
| `file_id` | string | no | File ID from [API Files](#api-files) - used to start a file without adding it as a queue item or user file.
344345

345346
#### Extra settings for `next_queue_item`
346347

source/includes/_queue.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ curl https://api.simplyprint.io/{id}/queue/AddItem \
3434
</aside>
3535

3636
<aside class="notice">
37-
You cannot upload new files via the API yet - this is coming soon
37+
You can only upload files through the API using <a href="#api-files">API Files</a>
3838
</aside>
3939

4040
This endpoint adds a file to the queue. The file can either be a file on the filesystem or an uploaded stl/3mf/obj/gcode/gco/nc/npg file.
@@ -47,9 +47,10 @@ This endpoint adds a file to the queue. The file can either be a file on the fil
4747

4848
| Parameter | Type | Required | Description |
4949
| ------------ | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
50-
| `filesystem` | string | no | The filesystem id of the file to add to the queue. |
50+
| `filesystem` | string | no | The [filesystem](#files) id of the file to add to the queue. |
5151
| `amount` | integer | no | The amount of prints to add to the queue.<br>**Default: 1** |
5252
| `group` | integer | no | If you have Queue Groups - ID of the group the item should be added to.<br>**Default: 0 - required if you have Queue Groups** |
53+
| `fileId` | string | no | Optional File ID from [API File](#api-files) - use this to add a file uploaded via the API. |
5354

5455
### Response
5556

source/index.html.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ includes:
1212
- printers
1313
- filament
1414
- files
15+
- api_files
1516
- queue
1617
- account
1718
- jobs

0 commit comments

Comments
 (0)