Get List of Label Sets in a Project
In addition to adding label sets to a project, you may also want to update them. To do this, you’ll first need to get the label set ID for the project.
Use the following GraphQL queries for this:
cURL
Use the following cURL command to get the cabinet ID, which is required before you can fetch label sets. Copy and paste it, then replace the following:
access_tokenwith your own API access token.project-idwith the ID of your project.rolewith the cabinet role you want to query.Set to REVIEWER to check the reviewer cabinet.
Set to LABELER if you need the labeler cabinet.
curl --location --request POST 'https://datasaur.ai/graphql' \
  --header 'Authorization: Bearer access_token' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "query": "query GetCabinet($projectId: ID!, $role: Role!) { getCabinet(projectId: $projectId, role: $role) { id } }",
    "variables": {
      "projectId": "project-id",
      "role": "REVIEWER"
    }
  }'Once you have the cabinet ID, use the command below to fetch all label sets added to that cabinet. Copy and paste it, then replace the following:
access_tokenwith your own API access token.The content of the label set items according to your needs.
cabinet-idwith the cabinet ID you previously retrieved.
curl --location --request POST '<https://datasaur.ai/graphql>' \\
  --header 'Authorization: Bearer access_token' \\
  --header 'Content-Type: application/json' \\
  --data-raw '{ "operationName": "GetCabinetLabelSetsById", "query": "query getCabinetLabelSetsById($cabinetId: ID!) { getCabinetLabelSetsById(cabinetId: $cabinetId) { id name tagItems { id parentId tagName color } } }", "variables": { "cabinetId": "cabinet-id" }}'For clarity, here’s a formatted version of the request body:
{
    "operationName": "GetCabinetLabelSetsById",
    "query": "query getCabinetLabelSetsById($cabinetId: ID!) { getCabinetLabelSetsById(cabinetId: $cabinetId) { id name tagItems { id parentId tagName color } } }",
    "variables": {
        "cabinetId": "cabinet-id"
    }
}operationName: you can fill any alphanumeric string in as the operationName. Refer this page for best practices on choosing an
operationName.variables:
fileId: string, reviewer's document ID of the project.
query: Copy this from the example above.
Response
Here is the response you can expect after issuing the cURL command. Use the id to create the project.
{
    "data": {
        "document": {
            "id": "c541e403-776a-40b7-af4b-955c7be86c0d",
            "settings": {
                "labelSets": [
                    {
                        "id": "4585972",
                        "index": 0,
                        "name": "POS",
                        "tagItems": [
                            { "id": "PhvHFKDx0m1lA4bl46NhH", "color": null, "parentId": null, "tagName": "NOUN" },
                            { "id": "zlFF5EBksh8vvjm36Pb7-", "color": null, "parentId": null, "tagName": "VERB" }
                        ]
                    },
                    {
                        "id": "4586371",
                        "index": 1,
                        "name": "NER",
                        "signature": "67452b1cdb893096e521dbe9d1f9eeaea3a308bcaee2b9001f2c0b6d538172aa",
                        "tagItems": [
                            { "id": "qgvxaa-svCwj18KIcoCBu", "color": "red", "parentId": null, "tagName": "PER" },
                            { "id": "qgvxbb-svCwj18KIcoCBu", "color": "green", "parentId": null, "tagName": "GEO" },
                            { "id": "qgvxMd-svCwj18KIcoCBu", "color": null, "parentId": null, "tagName": "GPE" }
                        ]
                    }
                ]
            }
        }
    },
    "extensions": {}
}Last updated