Table of Contents

Labels

Alex Cota Updated by Alex Cota

A Label is a collection of features on a single asset and represents an assessment on a Data Row.

Below are some common operations the GraphQL API supports for Labels.

Get JSON label by ID

To get the stringified JSON value for a Label by the Label ID, use this query:

query getLabelById{ 
label(where: {id: "<LABEL_ID>"}) {
# Info requested
}
}

Get JSON label by project

Use first to return a paginated result. You can also filter labels by review, creator, etc.

Query Variables: {"project_id": "<PROJECT_ID_HERE>"}

query getLabelsFromProject($project_id: ID!) {
projects(where: {id: $project_id}) {
id
name
labels(first: 10, skip: 0) {
id
createdBy {
email
}
label
}
}
}

Where:

  • first indicates how many elements from a page to retrieve
  • skip indicates how many labels from the project to skip

Export labels

There are two ways for exporting data, bulk export and individual export.

Bulk export

Bulk export is useful if you need to export many labels quickly.

downloadUrl

URL to the JSON file containing labels for the project.

createdAt

Timestamp indicating when the export was generated.

shouldPoll

If true, the export is in the process of being generated and your script should make the same request on an interval until completion.

30min Frequency The exportLabels mutation will only generate a new downloadUrl at a max frequency of 30min. If you called exportLabels twice within 30 min the second call will return the same downloadUrl and createdAt timestamp.
mutation{ 
exportLabels(data:{
projectId:"<PROJECT_ID>"
}){
downloadUrl
createdAt
shouldPoll
}
}
Individual export

Individual export is useful for real-time use cases or exporting a subset of the data.

  1. [Get the project ID].
  2. Query the labels. The example below retrieves the first 100 labels from the project but skips the first 5 labels.
query APIGetPageOfLabels { 
project(where:{id: "<PROJECT_ID>"}) {
labels(first: 100, skip: 5){
id
label
createdBy {
id
email
}
type {
id
name
}
secondsToLabel
agreement
dataRow {
id
rowData
}
}
}
}

Where:

  • first indicates how many elements from a page to retrieve
  • skip indicates how many labels from the project to skip

Delete labels

When you delete a label, the asset is automatically re-enqueued, meaning it is re-entered into the labeling queue. Please see our docs on relabeling data to read about re-enqueuing labels.

mutation{ 
deleteLabels(
labelIds:["<LABEL_ID>"]
){
id
deleted
}
}

Delete labels but keep as templates

You can use the bulkDeleteLabels mutation and the makeTemplates parameter to bulk delete labels from a project, but to keep them as label templates.

When you delete a label but keep it as a template, the labeling time and any other metrics are not carried over, only the label itself.
mutation BulkDeleteLabels($projectId: ID!, $makeTemplates: Boolean = true, $labelsWhere: WhereBulkLabelDelete, $first: PageSize, $skip: Int) {
project(where: {id: $projectId}) {
bulkDeleteLabels(where: $labelsWhere, makeTemplates: $makeTemplates, waitForQueue: true, first: $first, skip: $skip) {
count
}
}
}

Where:

  • makeTemplates must be set to True to create templates

Was this page helpful?

Labeling parameters

Members

Contact