You can export a project by exporting a single file or exporting all files. You can also download a project using five different methods (direct download, email, webhook, file storage, external file storage). These methods are fully explained here. This page describes how to accomplish the above using the API.
You could try this cURL command for exporting certain file.
curl --location --request POST 'https://datasaur.ai/graphql' \--header 'Authorization: Bearer access_token' \--header 'Content-Type: application/json' \--data-raw '{"operationName":"ExportTextProjectDocumentQuery","variables":{"input":{"documentId":"f788941b-ac0a-49ff-a325-08efdaa00831","fileName":"NER-file-2_output_Jun_15_2020","format":"iob","method":"EMAIL"}},"query":"query ExportTextProjectDocumentQuery($input: ExportTextProjectDocumentInput!) { result: exportTextProjectDocument(input: $input) { redirect fileUrl queued __typename }}"}'
Below is the more readable version of request body from cURL command above.
{"operationName": "ExportTextProjectDocumentQuery","variables": {"input": {"documentId": "f788941b-ac0a-49ff-a325-08efdaa00831","fileName": "NER-file-2_output_Jun_15_2020","format": "iob","method": "EMAIL"}},"query": "query ExportTextProjectDocumentQuery($input: ExportTextProjectDocumentInput!) { result: exportTextProjectDocument(input: $input) { redirect fileUrl queued __typename }}"}
operationName: you can fill any alphanumeric string in as the operationName. ExportTextProjectDocumentQuery
is fine as a default. Refer this page to organise operationName properly.
variables
input: See Input Parameter Table below.
query: Copy it from cURL example.
Input Parameter | Description | Example |
fileName | Custom file name | NER-file-2_output_Jun_15_2020 |
format | Refer to https://datasaurai.gitbook.io/datasaur/export-project/export-formats. Use lowercase. | iob |
documentId | Document Id | f788941b-ac0a-49ff-a325-08efdaa00831 |
method | Export method: EMAIL, DOWNLOAD, CUSTOM_WEBHOOK, FILE_STORAGE, EXTERNAL_FILE_STORAGE | |
url | Webhook URL (only works for CUSTOM_WEBHOOK) | ​ |
secret | Refer to https://datasaurai.gitbook.io/datasaur/export-project/export-to-api​ | ​ |
externalFileStorageParameter | See table below | ​ |
​
externalFileStorageParameter | Description | Example |
bucketName | AWS S3 Bucket Name | my-bucket |
objectPath | directory path to store the exported file | datasaur/exported-files |
accessKeyId | AWS Access Key Id | AK2234111K4452681AXO |
secretAccessKey | AWS Secret Access Key | MADCTTTTAM23455B/svbjrzd32spfvmbZN4dI+1c2 |
Here is the response when you execute the cURL command above.
{"data": {"result": {"redirect": null,"fileUrl": null,"queued": true,"__typename": "ExportRequestRedirectResult"}},"extensions": {}}
redirect: Open the url if you choose method DOWNLOAD
queued: It shows that export process has been already queued. Please check your email or webhook to retrieve your file url.
fileUrl: It contains file url to download if you choose method FILE_STORAGE
Please wait for the file is ready.
This means that the export request is already queued and Datasaur will generate the files and send them to you based on the selected method.
curl --location --request POST 'https://datasaur.ai/graphql' \--header 'Authorization: Bearer access_token' \--header 'Content-Type: application/json' \--data-raw '{"operationName":"ExportTextProjectQuery", "variables":{"input":{"fileName":"NER-Hope-2_output_Jun_15_2020","format":"iob","projectId":"projectId","role":"LABELER","method":"EMAIL"}},"query":"query ExportTextProjectQuery ($input: ExportTextProjectInput!) { result: exportTextProject(input: $input) { redirect fileUrl queued __typename }}"}'
Below is the more readable version of request cURL command above.
{"operationName": "ExportTextProjectQuery","variables": {"input": {"fileName": "Hello_world_output_Jun_15_2020","format": "iob","projectIds": ["projectId"],"role": "LABELER","method": "EMAIL"}},"query": "query ExportTextProjectQuery ($input: ExportTextProjectInput!) { result: exportTextProject(input: $input) { redirect fileUrl queued __typename }}"}
operationName: you can fill any alphanumeric string in as the operationName. ExportTextProjectQuery
is fine as a default. Refer this page to organise operationName properly.
variables
input: See Input Parameter Table below.
query: Copy it from cURL example.
Input Parameter | Description | Example |
fileName | Custom file name | Hello_world_output_Jun_15_2020 |
format | Refer to https://datasaurai.gitbook.io/datasaur/export-project/export-formats. Use lowercase. | iob |
projectIds | Project Id List, array of Project Id | ["projectId1", "projectId2"] |
role | Exporter role. There are two possible roles: LABELER, REVIEWER | LABELER |
method | Export method: EMAIL, DOWNLOAD, CUSTOM_WEBHOOK, FILE_STORAGE, EXTERNAL_FILE_STORAGE | |
url | Webhook URL (only works for CUSTOM_WEBHOOK) | ​ |
secret | Refer to https://datasaurai.gitbook.io/datasaur/export-project/export-to-api​ | ​ |
externalFileStorageParameter | Only works for EXTERNAL_FILE_STORAGE | ​ |
​
externalFileStorageParameter | Description | Example |
bucketName | AWS S3 Bucket Name | my-bucket |
objectPath | directory path to store the exported file | datasaur/exported-files |
accessKeyId | AWS Access Key Id | AK2234111K4452681AXO |
secretAccessKey | AWS Secret Access Key | MADCTTTTAM23455B/svbjrzd32spfvmbZN4dI+1c2 |
Here is the response when you execute the cURL command above.
{"data": {"result": {"redirect": null,"fileUrl": null,"queued": true,"__typename": "ExportRequestRedirectResult"}},"extensions": {}}
redirect: Open the url if you choose method DOWNLOAD
queued: It shows that export process has been already queued. Please check your email or webhook to retrieve your file url.
fileUrl: It contains file url to download if you choose method FILE_STORAGE
Please wait for the file is ready.
This means that the export request is already queued and Datasaur will generate the files and send them to you based on the selected method.
You can refer to the GraphQL Schema section to see more about the export query.
​