How to query the API ?

With cURL

The REST API is queryable in command line by using cURL

curl --request POST \
--url https://metabocloud.mesocentre.uca.fr/inchi/generation \
--header 'Content-Type: multipart/form-data' \
--form 'molText=<compound's MOL in plain text>'

With Python

One of the ways to query a REST-API with Python is to use the requests library.

After installing the requests library, you can query the REST API :

import requests

mol_text = "Compound's MOL in plain text"
mol_file = None
sdf_file = None

multipart_form_data_input = {
    "molText": (None, mol_text),
    "molFile": (None, mol_file),
    "sdfFile": (None, sdf_file)
    }

result = requests.post(f"https://metabocloud.mesocentre.uca.fr/inchi/generation", files=multipart_form_data_input)

output = result.text

Caution

Only one type of input (MOL in plain text, MOL file or SDF file) can be send in one request. The other types of input must be set to None.

Note

If you ran the application locally on your machine from a virtual environment or via Docker, you need to change the URL you send the request to. This means that https://metabocloud.mesocentre.uca.fr/<microservice>/<endpoint> will become http://localhost:<default port>/<endpoint> if you launched the application with the default parameters.

If you choose another port to run the application then you need to change the URL accordingly.

With a client generated by Swagger

From the OpenAPI specification file describing this REST API, you can auto-generated a client in the language you want thanks to Swagger using the option Generate Client in the menu.

The OpenAPI specification file is downloadable here : https://metabocloud.mesocentre.uca.fr/cdk/metabocloud-cdk.yaml