Export text annotations

How to export text annotations and sample export formats.

Export annotations as Python Annotation Types

Open this Colab for an interactive tutorial on exporting annotations made on text assets.

Export JSON annotations

# Set the export params to include/exclude certain fields. Make sure each of these fields are correctly grabbed 
export_params= {
  "attachments": True,
  "metadata_fields": True,
  "data_row_details": True,
  "project_details": True,
  "label_details": True,
  "performance_details": True
}

# You can set the range for last_activity_at and label_created_at. 
# For context, last_activity_at captures the creation and modification of labels, metadata, status, comments and reviews.
# Note: This is an AND logic between the filters, so usually using one filter is sufficient.

filters= {
  "last_activity_at": ["2000-01-01 00:00:00", "2050-01-01 00:00:00"],
}

export_task = project.export_v2(params=export_params, filters=filters)
export_task.wait_till_done()

if export_task.errors:
  print(export_task.errors)

export_json = export_task.result
print("results: ", export_json)
labels = project.export_labels(download=True)

# Optionally, provide a date range as an optional parameter
# This will export only labels created between the supplied dates
# Date range can be formatted as "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss"
labels = project.export_labels(download=True, start="2022-09-28", end="2022-10-04")

Annotation export formats

Text entity (named entity)

{
  "feature_id": "cldne96y201wn13yddm9l2v3j",
  "name": "named_entity",
  "annotation_kind": "TextEntity",
  "classifications": [],
  "location": {
    "start": 67,
    "end": 128
  }
}
{
  "featureId": "ck8kulppv000x0yf8pqpqqin4",
  "schemaId": "ck8kukafkqx1a0880iczbrqym",
  "title": "Entity type A",
  "value": "entity_type_a",
  "color": "#8000FF",
  "version": 1,
  "format": "text.location",
  "data": {
    "location": {
      "start": 67,
      "end": 128
    }
  }
}

Relationship

"relationships": [
  {
    "feature_id": "cle3a9op500013b6j0rxusjiq",
    "name": "relation_1",
    "annotation_kind": "TextUnidirectionalRelationship",
    "classifications": [],
    "unidirectional_relationship": {
      "source": "cldne96y201wn13yddm9l2v3j",
      "target": "cldouibfq00023b6j51ml2xll"
    }
  }
]
"relationships": [
  {
    "featureId":"cl12o1opb000g3g6acccvuqui",
    "schemaId":"cl12nq1ik004g0z4lf84q58rm",
    "data":
    {
      "source":"cl12nurbd00013g6an63jifsv",
      "target":"cl12nv4ab00073g6as6jkwcj3",
      "label": "verb"
    },
    "relationshipType":"unidirectional",
    "version": 1
  }
]

Radio

{
  "feature_id": "cldne96y201wq13ydu0qcc2up",
  "name": "radio_question_sub",
  "radio_answer": {
    "feature_id": "cldne96y201wr13yd23kr1pcr",
    "name": "first_radio_answer",
    "classifications": [
      {
        "feature_id": "cldne96y201ws13ydycgddbx1",
        "name": "sub_radio_question",
        "radio_answer": {
          "feature_id": "cldne96y201wt13ydowa2bs2i",
          "name": "first_sub_radio_answer",
          "classifications": []
        }
      }
    ]
  }
}
{
  "featureId": "cknp3d0hw00013g68wkjemi6o",
  "schemaId": "cknp3ctst06nq0ycte8icc2l3",
  "title": "Is it daytime?",
  "value": "is_it_daytime?",
  "answer": {
    "featureId": "cknp3d0hw00003g685c0nj5c1",
    "schemaId": "cknp3cttx06oe0yct3f0d6pmz",
    "title": "Yes",
    "value": "yes"
  }
}

Checklist

{
  "feature_id": "cldne96y201wu13ydohrclpra",
  "name": "checklist_question",
  "checklist_answers": [
    {
      "feature_id": "cldne96y301wv13ydatuxugbt",
      "name": "first_checklist_answer",
      "classifications": []
    },
    {
      "feature_id": "cldne96y301ww13yds4zkk49u",
      "name": "second_checklist_answer",
      "classifications": []
    },
    {
      "feature_id": "cldne96y301wx13ydvb5x2w6o",
      "name": "third_checklist_answer",
      "classifications": []
    }
  ]
}
{
  "featureId": "cl89b1d3g00013b6k8388lpol",
  "schemaId": "cl89b186w0xg107xkga0fdf4j",
  "scope": "global",
  "title": "Attributes",
  "value": "attributes",
  "answers": [
    {
      "featureId": "cl89b1dln00033b6ky6j9cb62",
      "schemaId": "cl89b186w0xg407xk4yvkf3o8",
      "title": "Crowded",
      "value": "crowded"
    },
    {
      "featureId": "cl89b1e3z00063b6kll28e559",
      "schemaId": "cl89b186w0xg607xk8ogy304a",
      "title": "Foot traffic",
      "value": "foot_traffic"
    },
    {
      "featureId": "cl89b1ekd000a3b6kbiipqxi7",
      "schemaId": "cl89b186w0xg807xke5kg606w",
      "title": "Vehicle traffic",
      "value": "vehicle_traffic"
    }
  ]
}

