pyxnat: XNAT in Python

Date: Jul 26, 2021 Version: 1.4

Useful links: Binary Installers | Source Repository | Issues & Ideas


pyxnat is an open source, BSD-licenced library providing a programmatic interface with XNAT which is an extensible management system for imaging data (and related). pyxnat uses the RESTful Web services provided by XNAT and allows easier interaction with an XNAT server through a simple and consistent API using the Python programming language.

Short examples

Setup a connection

>>> from pyxnat import Interface
>>> interface = Interface(server='',

Traverse the resource tree

>>> list(

Operate the database

>>> project ='my_project').insert()
>>> project.resource('images').file('image.nii').insert('/tmp/image.nii')

Use the search engine

>>> table =
            ['xnat:subjectData/PROJECT', 'xnat:subjectData/SUBJECT_ID']
                     ('xnat:subjectData/PROJECT', '=', 'my_project'),

Module contents

Interface([server, user, password, config, …])

Main entry point to access an XNAT server.


Data selection interface.


Search interface.


Database user management interface.