Sync Annotations
POST/v1/datasets/<dataset_owner>/<dataset_name>/sync-annotations
- Bash
- Node
- Python
- Response
curl -X POST 'https://<my_api_endpoint>/api/v1/datasets/<dataset_owner>/<dataset_name>/sync-annotations' \
-H "Authorization: Bearer $REINFER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"annotations": [
{
"comment_uid": "<source_id>.<comment_id>",
"labels": {
"assigned": [
{
"external_id": "8d59822a-af84-4f5d-9dd4-6b0e8e76d3c5",
"name": "Some Parent"
},
{
"external_id": "298f5e0f-a52a-42b2-87b3-050ad3ed262b",
"name": "Some Parent > Some Child"
}
]
}
},
{
"comment_uid": "<source_id>.<comment_id>",
"labels": {
"assigned": [
{
"external_id": "8d59822a-af84-4f5d-9dd4-6b0e8e76d3c5"
},
{
"name": "Some Parent > Some Child"
}
]
}
}
]
}'
const request = require("request");
request.post(
{
url: "https://<my_api_endpoint>/api/v1/datasets/<dataset_owner>/<dataset_name>/sync-annotations",
headers: {
Authorization: "Bearer " + process.env.REINFER_TOKEN,
},
json: true,
body: {
annotations: [
{
comment_uid: "<source_id>.<comment_id>",
labels: {
assigned: [
{
external_id: "8d59822a-af84-4f5d-9dd4-6b0e8e76d3c5",
name: "Some Parent",
},
{
external_id: "298f5e0f-a52a-42b2-87b3-050ad3ed262b",
name: "Some Parent > Some Child",
},
],
},
},
{
comment_uid: "<source_id>.<comment_id>",
labels: {
assigned: [
{ external_id: "8d59822a-af84-4f5d-9dd4-6b0e8e76d3c5" },
{ name: "Some Parent > Some Child" },
],
},
},
],
},
},
function (error, response, json) {
// digest response
console.log(JSON.stringify(json, null, 2));
}
);
import json
import os
import requests
response = requests.post(
"https://<my_api_endpoint>/api/v1/datasets/<dataset_owner>/<dataset_name>/sync-annotations",
headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
json={
"annotations": [
{
"comment_uid": "<source_id>.<comment_id>",
"labels": {
"assigned": [
{
"name": "Some Parent",
"external_id": "8d59822a-af84-4f5d-9dd4-6b0e8e76d3c5",
},
{
"name": "Some Parent > Some Child",
"external_id": "298f5e0f-a52a-42b2-87b3-050ad3ed262b",
},
]
},
},
{
"comment_uid": "<source_id>.<comment_id>",
"labels": {
"assigned": [
{
"external_id": "8d59822a-af84-4f5d-9dd4-6b0e8e76d3c5"
},
{"name": "Some Parent > Some Child"},
]
},
},
]
},
)
print(json.dumps(response.json(), indent=2, sort_keys=True))
{
"status": "ok"
}
Allows for programatically applying label annotations via the API. A comment's
uid
uniquely identifies it within a source. For each
comment being annotated, at least one of external_id
and name
should be
provided:
- Where only a
name
is provided, a label annotation with that name will be applied to the comment. - Where only an
external_id
is provided, the label to annotate will be looked up within the existing taxonomy. If no label already exists with the sameexternal_id
an error response will be returned. - Where both an
external_id
andname
are provided, the label to annotate will be looked up within the existing taxonomy. If there is no existing label with the sameexternal_id
andname
an error will be returned.
name | type | required | description |
---|---|---|---|
comment_uid | string | yes | The uid of the comment that should be annotated. |
external_id | string | no | The external_id of the existing label definition to annotate. |
name | string | no | The name of the label to annotate. |
Note that a comment cannot contain duplicated labels.