Free-form text

{
  "feature_id": "cldne96y301wy13yd0wp5z87y",
  "name": "free_text",
  "text_answer": {
    "content": "sample text"
  }
}
{
    "featureId": "cknp3dugp00073g68fkudn092",
    "schemaId": "cknp3ctsu06nu0yctf0v5gzij",
    "title": "Free-form text",
    "value": "free-form_text",
    "answer": "Correct text answer"
}

Sample project export

[
    {
        "ID": "cknp3dwk4000b3g68ghqpti7y",
        "DataRow ID": "ckekrwg3zqjbo0bs3hl15ex1i",
        "Labeled Data": "https://storage.googleapis.com/labelbox-sample-datasets/nlp/lorem-ipsum.txt",
        "Label": {
            "objects": [
                {
                    "featureId": "cknp3dvhg000a3g68hujtu6l1",
                    "schemaId": "ckkd4yl0e0le30ycl7i4944l5",
                    "title": "A",
                    "value": "a",
                    "color": "#1CE6FF",
                    "version": 1,
                    "format": "text.location",
                    "data": {
                        "location": {
                            "start": 6,
                            "end": 145
                        }
                    },
                    "instanceURI": "https://api.labelbox.com/masks/feature/cknp3dvhg000a3g68hujtu6l1?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjazUycnZ4MWtxYXpiMDc3MDBtcTI3eDRsIiwib3JnYW5pemF0aW9uSWQiOiJjazUycnZ4MG1wdzRnMDc2NndncXZqdGw5IiwiaWF0IjoxNjE4ODY2NjI4LCJleHAiOjE2MjE0NTg2Mjh9.tW78CH7C7Nb85w6epSULEpaY4sEg6UeWeSk0WmCP5jg"
                }
            ],
            "classifications": [
                {
                    "featureId": "cknp3d0hw00013g68wkjemi6o",
                    "schemaId": "cknp3ctst06nq0ycte8icc2l3",
                    "title": "Radio",
                    "value": "radio",
                    "answer": {
                        "featureId": "cknp3d0hw00003g685c0nj5c1",
                        "schemaId": "cknp3cttx06oe0yct3f0d6pmz",
                        "title": "Yes",
                        "value": "yes"
                    }
                },
                {
                    "featureId": "cknp3dk5r00013g68lyduuwvp",
                    "schemaId": "cknp3dfo51h900y9y5j10g7hg",
                    "title": "Checklist",
                    "value": "checklist",
                    "answers": [
                        {
                            "featureId": "cknp3dk5r00003g6864se47ef",
                            "schemaId": "cknp3dfv21h9a0y9yagz41wtq",
                            "title": "1",
                            "value": "1"
                        },
                        {
                            "featureId": "cknp3dko500033g685s10zw9u",
                            "schemaId": "cknp3dfv21h9b0y9yg34i8xru",
                            "title": "2",
                            "value": "2"
                        }
                    ]
                }
            ]
        },
        "Created By": "[email protected]",
        "Project Name": "NER",
        "Created At": "2021-04-19T21:10:17.000Z",
        "Updated At": "2021-04-19T21:10:18.000Z",
        "Seconds to Label": 28.293,
        "External ID": null,
        "Agreement": -1,
        "Benchmark Agreement": -1,
        "Benchmark ID": null,
        "Dataset Name": "Lorem ipsum.txt",
        "Reviews": [],
        "View Label": "https://editor.labelbox.com?project=ckkd4xstjqnsb0740zwio6grd&label=cknp3dwk4000b3g68ghqpti7y",
        "Has Open Issues": 0,
        "Skipped": false,
        "DataRow Workflow Info": {
            "taskName": "Done",
            "Workflow History": [
              {
                "actorId": "cl3lobugu14pw0796fau0dgad",
                "action": "APPROVE",
                "createdAt": "2022-09-29T15:46:23.269Z",
                "previousTaskId": "0ae49522-97f0-4a07-96c6-bd4d50963acd",
                "previousTaskName": "Initial review task"
              },
              {
                "actorId": "cl3lobugu14pw0796fau0dgad",
                "action": "REWORK",
                "createdAt": "2022-09-29T14:23:59.735Z",
                "previousTaskId": "4a0d7f40-0c3f-0cc8-adc4-fd818684facd",
                "previousTaskName": "Rework (all rejected)",
                "nextTaskId": "0ae49522-97f0-4a07-96c6-bd4d50963acd",
                "nextTaskName": "Initial review task"
              },
              {
                "actorId": "cl1qe5naj3g460z6e0owr6mwj",
                "action": "REJECT",
                "createdAt": "2022-09-29T13:39:01.077Z",
                "previousTaskId": "0ae49522-97f0-4a07-96c6-bd4d50963acd",
                "previousTaskName": "Initial review task",
                "nextTaskId": "4a0d7f40-0c3f-0cc8-adc4-fd818684facd",
                "nextTaskName": "Rework (all rejected)"
              },
              {
                "actorId": "cl3ucfsj22j8l073xaitnh1xe",
                "action": "MOVE",
                "createdAt": "2022-09-28T18:06:16.881Z",
                "previousTaskId": "ea78e526-e429-002e-8b80-b72c4b591152",
                "previousTaskName": "Initial labeling task",
                "nextTaskId": "0ae49522-97f0-4a07-96c6-bd4d50963acd",
                "nextTaskName": "Initial review task"
              },
              {
                "actorId": "cl3ucfsj22j8l073xaitnh1xe",
                "action": "MOVE",
                "createdAt": "2022-09-28T18:06:16.859Z",
                "nextTaskId": "ea78e526-e429-002e-8b80-b72c4b591152",
                "nextTaskName": "Initial labeling task"
              }
            ]
        }
    }
]
{
    "data_row": {
        "id": "cldne8tks082r07zegir55f7i",
        "global_key": "TEST-ID-179346588229173382106824381481493642554d",
        "row_data": "https://storage.googleapis.com/labelbox-sample-datasets/nlp/lorem-ipsum.txt",
        "details": {
            "dataset_id": "cldne8t6l036q073d9ggm8f7a",
            "created_at": "2023-02-02",
            "updated_at": "2023-02-02",
            "created_by": "[email protected]"
        }
    },
    "media_attributes": {
        "mime_type": "text/plain"
    },
    "attachments": [
        {
            "type": "TEXT_URL",
            "value": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/text_attachment.txt",
            "name": "null",
            "id": "cldne8tl3082v07zebx5lgt36"
        }
    ],
    "metadata_fields": [],
    "projects": {
        "cldne8u7l043y071939q35sox": {
            "project_name": "text_project_demo",
            "labels": [
                {
                    "label_kind": "Default",
                    "version": "1.0.0",
                    "id": "cldne96yo01wz13ydga0hokmj",
                    "label_details": {
                        "created_at": "2023-02-02T17:51:22+00:00",
                        "updated_at": "2023-02-13T20:55:06+00:00",
                        "created_by": "[email protected]",
                        "reviews": []
                    },
                    "performance_details": {
                        "seconds_to_create": 338,
                        "seconds_to_review": 0,
                        "skipped": false
                    },
                    "annotations": {
                        "objects": [
                            {
                                "feature_id": "cldne96y201wn13yddm9l2v3j",
                                "name": "named_entity",
                                "annotation_kind": "TextEntity",
                                "classifications": [],
                                "location": {
                                    "start": 67,
                                    "end": 128
                                }
                            },
                            {
                                "feature_id": "cldouibfq00023b6j51ml2xll",
                                "name": "named_entity",
                                "annotation_kind": "TextEntity",
                                "classifications": [],
                                "location": {
                                    "start": 290,
                                    "end": 305
                                }
                            }
                        ],
                        "classifications": [
                            {
                                "feature_id": "cldne96y201wo13ydv348qx2z",
                                "name": "radio_question",
                                "radio_answer": {
                                    "feature_id": "cldne96y201wp13ydbhfzbpue",
                                    "name": "first_radio_answer",
                                    "classifications": []
                                }
                            },
                            {
                                "feature_id": "cldne96y201wq13ydu0qcc2up",
                                "name": "radio_question_sub",
                                "radio_answer": {
                                    "feature_id": "cldne96y201wr13yd23kr1pcr",
                                    "name": "first_radio_answer",
                                    "classifications": [
                                        {
                                            "feature_id": "cldne96y201ws13ydycgddbx1",
                                            "name": "sub_radio_question",
                                            "radio_answer": {
                                                "feature_id": "cldne96y201wt13ydowa2bs2i",
                                                "name": "first_sub_radio_answer",
                                                "classifications": []
                                            }
                                        }
                                    ]
                                }
                            },
                            {
                                "feature_id": "cldne96y201wu13ydohrclpra",
                                "name": "checklist_question",
                                "checklist_answers": [
                                    {
                                        "feature_id": "cldne96y301wv13ydatuxugbt",
                                        "name": "first_checklist_answer",
                                        "classifications": []
                                    },
                                    {
                                        "feature_id": "cldne96y301ww13yds4zkk49u",
                                        "name": "second_checklist_answer",
                                        "classifications": []
                                    },
                                    {
                                        "feature_id": "cldne96y301wx13ydvb5x2w6o",
                                        "name": "third_checklist_answer",
                                        "classifications": []
                                    }
                                ]
                            },
                            {
                                "feature_id": "cldne96y301wy13yd0wp5z87y",
                                "name": "free_text",
                                "text_answer": {
                                    "content": "sample text"
                                }
                            }
                        ],
                        "relationships": [
                            {
                                "feature_id": "cle3a9op500013b6j0rxusjiq",
                                "name": "relation_1",
                                "annotation_kind": "TextUnidirectionalRelationship",
                                "classifications": [],
                                "unidirectional_relationship": {
                                    "source": "cldne96y201wn13yddm9l2v3j",
                                    "target": "cldouibfq00023b6j51ml2xll"
                                }
                            }
                        ]
                    }
                }
            ],
            "project_details": {
                "ontology_id": "cldne8twy04ch07287l54b0u4",
                "batch_id": "2d20e720-a322-11ed-aba1-1d7e91cf15e9",
                "priority": 5,
                "consensus_expected_label_count": 1,
                "workflow_history": []
            }
        }
    }
}

