Back to Label Studio

API Reference

web/libs/datamanager/docs/api_reference.md

2.2.10-115.9 KB
Original Source

API Reference

DataManager uses LabelStudio API to operate.

Request parameters should be JSON.

Responses are in JSON as well.

/project

GET

Information about current project


/project/columns

GET

Information about columns of the dataset.

Response

ParameterTypeDescription
columnsList<Column>List of columns

/project/tabs

GET

Information about tabs in current project

PropertyTypeDescription
tabsList<Tab>List of tabs

/project/tabs/:tabID

POST

Create tab or update existing one.

PropertyValueDescription
bodyJSON encoded TabData to create or update the tab
DELETE

Delete specific tab


/project/tabs/:tabID/tasks

GET

Pages set of samples from the dataset filtered by Filter.

Request parameters (set automatically by DataManager):
PropertyTypeDescription
pageIntPage to load
page_sizeIntAmount of tasks per page
interaction"scroll" | "filter" | "ordering"This value is used by LS to optimize requests to the underlying storage
Response parameters:
PropertyTypeDescription
tasksList<Task>Tasks are samples from your dataset
totalIntTotal amount of tasks
total_annotationsIntTotal amount of annotations for the tasks
total_predictionsIntTotal amount of annotations for the tasks

/tasks/:taskID

GET

Returns a specific task

PropertyTypeDescription
taskTaskSingle task entity

/project/next

GET

According to sampling settings returns next task in the dataset

PropertyTypeDescription
taskTaskSingle task entity

/project/tabs/:tabID/annotations

GET

Annotations for the current dataset

PropertyTypeDescription
annotationsList<Annotation>See Label Studio documentation to learn about annotations

/tasks/:taskID/annotations

GET

Annotations for the current dataset

PropertyTypeDescription
annotationsList<Annotation>See Label Studio documentation to learn more about annotations
POST [was_skipped=true]

If was_skipped parameter is passed, creates a annotation marked as rejected

PropertyTypeDescription
bodyJSON encoded Annotation
was_skipped1 | nullCreates new annotation with was_skipped=true flag

/tasks/:taskID/annotations/:id

GET

Get a annotation for a specific task

POST [was_skipped=true]

If was_skipped parameter is passed, marks an existing annotation as rejected

Request parameters
PropertyTypeDescription
bodyJSON encoded Annotation
was_skipped1 | nullTells the backend to mark the annotation as was_skipped
DELETE

Delete annotation

PropertyTypeDescription
idIntDeleted annotation id

/project/tabs/:tabID/selected-items

This method manages selected items list – tasks, that you marked as selected. List of selected task is stored on a tab level.

POST

Override selected items list.

Request parameters
PropertyTypeDescription
bodyJSON encoded SelectedItemsSelected items to write
PATCH

Add items to the list. This method does not override SelectedItems, instead it modifies the list.

Request parameters
PropertyTypeDescription
bodyJSON encoded SelectedItemsSelected items to write
DELETE

Remove items from the list.

Request parameters
PropertyTypeDescription
bodyJSON encoded SelectedItemsSelected items to write

/project/actions

GET

Returns a list of available actions. Actions can be applied to

  • single task
  • selected tasks
  • whole tab
PropertyTypeDescription
idStringString-based code of the action
titleStringHuman readable label of the action
orderIntActs as a weight for the task and affects the order of buttons in Data Manager
dialogDist<String, String> | nullConfirmation dialog. It will be shown on button press before executing the action
dialog.textStringDialog text
dialog.typeStringDialog type

/project/tabs/:tabID/actions

POST

Invokes a given action.

Doesn't require any parameters.

Type Reference

Tab

Tab represents a materialized view that can slice and order the data

PropertyTypeDescription
idIntTab identifier
type"list" | "grid"Display type
titleStringHuman readable title
target"tasks" | "annotations"Currently shown entity type
filtersFilterFilter applied to the tab
orderingList<ColumnAlias | -ColumnAlias>Ordering applied to the tab
selectedItemsSelectedItemsList of checked samples
columnsDisplayTypeDict<ColumnAlias, ColumnType>List of display types override for data values
columnsWidthDict<ColumnAlias, int>Width of each individual column
hiddenColumnsDict<"explore" | "labeling", List<ColumnAlias>>List of hidden tabs per view

