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:
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: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 goes here>
URL option available:
https://x-raydar.info/api/cv
for DICOM files and the Computer Vision algorithmhttps://x-raydar.info/api/nlp
for text files and the NLP algorithm
<Key goes here>
As mentioned, registration is necessary to consume the API. Insert the 16 character string received in the registration email here.
Replace this section with the complete or relative path to the file you wish to send:
/path/to/file
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)