Skip to main content

Orthanc REST API python wrapper with additional utilities

Project description


Python library that wrap the Orthanc REST API and facilitate the manipulation of data.

Link to Orthanc web site:

Notes: Please note that this is an early version of the wrapper (version < 1.0), therefore some methods description (and maybe name) may change because they don't describe adequately the behavior of the corresponding Orthanc REST API route. Also note that this librairy is still under development. If the description of an Orthanc method does not correspond to the planned behavior, please do an issue.

However, 'PyOrthanc' contains objects and functions that may be useful for anyone writing python script to interact with Orthanc.

Also note that tests (python test) might only work on a linux machine.


$ pip install pyorthanc

Or from the repository:

pip install git+

Or, if you do not have git installed, clone the repository:

pip install -e

Specific version

If you are looking for a specific version, lookout the version with the desired tag ar

Example of usage

Be sure that Orthanc is running. The default URL (if running locally) is http://localhost:8042.

With Orthanc server:

from pyorthanc import Orthanc

orthanc = Orthanc('http://localhost:8042')
orthanc.setup_credentials('username', 'password')  # If needed

# To get patients identifier and main information
patients_identifiers = orthanc.get_patients()

for patient_identifier in patients_identifiers:
    patient_information = orthanc.get_patient_information(patient_identifier)

# To get patient's studies identifier and main information
a_patient_identifier = patients_identifiers[0]
studies_identifiers = orthanc.get_studies(a_patient_identifier)

for study_identifier in studies_identifiers:
    study_information = orthanc.get_study_information(study_identifier)

Getting list of remote modalities:

from pyorthanc import Orthanc

orthanc = Orthanc('http://localhost:8042')
orthanc.setup_credentials('username', 'password')  # If needed


Query (C-Find) and Retrieve (C-Move) from remote modality:

from pyorthanc import RemoteModality, Orthanc

remote_modality = RemoteModality(Orthanc('http://localhost:8042'), 'modality')
remote_modality.setup_credentials('username', 'password')  # If needed

# Query (C-Find) on modality
data = {'Level': 'Study', 'Query': {'PatientID': '*'}}
query_response = remote_modality.query(data=data)

# Retrieve (C-Move) results of query on a target modality (AET)
remote_modality.move(query_response['QUERY_ID'], 'target_modality')

Build a patient tree structure of all patients in Orthanc instance:

Each patient is a tree. Layers in each tree are Patient -> Study -> Series -> Instance.

from pyorthanc import Orthanc, datastructure

patient_forest = datastructure.build_patient_forest(

for patient in patient_forest:
    patient_info = patient.get_main_information()

    for study in patient.get_studies():

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyorthanc, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size pyorthanc-0.2.1-py3-none-any.whl (61.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pyorthanc-0.2.1.tar.gz (54.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page