Unofficial Python SDK for the iMednet clinical trials API
Project description
imednet
Unofficial Python SDK for the iMednet clinical trials API.
Full documentation: https://fderuiter.github.io/imednet-python-sdk/
This package simplifies integration with the iMednet REST API for clinical trial management. It provides typed endpoint wrappers, helper workflows and a CLI so researchers and developers can automate data extraction and submission without reimplementing HTTP logic.
Features
- Simple, consistent interface for API calls
- Automatic pagination across endpoints
- Pydantic models for requests and responses
- Workflow helpers for data extraction and mapping
- Pandas and CSV utilities
- Optional in-memory caching of study metadata
- Structured JSON logging and OpenTelemetry tracing
- Async client and command line interface
Architecture
The SDK is organized around a core HTTP client layer, endpoint wrappers that model the iMednet API, workflow helpers that combine multiple endpoint calls, and a CLI built on top of those pieces.
graph TD
CLI[CLI] --> |invokes| Workflows
Workflows --> |coordinate| Endpoints
Endpoints --> |use| Client["(HTTP Client)"]
Client --> |requests| API
Installation
# PyPI release
pip install imednet
# Dev version
pip install git+https://github.com/fderuiter/imednet-python-sdk.git@main
Quick Start
Synchronous Example
from imednet import ImednetSDK, load_config
from imednet.utils import configure_json_logging
configure_json_logging()
cfg = load_config()
sdk = ImednetSDK(
api_key=cfg.api_key,
security_key=cfg.security_key,
base_url=cfg.base_url,
)
print(sdk.studies.list())
Asynchronous Example
import asyncio
from imednet import AsyncImednetSDK, load_config
from imednet.utils import configure_json_logging
async def main() -> None:
configure_json_logging()
cfg = load_config()
async with AsyncImednetSDK(
api_key=cfg.api_key,
security_key=cfg.security_key,
base_url=cfg.base_url,
) as sdk:
print(await sdk.studies.async_list())
asyncio.run(main())
See docs/async_quick_start.rst for more details.
Configuration
The SDK and CLI read credentials from environment variables such as
IMEDNET_API_KEY and IMEDNET_SECURITY_KEY. You can set these in your shell or
use a .env file. Copy .env.example to .env to get started.
See configuration for the complete list of options.
Use imednet.config.load_config() to access these values in your code.
CLI Usage
The package installs an imednet command with subcommands for studies, sites,
subjects, records, jobs, queries and more. Use imednet --help to explore all
options.
Example of exporting a subset of variables:
imednet export sql MY_STUDY table sqlite:///data.db --vars AGE,SEX --forms 10,20
When the connection string uses SQLite, the command splits the output into one
table per form to avoid the 2000 column limit. Pass --single-table to
disable this behaviour. See docs/cli.rst for full examples.
Documentation & Resources
- API Documentation: Full documentation is available at https://fderuiter.github.io/imednet-python-sdk/.
- Official iMednet API Docs: https://portal.prod.imednetapi.com/.
- Postman Collection: Download
imednet.postman_collection.jsonand import it into Postman to explore and test the API endpoints.
Development & Contributing
Tech Stack
- Python 3.10–3.12
- requests, httpx, pydantic, typer, tenacity, python-dotenv
Project Structure
.
├── docs/ - Sphinx documentation
├── examples/ - Usage samples
├── imednet/ - SDK package
├── scripts/ - Helper scripts
└── tests/ - Unit and integration tests
Testing & Development
./scripts/setup.sh # once
poetry run ruff check --fix .
poetry run black --check .
poetry run isort --check --profile black .
poetry run mypy imednet
poetry run pytest -q
After running tests, validate documentation builds cleanly (no warnings):
make docs
See docs/AGENTS.md for full documentation guidelines.
Smoke-test workflow
The optional smoke.yml action runs the tests/live suite.
It relies on repository secrets APIKEY and SECURITYKEY and sets IMEDNET_RUN_E2E.
Use the workflow to confirm real API access on demand or via its nightly schedule.
INFO-level log messages stream to the terminal during these runs, making it easier to
debug failures.
Building & Publishing
python -m build
python -m twine upload dist/*
Pushing a Git tag like v0.1.4 triggers the GitHub Actions workflow that builds
and publishes the package to PyPI.
Versioning & Changelog
This project follows Semantic Versioning. See GitHub Releases for release history.
Contributing
Contributions are welcome! See the contributing guide and CONTRIBUTING.md for full details.
License
This project is licensed under the MIT license. See LICENSE for details.
Acknowledgements
Built with open source libraries including requests, httpx, pydantic and typer.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file imednet-0.2.2.tar.gz.
File metadata
- Download URL: imednet-0.2.2.tar.gz
- Upload date:
- Size: 67.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b85a4d97a6a0b1955033bd6159e5b10155b80a4e58896de9230eea47d0a5284e
|
|
| MD5 |
233169c0d5261e0e5a339c6fdc1c699c
|
|
| BLAKE2b-256 |
ccb757ac9830429eb772ee9ae17bc019944db02eea832343324893ac6297f384
|
Provenance
The following attestation bundles were made for imednet-0.2.2.tar.gz:
Publisher:
release.yml on fderuiter/imednet-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imednet-0.2.2.tar.gz -
Subject digest:
b85a4d97a6a0b1955033bd6159e5b10155b80a4e58896de9230eea47d0a5284e - Sigstore transparency entry: 764613824
- Sigstore integration time:
-
Permalink:
fderuiter/imednet-python-sdk@1ae4ac7b2ab110e4e2242cefa4ecbf2163e246a5 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/fderuiter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1ae4ac7b2ab110e4e2242cefa4ecbf2163e246a5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file imednet-0.2.2-py3-none-any.whl.
File metadata
- Download URL: imednet-0.2.2-py3-none-any.whl
- Upload date:
- Size: 92.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dea8f426c4f50a796071756f0d19d36bbba846e31893026e807054a25b4a668
|
|
| MD5 |
66f7fbdb4c7fb5fa1eb1ef4c553c289b
|
|
| BLAKE2b-256 |
1e89b11d6ff4eb942260339271b3fcd4a31f0cc5e7c9a10f798aa000088332a2
|
Provenance
The following attestation bundles were made for imednet-0.2.2-py3-none-any.whl:
Publisher:
release.yml on fderuiter/imednet-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imednet-0.2.2-py3-none-any.whl -
Subject digest:
5dea8f426c4f50a796071756f0d19d36bbba846e31893026e807054a25b4a668 - Sigstore transparency entry: 764613828
- Sigstore integration time:
-
Permalink:
fderuiter/imednet-python-sdk@1ae4ac7b2ab110e4e2242cefa4ecbf2163e246a5 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/fderuiter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1ae4ac7b2ab110e4e2242cefa4ecbf2163e246a5 -
Trigger Event:
push
-
Statement type: