Getting Started with Datamint Python API

This guide will help you set up and start using the Datamint Python API for your medical imaging projects.

Installation

Datamint requires Python 3.10+. Install/update Datamint and its dependencies using pip

pip install -U datamint

We recommend that you install Datamint in a dedicated virtualenv, to avoid conflicting with your system packages. You can do this by running:

python3 -m venv datamint-env
source datamint-env/bin/activate # In Windows, run datamint-env\Scripts\activate.bat
pip install -U datamint

Setup API key

To use the Datamint API, you need to set up your API key. If you have the necessary permissions, you can obtain one from the UI:

  1. In the left sidebar, select Teams.

  2. Click Edit on your user profile.

Navigating to the Teams page and editing your profile

  1. Click Generate API key to create a new API key.

Generating an API key

Note

If you don’t have the necessary permissions, ask your administrator.


Once you have your API key, use one of the following methods to configure it:

Method 2: Environment variable

Specify the API key as an environment variable.

export DATAMINT_API_KEY="my_api_key"
# run your commands (e.g., `datamint-upload`, `python script.py`)
import os
os.environ["DATAMINT_API_KEY"] = "my_api_key"

Method 3: Api constructor

Specify API key in the Api constructor:

from datamint import Api

api = Api(api_key='my_api_key')

Next Steps

Now that you have the basics set up, explore these advanced topics: