-
Notifications
You must be signed in to change notification settings - Fork 463
REST API
The COCO Annotator API is organized around REST. The API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. JSON is returned by most API responses and will be stated otherwise if not.
A swagger interface can be found at localhost:5000/api
which lists each endpoint and allows you to call it from your web browser.
-
Image
- GET
/image/
- POST
/image/
- GET
/image/{id}
-
DELETE
/image/{id}
` - GET
/image/{id}/coco
- GET
- Annotation
- GET
/annotation/
- POST
/annotation/
- GET
/annotation/{id}
- DELETE
/annotation/{id}
- GET
- Category
- GET
/category/
- POST
/category/
- GET
/category/{id}
- DELETE
/category/{id}
- GET
/category/data
- GET
- Annotator
- POST
/annotator/data
- GET
/annotator/data/{image_id}
- POST
- Dataset
- GET
/dataset/
- POST
/dataset/
- GET
/dataset/data
- DELETE
/dataset/{id}
- POST
/dataset/{id}
- GET
/dataset/{id}/coco
- POST
/dataset/{id}/coco
- GET
/dataset/{id}/data
- GET
- Undo
- DELETE
/undo/
- POST
/undo/
- GET
/undo/
- DELETE
Returns all images in the database.
Request:
curl -X GET "http://localhost:5000/api/image/"
Response:
[]
Returns an image with the provided ID. Image ID's are sequentially generated when the image object is created in the database.
Augment | Required | Type | Default | Location | Description |
---|---|---|---|---|---|
asAttachment | false |
Boolean | true |
URL paramter | Sends the image file with a Content-Disposition: attachment header |
width | false |
Integer | Image Width | URL paramter | Returns image with provided width (Maintains aspect ratio) |
height | false |
Integer | Image Height | URL paramter | Returns image with provided height (Maintains aspect ratio) |
Request:
curl -X GET "http://localhost:5000/api/image/1?asAttachment=true"
Response:
Binary Output
Partial deletes an image with the provided ID. Image ID's are sequentially generated when the image object is created in the database.
Request:
curl -X DELETE "http://localhost:5000/api/image/1
Response:
{
"success": true
}
Returns COCO format json which includes all annotations and categories.
Request:
curl -X GET "http://localhost:5000/api/image/4/coco
Response:
{
"images": [
{
"id": 4,
"path": "/data/datasets/Random_Dataset/Image4.png",
"dataset_id": 2,
"width": 653,
"height": 303,
"file_name": "Image4.png",
"metadata": {}
}
],
"categories": [...],
"annotations": [...]
}