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.

Prerequisites

  • Python 3.10 or later (earlier versions are not supported)

  • pip or conda for package management

  • A Datamint account with an API key (get one at app.datamint.io)

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

Verify your installation

python -c "import datamint; print(datamint.__version__)"
datamint-config --help

Setup API Key

Obtaining an API key

Before using the Datamint API, you need to configure your API key. If you have the necessary permissions, you can obtain one from the Datamint platform:

  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.

Configuring your API key

Once you have your API key, choose one of the following options:

Option 1: Using the CLI tool (recommended)

datamint-config --api-key YOUR_API_KEY

Option 2: Setting an environment variable

export DATAMINT_API_KEY="your_api_key"

Option 3: Programmatically in Python

from datamint import Api

api = Api(api_key="your_api_key")

Troubleshooting

ImportError: No module named ‘datamint’

Make sure you activated your virtual environment before running your script:

source datamint-env/bin/activate  # Linux/macOS
datamint-env\Scripts\activate     # Windows

Or install globally (not recommended):

pip install --user -U datamint
API authentication errors

Verify your API key is set correctly:

datamint-config

Next Steps

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