Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing endpoints, edit responses #11

Merged
merged 17 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions scripts/check_outdated.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import os
import re

from settings import ENDPOINTS_DIR

ENDPOINTS_DIR = "<SITE-API/API/Endpoints PATH>"
DOCUMENTATION_DIR = os.path.join(os.path.dirname(__file__), "../source/includes")

def get_all_endpoints():
def get_all_endpoints(with_disabled=False):
endpoints = []
for root, dirs, files in os.walk(ENDPOINTS_DIR):
for file in files:
with open(os.path.join(root, file), 'r') as f:
if re.search(r"public bool \$api_disabled = true;", f.read()):
continue
if not with_disabled:
with open(os.path.join(root, file), 'r') as f:
if re.search(r"public *bool *\$api_disabled *= true;", f.read()):
continue

endpoints.append(root.split(ENDPOINTS_DIR)[1] + "/" + file[:-4])

Expand All @@ -25,12 +25,12 @@ def get_all_documented_endpoints():
file_cat = file[1:-3]
with open(os.path.join(DOCUMENTATION_DIR, file), 'r') as f:
for line in f.readlines():
match = re.match(r"curl https:\/\/api\.simplyprint\.io\/\{id\}(.*?)(\?| \\).*$", line)
match = re.match(r"(?:curl)?.*https:\/\/api\.simplyprint\.io\/\{id\}(.*?)(\?| \\).*$", line)

if not match:
continue

endpoints.append(match.group(1))
endpoints.append(match.group(1).replace("\"", ""))

endpoints.sort()
return endpoints
Expand Down
1 change: 0 additions & 1 deletion source/includes/_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ This endpoint updates the groups in the company.

```shell
curl https://api.simplyprint.io/{id}/account/GetGroups \
-X GET \
-H 'accept: application/json' \
-H 'X-API-KEY: {API_KEY}'
```
Expand Down
70 changes: 37 additions & 33 deletions source/includes/_api_files.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# API Files

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.
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.

## Upload a file using the API

<aside class="notice">
This endpoint requires the <b>Print Farm</b> plan.
</aside>

`POST {id}/files/Upload`
`POST /{id}/files/Upload`

> Example request to upload a file less than 100MB

Expand All @@ -18,17 +20,18 @@ curl -X POST "https://files.simplyprint.io/{id}/files/Upload" \
-H "X-API-KEY: {API_KEY}" \
-F "file=@/path/to/file.gcode"
```

> Success response

```json
{
"status":true,
"message": null,
"file": {
"id": "f568ead4bbc2d881efc8a9a05f3bd585334cd8c662347ba2dfad7250176b0abd",
"name": "file.gcode",
"size": 13439
}
"status": true,
"message": null,
"file": {
"id": "f568ead4bbc2d881efc8a9a05f3bd585334cd8c662347ba2dfad7250176b0abd",
"name": "file.gcode",
"size": 13439
}
}
```

Expand All @@ -41,13 +44,14 @@ curl -X POST "https://files.simplyprint.io/{id}/files/Upload" \
-F "file=@/path/to/part1.3mf"
-F "totalSize=3352316"
```

> Success response with continueToken

```json
{
"status":true,
"message":null,
"continueToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzM4NCJ9.eyJ0eXBlIjoiYWN0ao9uX3Rva2VuIiwiYWN0aW9uIjoiZmlsZV9jb250aW51ZV91cGxvYWQiLCJ1c2VyIjo2OTc2LCJjb21wYW55IjoyLCJkYXRhIja7ImJ1Y2tldEhhc2giOiI0MGQ2MzgwNmQwYWUxODhkNjc5YzY0NjA0M2RiYjUxMTc0NTViNTc1NjNlODEzZDc2MGRjMTJkMzVaYjdmY2Y0IiwidG90YWxTaXplIjoxNjc2MTU4NH0sImlhdCI6MTcyNTU2MjEzMywiZXhwIjoxNzI1NjQ4NTMzfQ.9qyNyx9A4Ox_6GrFSxXpxlpLcAKaSr8ln84X3yuWdhT_2O3L8-lGWaXAbQk9VvR-3pu1-a9p40amnt6Fghy49InjzCfNMRp-6-Ft_uMRf6PbmcCCrksvRxNP38ImoXy6"
"status": true,
"message": null,
"continueToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzM4NCJ9.eyJ0eXBlIjoiYWN0ao9uX3Rva2VuIiwiYWN0aW9uIjoiZmlsZV9jb250aW51ZV91cGxvYWQiLCJ1c2VyIjo2OTc2LCJjb21wYW55IjoyLCJkYXRhIja7ImJ1Y2tldEhhc2giOiI0MGQ2MzgwNmQwYWUxODhkNjc5YzY0NjA0M2RiYjUxMTc0NTViNTc1NjNlODEzZDc2MGRjMTJkMzVaYjdmY2Y0IiwidG90YWxTaXplIjoxNjc2MTU4NH0sImlhdCI6MTcyNTU2MjEzMywiZXhwIjoxNzI1NjQ4NTMzfQ.9qyNyx9A4Ox_6GrFSxXpxlpLcAKaSr8ln84X3yuWdhT_2O3L8-lGWaXAbQk9VvR-3pu1-a9p40amnt6Fghy49InjzCfNMRp-6-Ft_uMRf6PbmcCCrksvRxNP38ImoXy6"
}
```

Expand All @@ -65,33 +69,33 @@ curl -X POST "https://files.simplyprint.io/{id}/files/Upload" \

```json
{
"status":true,
"message":null,
"file": {
"id": "f568ead4bbc2d881efc8a9a05f3bd585334cd8c662347ba2dfad7250176b0abd",
"name": "part1.3mf",
"size": 3352316
}
"status": true,
"message": null,
"file": {
"id": "f568ead4bbc2d881efc8a9a05f3bd585334cd8c662347ba2dfad7250176b0abd",
"name": "part1.3mf",
"size": 3352316
}
}
```

### Request

| Parameter | Type | Required | Description |
| --------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `file` | file | yes | Uploaded file (Max 100mb) |
| `continueToken` | string | no | Optional token you'll get if you need to continue the upload for files greater than 100MB. |
| `totalSize` | integer | no | Send this if you want a continueToken, by providing the total size of the entire file you want to upload |
| Parameter | Type | Required | Description |
|-----------------|---------|----------|----------------------------------------------------------------------------------------------------------|
| `file` | file | yes | Uploaded file (Max 100mb) |
| `continueToken` | string | no | Optional token you'll get if you need to continue the upload for files greater than 100MB. |
| `totalSize` | integer | no | Send this if you want a continueToken, by providing the total size of the entire file you want to upload |

### Response

| Parameter | Type | Description |
| ------------ | ------- | -------------------------------------------------------------|
| `status` | boolean | True if the request was successful. |
| `message` | string | Error message if `status` is false. |
| `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. |
| `file.*` | object | Final file object after entire file has been uploaded |
| `file.id` | string | The API File ID you'll need to use other SimplyPrint APIs |
| `file.name` | string | Name used to reference the file |
| `file.size` | int | Total size of uploaded file |
| Parameter | Type | Description |
|-----------------|---------|----------------------------------------------------------------------------------------------------------------------------------|
| `status` | boolean | True if the request was successful. |
| `message` | string | Error message if `status` is false. |
| `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. |
| `file.*` | object | Final file object after entire file has been uploaded |
| `file.id` | string | The API File ID you'll need to use other SimplyPrint APIs |
| `file.name` | string | Name used to reference the file |
| `file.size` | int | Total size of uploaded file |

Loading
Loading