Sample model run export

{
  "data_row": {
    "id": "clduj5b8103z407uqhlalhu25",
    "global_key": "84a24fab-bf79-449d-831d-b3b3002affe9",
    "row_data": "https://storage.googleapis.com/labelbox-sample-datasets/nlp/lorem-ipsum.txt",
    "details": {
      "dataset_id": "clduj5ary09eh07zsf3btbgk9",
      "created_at": "2023-02-07",
      "updated_at": "2023-02-07",
      "created_by": "[email protected]"
    }
  },
  "media_attributes": {
    "mime_type": "text/plain"
  },
  "attachments": [],
  "metadata_fields": [],
  "experiments": {
    "a089fc39-5fb0-0107-5948-d9963f668d76": {
      "name": "text_model_run_4dfb57ac-54a4-40da-89ff-b4930f388953",
      "runs": {
        "a089fc39-d06d-00c1-ee95-e49521276427": {
          "name": "iteration 1",
          "run_data_row_id": "f86738d9-3438-4b71-9625-232ff2b0009c",
          "labels": [
            {
              "label_kind": "Default",
              "version": "1.0.0",
              "id": "cldujpk1702p113ydw8vi6qra",
              "annotations": {
                "objects": [
                  {
                    "feature_id": "79cf45ed-d0ad-4a41-a107-686de471dc6b",
                    "name": "named_entity",
                    "annotation_kind": "TextEntity",
                    "classifications": [],
                    "location": {
                      "start": 67,
                      "end": 128
                    }
                  }
                ],
                "classifications": [
                  {
                    "feature_id": "5c3d1d41-d69c-49ff-b6a7-5b8a50c45569",
                    "name": "radio_question",
                    "radio_answer": {
                      "feature_id": "92ffa583-8ab8-408e-8e2d-2e600a522525",
                      "name": "first_radio_answer",
                      "classifications": []
                    }
                  },
                  {
                    "feature_id": "80ed4712-7ef7-454e-972c-b4db5dd62a0b",
                    "name": "nested_checklist_question",
                    "checklist_answers": [
                      {
                        "feature_id": "41a8857a-597f-490c-977e-9e2e84c184df",
                        "name": "first_checklist_answer",
                        "classifications": [
                          {
                            "feature_id": "2d91f11c-fdaf-40c6-893a-f1ae73d1154d",
                            "name": "sub_checklist_question",
                            "checklist_answers": [
                              {
                                "feature_id": "a0bfd338-6957-41bc-a00d-4464673aa732",
                                "name": "first_sub_checklist_answer",
                                "classifications": []
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "feature_id": "8d604648-cfe5-4ac9-bebc-01bf439661f4",
                    "name": "free_text",
                    "text_answer": {
                      "content": "sample text"
                    }
                  },
                  {
                    "feature_id": "b2ae102b-783f-4511-a5f5-61aae62ad312",
                    "name": "radio_question_sub",
                    "radio_answer": {
                      "feature_id": "18a702ed-6b88-42b8-9753-50caf990dc04",
                      "name": "first_radio_answer",
                      "classifications": [
                        {
                          "feature_id": "4d3757b0-55b4-41ee-87c9-c7fc9b4c5342",
                          "name": "sub_radio_question",
                          "radio_answer": {
                            "feature_id": "380ded50-a14c-41f5-9c78-b2ed821c6163",
                            "name": "first_sub_radio_answer",
                            "classifications": []
                          }
                        }
                      ]
                    }
                  },
                  {
                    "feature_id": "ef6137ab-2c78-482c-8f59-b068ab826328",
                    "name": "checklist_question",
                    "checklist_answers": [
                      {
                        "feature_id": "160978a2-0caf-4bb2-ae74-6596cc2bcd5e",
                        "name": "third_checklist_answer",
                        "classifications": []
                      },
                      {
                        "feature_id": "a58e3c54-26e9-4980-bd6b-8d65034bdcf7",
                        "name": "first_checklist_answer",
                        "classifications": []
                      },
                      {
                        "feature_id": "f9b4e4b8-b8e3-468c-a404-1443d74a8b69",
                        "name": "second_checklist_answer",
                        "classifications": []
                      }
                    ]
                  }
                ],
                "relationships": []
              }
            }
          ],
          "predictions": [
            {
              "label_kind": "Default",
              "version": "1.0.0",
              "id": "cldujpk1702p113ydw8vi6qra",
              "annotations": {
                "objects": [
                  {
                    "feature_id": "105b3415-7472-4427-b464-8e9fcebffee2",
                    "name": "named_entity",
                    "annotation_kind": "TextEntity",
                    "classifications": [],
                    "location": {
                      "start": 67,
                      "end": 128
                    }
                  }
                ],
                "classifications": [
                  {
                    "feature_id": "1b24162f-3b30-44db-958c-e26e7a28b961",
                    "name": "free_text",
                    "text_answer": {
                      "content": "sample text"
                    }
                  },
                  {
                    "feature_id": "67e47a11-2f21-41fe-b76a-f96cca85e514",
                    "name": "checklist_question",
                    "checklist_answers": [
                      {
                        "feature_id": "f88fbf38-5e9e-49f2-b9c1-19ea610c9fcf",
                        "name": "first_checklist_answer",
                        "classifications": []
                      }
                    ]
                  },
                  {
                    "feature_id": "7484bbde-7def-484b-8fcd-972bd3a2fc49",
                    "name": "radio_question_sub",
                    "radio_answer": {
                      "feature_id": "f4e4e5c2-f8c8-4e16-8f03-4735544ef0d1",
                      "name": "first_radio_answer",
                      "classifications": [
                        {
                          "feature_id": "f24fc2c3-9d94-49c2-b243-7f5a59fd72f0",
                          "name": "sub_radio_question",
                          "radio_answer": {
                            "feature_id": "3867c1f0-55ec-4f06-a283-b67f178248a0",
                            "name": "first_sub_radio_answer",
                            "classifications": []
                          }
                        }
                      ]
                    }
                  },
                  {
                    "feature_id": "74f40a27-64fb-4e71-a7fa-343784f3062c",
                    "name": "nested_checklist_question",
                    "checklist_answers": [
                      {
                        "feature_id": "2cd6b11f-6609-4610-8874-c977976dbbab",
                        "name": "first_checklist_answer",
                        "classifications": [
                          {
                            "feature_id": "c153c44a-609b-4559-826f-996195795a00",
                            "name": "sub_checklist_question",
                            "checklist_answers": [
                              {
                                "feature_id": "8286636e-7516-4681-ad2b-d414f88e0507",
                                "name": "first_sub_checklist_answer",
                                "classifications": []
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "feature_id": "d8b70c5c-622c-4abf-9c85-48639240261a",
                    "name": "radio_question",
                    "radio_answer": {
                      "feature_id": "9d5dd8a1-4d4e-436a-93ab-fe8a1bd31abc",
                      "name": "first_radio_answer",
                      "classifications": []
                    }
                  }
                ],
                "relationships": []
              }
            }
          ]
        }
      }
    }
  }
}