DICOMweb Client

0.11.2 · active · verified Tue Apr 21

The `dicomweb-client` library provides a JavaScript implementation of the DICOMweb standard (PS3.18), enabling web applications to interact with DICOM image archives. It supports key RESTful services including STOW-RS (Store), QIDO-RS (Query), and WADO-RS (Retrieve) for DICOM objects. The current stable version is 0.11.2, with releases occurring regularly to address bugs and introduce features, as indicated by its recent update history (e.g., multiple updates in 2025). This library is designed to be lightweight, facilitating straightforward integration into web-based environments for handling medical imaging data. It ships with full TypeScript type definitions, enhancing developer experience in type-safe projects. A key differentiator is its focus on direct DICOMweb protocol implementation for both browser and Node.js environments, providing a foundational layer for building medical image viewers and processing tools without requiring extensive frameworks.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing the DICOMweb client, performing a QIDO-RS search for studies, and executing a STOW-RS operation to store a dummy DICOM instance, including progress tracking via XMLHttpRequest.

import { DICOMwebClient } from 'dicomweb-client';

const dicomwebUrl = process.env.DICOMWEB_URL ?? 'http://localhost:8080/dicomweb';

// Initialize the client with basic configuration
const client = new DICOMwebClient({ url: dicomwebUrl });

async function runExample() {
  try {
    // 1. Search for studies (QIDO-RS)
    console.log(`Searching for studies at ${dicomwebUrl}...`);
    const studies = await client.searchForStudies();
    console.log('Found studies (Study Instance UIDs):', studies.map(s => s['0020000D']?.Value[0] || 'N/A'));

    // 2. Example of storing an instance with progress tracking (STOW-RS)
    // In a real application, 'dataSet' would be an ArrayBuffer of a valid DICOM object.
    // For demonstration, we use a dummy ArrayBuffer.
    const dummyDicomDataSet = new ArrayBuffer(1024); // Represents a single DICOM file as ArrayBuffer

    // Create a custom XMLHttpRequest to track upload progress
    const request = new XMLHttpRequest();
    request.upload.addEventListener('progress', evt => {
      if (evt.lengthComputable) {
        const percentComplete = Math.round((100 * evt.loaded) / evt.total);
        console.log(`STOW-RS upload progress: ${percentComplete}%`);
      }
    });

    const storeInstancesOptions = {
      dataSets: [dummyDicomDataSet], // Pass an array of DICOM data sets
      request, // Attach the custom XMLHttpRequest for progress
    };

    console.log('Attempting to store a dummy instance...');
    await client.storeInstances(storeInstancesOptions);
    console.log('Dummy instance stored successfully.');

  } catch (error) {
    console.error('An error occurred during DICOMweb operations:', error);
    // Common errors include CORS issues, network failures, or server-side DICOM validation problems.
  }
}

runExample();

view raw JSON →