Filter

Filter specifies what data will be shown in the tab

PropertyTypeDescription
conjunction"and" | "or"How filter items are combined for the comparison
itemsList<FilterItem>Single filter

FilterItem

PropertyTypeDescription
filter"filter:ColumnAlias"Path to the property
typeColumnTypeType of the column
operatorFilterOperatorOperator of the comparison
valueStringValue to compare

FilterOperator

OperatorInputDescription
equalString | NumberDirect equality comparison
not_equalString | NumberDirect inequality comparison
containsString | NumberCheck wther string contains a substring
not_containsString | NumberCheck wther string does not contain a substring
lessNumberValue is less than an input
greaterNumberValue is greater than an input
less_or_equalNumberValue is less or equal to input
greater_or_equalNumberValue is greater or equal to input
inList<String | Number>Value is in a list
not_inList<String | Number>Value is not in a list
emptyBooleanValue is empty

Column

Column represents a single field of the dataset samle:

PropertyTypeDescription
column.idStringColumn identifier
column.parentString | nullParent identifier
column.target"tasks" | "annotations"Entity the column is attached to
column.titleStringHuman readable title
column.typeColumnTypeColumn value type
column.childrenList<String> | nullColumn identifier
column.visibility_defaultsDict<"explore"|"labeling", Boolean>Column identifier

ColumnType

Represents a type of a column value. Column can have one of the tipes listed below.

TypeDescription
StringPrimitive string
BooleanPrimitive boolean
NumberInt or Double
DatetimeDate and time in ISO format
List<T>List of items. T can be one of the types listed in this table
ImageImage url
AudioAudio url
TextText string
HyperTextHTML or XML based markup
TimeSeriesTimeSeries data
UnknownType cannot be determined by the backend

ColumnAlias

ColumnAlias is an aggregated field that combines full path to the column. ColumnAlias is built using the following rules:

  • [target]:[column_name]
  • [target]:[full_path].[column_name]

Full path is a path that combines all parent columns. E.g. you have a data column that contains several values:

json
{
  "data": {
    "image": "https://example.com/image.jpg"
  }
}

In this case columns will look like this:

json
{
  "columns": [
    {
      "id": "data",
      "title": "Data",
      "children": ["image"],
      "target": "tasks",
    },
    {
      "id": "image",
      "title": "image",
      "parent": "data",
      "target": "tasks",
    }
  ]
}

As the columns list is flat, full path will reference all ascending columns: tasks:data.image

In some cases ColumnAlias might be negative. For example negative values are used for ordering: -tasks:data.image

SelectedItems

PropertyTypeDefaultDescription
allBooleanfalseWhen true, all items in the dataset implied as selected
includedList<Int>[]When all=false this list specifies selected items
excludedList<Int>[]When all=true this list specifies the items to exclude from selection

Selected items is an object that stores samples checked in the UI. To operate effectively on large amounts of data it uses partial selection approach. The structure of this object is the following:

json
// In this case we select only items with IDs 1, 2 and 3
{
  "selectedItems": {
    "all": false,
    "included": [1, 2, 3]
  }
}

// SelectedItems can select all the items in the dataset regardless of the size
{
  "selectedItems": {
    "all": true,
  }
}

// With `excluded` list you can select all but `excluded`
// In this example we select all items except 1, 2 and 3
{
  "selectedItems": {
    "all": true,
    "excluded": [1, 2, 3]
  }
}

Task

Task is a single sample from the dataset.

PropertyTypeDescription
idIntTask identifier generated by LS
cancelled_annotationsIntNumber of cancelled (rejected) annotations for the task
completed_atDateTimeCreation date of the last annotation
predictions_resultString
total_annotationsIntTotal annotations for the task
total_predictionsIntTotal predictions fo the task
dataDict<String, Any>Data from the dataset
extraDict<String, Any>Any extra data for the task