An unofficial Python SDK for interacting with the OHDSI Athena Concepts API.
Project description
athena-client
An unofficial Python SDK for interacting with the OHDSI Athena Concepts API. Easily search, explore, and analyze medical concepts without any additional setup.
Developed by Alvaro A. Alvarez P. (alvaro1@stanford.edu).
This project is provided as-is, without warranty of any kind.
Looking for advanced concept exploration, mapping, and best practices? See the Concept Exploration Guide for a comprehensive tutorial on robust usage, advanced workflows, and real-world examples.
Responsible Usage Notice: Please use this package responsibly. Avoid making excessive or automated requests to the Athena API, as this may result in your IP being rate-limited or blocked by the API provider. Always use filters and limits where possible, and respect the terms of service of the OHDSI Athena API.
Installation
Basic Installation (Recommended)
For standard use, install with:
pip install athena-client
This provides essential Athena API functionalities like concept search and exploration without database integration.
Alternatively, explicitly specify:
pip install "athena-client[core]"
Both methods offer the same functionality.
Quick Start
from athena_client import Athena
# Initialize Athena client (uses public Athena API by default)
athena = Athena()
# Search for concepts
results = athena.search("aspirin")
# Different ways to handle results
concept_list = results.all()
top_three = results.top(3)
as_json = results.to_json()
as_df = results.to_df()
# Detailed information for a specific concept
details = athena.details(concept_id=1127433)
# Concept relationships
relationships = athena.relationships(concept_id=1127433)
# Concept graph
graph = athena.graph(concept_id=1127433, depth=3)
# Comprehensive summary
summary = athena.summary(concept_id=1127433)
CLI Quick Start
Athena CLI allows rapid concept search and exploration:
athena search "aspirin" --limit 3 --output json
athena details 1127433
athena relationships 1127433
athena graph 1127433 --depth 3
athena summary 1127433
Optional Extras
Additional functionalities can be installed separately:
pip install athena-client[cli] # Command-line interface
pip install athena-client[async] # Async client support
pip install athena-client[pandas] # pandas DataFrame support
pip install athena-client[yaml] # YAML format support
pip install athena-client[crypto] # HMAC authentication
pip install athena-client[all] # All optional dependencies
Experimental: Database Integration (Advanced Users)
Warning: Database integration features are experimental, subject to change, and may encounter errors.
Experimental database integration allows validation and concept set generation against your local OMOP database. Use these features cautiously.
Installation for Database Support
For specific database integrations:
-
PostgreSQL:
pip install "athena-client[postgres]"
-
Google BigQuery:
pip install "athena-client[bigquery]"
Reducing Dependency Conflicts (Advanced)
To minimize dependency issues:
- Use specific extras when installing.
- For BigQuery integration, use Python 3.9 and SQLAlchemy < 1.5.0.
Database Usage Example
import asyncio
from athena_client import Athena
DB_CONNECTION_STRING = "postgresql://user:pass@localhost/omop_cdm"
async def main():
athena = Athena()
concept_set = await athena.generate_concept_set(
query="Type 2 Diabetes",
db_connection_string=DB_CONNECTION_STRING
)
print(concept_set)
asyncio.run(main())
Experimental CLI Database Example
export OMOP_DB_CONNECTION="postgresql://user:pass@localhost/omop"
athena generate-set "Type 2 Diabetes" --output json
Troubleshooting Common Issues
- Dependency installation problems: Ensure Python version compatibility and correct extras.
- PostgreSQL build errors: Install PostgreSQL development tools (
brew install postgresqlon macOS). - BigQuery SQLAlchemy conflicts: Only use Python 3.9 with BigQuery integration.
Exporting CLI Results to Files (JSON, YAML, CSV)
You can export CLI search results to various formats:
athena search "aspirin" --output json | tail -n +2 > aspirin_concepts.json
athena search "aspirin" --output yaml | tail -n +2 > aspirin_concepts.yaml
athena search "aspirin" --output csv | tail -n +2 > aspirin_concepts.csv
Note: The
tail -n +2removes warning lines (such as large query warnings) to ensure the output file is valid for the chosen format.
Version Compatibility
- Python: >= 3.9, < 3.13
- SQLAlchemy: >= 1.4.0 (BigQuery limited to <1.5.0)
- pandas: >= 1.3.0, < 3.0.0
- pydantic: >= 2.0.0
- httpx: >= 0.18.0
- cryptography: >= 36.0.0
Project details
Release history Release notifications | RSS feed
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 athena_client-1.0.18.tar.gz.
File metadata
- Download URL: athena_client-1.0.18.tar.gz
- Upload date:
- Size: 70.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab4c8d3e756c093ce2d0c53ecced72ef130b0982908b8d5e1dd001976825e958
|
|
| MD5 |
a97332c11ad65ac669a6c10cf76ccdad
|
|
| BLAKE2b-256 |
81b9df2710fb83010f4129f17c5bc495930dd73d59ea9825231ffa4cbd5953c1
|
Provenance
The following attestation bundles were made for athena_client-1.0.18.tar.gz:
Publisher:
publish.yml on aandresalvarez/athena_client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
athena_client-1.0.18.tar.gz -
Subject digest:
ab4c8d3e756c093ce2d0c53ecced72ef130b0982908b8d5e1dd001976825e958 - Sigstore transparency entry: 258084747
- Sigstore integration time:
-
Permalink:
aandresalvarez/athena_client@9e5208cf827bbe817bf5fc83900afb23018e695a -
Branch / Tag:
refs/tags/v1.0.18 - Owner: https://github.com/aandresalvarez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9e5208cf827bbe817bf5fc83900afb23018e695a -
Trigger Event:
push
-
Statement type:
File details
Details for the file athena_client-1.0.18-py3-none-any.whl.
File metadata
- Download URL: athena_client-1.0.18-py3-none-any.whl
- Upload date:
- Size: 46.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b70096628a3d8596f500aab663dea1473c46424be855d7853c97784d99badcbf
|
|
| MD5 |
142e05fa3d523f8728dfa329286379a6
|
|
| BLAKE2b-256 |
9c8d502b308c106e3021f44d102c45483219bb314463d88f3ee785e1e4ae2e2b
|
Provenance
The following attestation bundles were made for athena_client-1.0.18-py3-none-any.whl:
Publisher:
publish.yml on aandresalvarez/athena_client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
athena_client-1.0.18-py3-none-any.whl -
Subject digest:
b70096628a3d8596f500aab663dea1473c46424be855d7853c97784d99badcbf - Sigstore transparency entry: 258084761
- Sigstore integration time:
-
Permalink:
aandresalvarez/athena_client@9e5208cf827bbe817bf5fc83900afb23018e695a -
Branch / Tag:
refs/tags/v1.0.18 - Owner: https://github.com/aandresalvarez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9e5208cf827bbe817bf5fc83900afb23018e695a -
Trigger Event:
push
-
Statement type: