Import
Import¶
POST /tasks/import/check-images¶
Check if images' hashes already exist in the system
Example: Array of hashes - base64 encoded string using sha-256
[ "TpcxOt/fwbUYLeC3eCyFDZ3zfF1mKxY9LrrWKegOiIA=", "VwjkXiodrrJjviLsDzIVl9mmo/MgGtB9EwYXRZMKsA0=" ]
Response: Array of missing hashes
[ "VwjkXiodrrJjviLsDzIVl9mmo/MgGtB9EwYXRZMKsA0=" ]
POST /tasks/import/files¶
Upload files (100 max per request)
Params:
- name - String connects content and metadata
- id - String unique per file in request
- hash - optional if you want server to first check if data already exist. Also used to verify received content (consistency check)
Example:
------WebKitFormBoundary5A8GQaO10jWTnQDM Content-Disposition: form-data; name="46a28cd6-61b3-4e97-a507-99c3e8ed029c" {"id":"/image1.json","hash":null,"type":"annotation","format":"Supervisely"} ------WebKitFormBoundary5A8GQaO10jWTnQDM Content-Disposition: form-data; name="46a28cd6-61b3-4e97-a507-99c3e8ed029c-file"; filename="image1.json" ------WebKitFormBoundary5A8GQaO10jWTnQDM Content-Disposition: form-data; name="646d1109-b74f-4757-a86d-f8dc4ebf3699" {"id":"/classes.json","hash":null,"type":"class","format":"Supervisely"} ------WebKitFormBoundary5A8GQaO10jWTnQDM Content-Disposition: form-data; name="646d1109-b74f-4757-a86d-f8dc4ebf3699-file"; filename="classes.json" ------WebKitFormBoundary5A8GQaO10jWTnQDM Content-Disposition: form-data; name="fdf24229-c054-4aa5-9dbe-7c91a3988b6b" {"id":"someImg.png","hash":"WNDkG8F5C3SUxfUT8pQRYJnvtDFEtJWJe723A2gLjq8=","type":"image","format":"Supervisely"} ------WebKitFormBoundary5A8GQaO10jWTnQDM Content-Disposition: form-data; name="fdf24229-c054-4aa5-9dbe-7c91a3988b6b-file"; filename="someImg.png"
Response:
[ { "id": "/image1.json", "fileId": "31e96a7e-1137-4752-be3f-d63d19874d6b", "errors": [] }, { "id": "/classes.json", "fileId": "111a89f1-7967-4616-a42f-215083324c91", "errors": [] }, { "id": "/someImg.png", "hash": "WNDkG8F5C3SUxfUT8pQRYJnvtDFEtJWJe723A2gLjq8=", "errors": [] } ]
Python:
import requests files = { 'random-string-to-match-metadata-with-content-file': open('img.png', 'rb') } url = 'https://api.supervise.ly/v1/tasks/import/files' r = requests.post(url, headers = { 'x-api-key': <api-key> }, files = files, data = { 'random-string-to-match-metadata-with-content': '{"id":"img.png"}' } ) print(r.text)
POST /tasks/import¶
Run import task
Example:
{ "project": { "id": null, "title": "Supervisely" }, "preset": 1, "onConflict": "ignore", "files": [ { "hash": "WNDkG8F5C3SUxfUT8pQRYJnvtDFEtJWJe723A2gLjq8=", "path": "/img.png" }, { "fileId": "111a89f1-7967-4616-a42f-215083324c91", "path": "/img.json" } ] }
Response:
{ "taskId": 103 }
POST /tasks/import/local¶
Run import from preset task
Example:
{ "id": 1, "title": "My Super Project", "datasetsIds": [1, 2] }
Response:
{ "taskId": 103 }