Table of Contents

Data Rows

Alex Cota Updated by Alex Cota

A data row is the internal Labelbox representation of an asset.

Below are some common operations the GraphQL API supports for data rows.

Create data rows

There are two ways to create data rows, individually and in bulk.

Individual import

Individual import is ideal for manipulating existing databases, whether you are adding specific data you missed or connecting a live feed of information to the database. Use the createDataRow mutation and pass the URL to your unlabeled asset.

  1. Create an empty dataset.
  2. Query the ID of the dataset you just created.
query GetDataset { 
datasets(where: {name: "<DATASET_NAME>"}){
id
}
}
  1. Attach the asset to the dataset.
mutation CreateDataRow { 
createDataRow(
data: {
externalId: "<OPTIONAL_USER_GENERATED_FILENAME>",
rowData: "<URL_TO_UNLABELED_ASSET>",
dataset: {
connect: {
id: "<DATASET_ID>"
} }, } ){ id }}
Bulk import

Bulk import is optimized for uploading large quantities of data by reading the new data information out of a JSON file. You must host your JSON file in a cloud server and pass the URL. Before you import, make sure your JSON file is properly formatted. If you have the file locally on your computer, our walkthrough shows how to make a one-off cloud URL to easily integrate this into your workflow.

  1. Create an empty dataset.
  2. Get the ID for the dataset you just created.
query { 
datasets(where: {name: "<DATASET_NAME>"}){
id
}
}
  1. Use appendRowsToDataset to create data rows for the assets specified in JSON file and attach the data rows to the dataset. When a dataset is attached to a project, the assets in that dataset enter the labeling queue for that project.
mutation AppendRowsToDataset { 
appendRowsToDataset(
data:{
datasetId:"<DATASET_ID>",
jsonFileUrl:"<URL_TO_JSON_FILE>"
}
){
accepted
}
}

Get data rows

Get all data rows in a project

Use first to return the first 100 results.

query GetDataRowsByProject { 
project (where: {id: "<PROJECT_ID>"}) {
datasets {
dataRows (first: 100){
id
rowData
externalId
}
}
}
}
Get all data rows in a dataset

Query Variables: {"dataset_id": "<DATASET ID HERE>"}

query GetDataRows($dataset_id: ID!) { 
datasets(where: {id_contains: $dataset_id}) {
name
id
dataRows {
id
externalId
}
}
}

Update data rows

Use this query to update the externalId on a data row.

mutation UpdateDataRow { 
updateDataRow(
where:{id: "<DATAROW_ID>"}
data:{externalId: "<NEW_FILENAME>"}
){
id
}

Use this query to update the rowData (asset URL) on a data row.

mutation { 
updateDataRow (
where:{id: "<DATAROW_ID>"}
data: {rowData: "<NEW_ASSET_URL>"}
) {
id
}
}

Delete data rows

The deleteDataRows mutation can take a list of up to 10,000 data rows.

Cascading Delete. If you delete a data row it will also delete the attached labels. Once deleted there isn’t an API method to undelete a data row.
mutation DeleteDataRows { 
deleteDataRows(where:{
dataRowIds:["<DATA_ROW_ID>"]
}){
id
deleted
}
}

Was this page helpful?

Datasets

Labels

Contact