Attention: : Confluence is not suitable for the storage of highly confidential data. Please ensure that any data classified as Highly Protected is stored using a more secure platform.
If you have any questions, please refer to the University's data classification guide or contact ict.askcyber@sydney.edu.au

1 Basic Operations

RESTAPI Basic Operation Manual

List projects (will return only the projects the user has access to)

curl -u username "https://xnat.sydney.edu.au/data/archive/projects"

^data is returned in JSON format by default. Modify format using the format parameter with html, xml, json, csv.

^username is the XNAT logon username, password will be prompt.

List projects (in XML format and save to a file)

curl -u username "https://xnat.sydney.edu.au/data/archive/projects/?format=xml" -o projects.xml

List files for an experiment (in XML format and save to a file)

curl -u username "https://xnat.sydney.edu.au/data/projects/[insert project name here]/subjects/[insert subject name here]/experiments/[insert session name here]/scans/[insert scan ID here]/files?format=xml" -o filelist.xml

Download all DICOM files for a scan (in zip format)

curl -u username "https://xnat.sydney.edu.au/data/projects/[insert project name here]/subjects/[insert subject name here]/experiments/[insert session name here]/scans/[insert scan id here]/files?format=zip" -o dicomfiles.zip


For example, below command downloads to dicomfiles.zip that contains all files for existing scan "3980" of existing session "29", that is for existing subject "MH_Brain" of existing project "fang1".

curl -u xufang "https://dev.xnat.sydney.edu.au/data/projects/fang1/subjects/MH_Brain/experiments/29/scans/3980/files?format=zip" -o dicomfiles.zip

Download all files in a session to zip files

curl -u username -X GET "https://xnat.sydney.edu.au/data/projects/[project name]/subjects/[subject name]/experiments/[session name]/scans/ALL/files?format=zip" -o file.zip

Upload all files into the scan

curl -u username -X PUT "https://xnat.sydney.edu.au/data/projects/[insert project name here]/subjects/[insert subject name here]/experiments/[insert session name here]/scans/[insert scan id here]/resources/[insert a custom folder name here]/files?extract=true" -F “file=@compresses-file.zip


For example, below command will decompress test.zip and save all DICOM files into "TEST" folder under existing scan "3980" of existing session "29", that is for existing subject "MH_Brain" of existing project "fang1". You can specify the name of folder, if not existed, it'll be created.

curl -u xufang -X PUT "https://dev.xnat.sydney.edu.au/data/projects/fang1/subjects/MH_Brain/experiments/29/scans/3980/resources/TEST/files?extract=true" -F "file=@test.zip"


Upload the whole session to prearchive

curl -u username -X POST "https://xnat.sydney.edu.au/data/services/import" -F 'file=@file.zip'

Create folder

curl -u username -X PUT "https://xnat.sydney.edu.au/data/projects/[insert project name here]/subjects/[insert subject name here]/experiments/[insert session name here]/scans/[insert scan id here]/resources/[insert a custom folder name here]"


For example, below command creates a sub-folder "TEST3" under scan named "3980" of existing session "29", that is for existing subject "MH_Brain" of existing project "fang1". Note that no further sub-directories are allowed.

curl -u xufang -X PUT "https://xnat.sydney.edu.au/data/projects/fang1/subjects/MH_Brain/experiments/29/scans/3980/resources/TEST3"

Initiate push session data to S3

curl -u xufang -X POST "https://uat.xnat.sydney.edu.au/xapi/remote_files/push?item=/archive/experiments/[insert session accession number here]"

For example, below command will push session XNAT_E00019 data to S3 bucket

curl -u xufang -X POST "https://uat.xnat.sydney.edu.au/xapi/remote_files/push?item=/archive/experiments/XNAT_E00019"