API

An Application Programming Interface (API) provides communication between a client (e.g. a desktop computer or mobile app) and a server. The server receives information sent from the client via the API, interprets and processes it, and returns the result back to the client in a readable way.

As part of the X-Raydar project, we provide free access an API which provides access to two analysis algorithms:

  • X-Raydar-NLP for the real-time annotation of free-text reports
  • X-Raydar-CV for the real-time reading of chest X-rays provided in DICOM format

The API communicates with our computational servers based at the University of Warwick where the data is uploaded and processed. It receives either a DICOM or text file, which is sent to the appropriate algorithm for processing. In both cases, the API results a list of probabilities associated to each of the 37 radiological abnormalities.

In order to use the API, we require users to register and follow the instructions related to the programming language used to make API requests.

There are two prerequisites for consuming this API:
  • Registration
    For security reasons, any and all requests must be verified by providing a 16-character key in the body parameters. This can be created by registering and providing an email address.
  • A HTTP client
    Any DICOMs and text files sent to the API are handled over the internet using HTTP. This can be achieved by building a simple HTTP client using one of many programming languages or interfaces. This guide provides examples of how this can be done using several popular ones. The examples shown provide the basic syntax for constructing a HTTP client, executing a request to the API and reading the response, using an appropriate library for each language. This is fundamentally the same as using X-Raydar Online, only by using your own software to interact with the API. This grants the freedom to handle the report returned from the algorithm however is necessary.

URL and Key Placeholders

In each example shown on how to build a HTTP client in various languages, there are three placeholders that must be filled for the request to be valid, unless otherwise stated.

URL
							
		<URL goes here>
							
						

URL option available:

  • https://x-raydar.info/api/cv
    for DICOM files and the Computer Vision algorithm
  • https://x-raydar.info/api/nlp
    for text files and the NLP algorithm
Key
							
		<Key goes here>
							
						

As mentioned, registration is necessary to consume the API. Insert the 16 character string received in the registration email here.

File Path

Replace this section with the complete or relative path to the file you wish to send:

							
		/path/to/file
							
						

Requests

Requests is an additional library and syntactically much simpler than the standard http.client package.

Firstly it must be installed via pip from any CLI

					
python -m pip install requests					
					
				

Then it can be used to build a client in fewer lines

					
import requests

url = "https://x-raydar.info/api/cv"

payload={'key': '<Key goes here>'}

FILEPATH = '/path/to/file' #It has to be a DICOM file 

files=[
  ('file',('file',open(FILEPATH,'rb'),'application/octet-stream'))
]
headers = {}
try:
    response = requests.request("POST", url, headers=headers, data=payload, files=files, timeout=10)
    print(response.text)
except requests.exceptions.Timeout as err:
    print(err)