Unofficial community-maintained Python client for the Open Targets Platform GraphQL API
Project description
opentargets-py
Modern Python client for the Open Targets Platform GraphQL API.
Disclaimer: This is an unofficial, community-maintained client and is not affiliated with, endorsed by, or supported by the Open Targets consortium. For the official platform, visit platform.opentargets.org.
The official opentargets package was deprecated when Open Targets migrated to GraphQL in 2021 and has since been removed from PyPI. This library fills that gap — it is the only Python SDK targeting the current GraphQL API.
Installation
pip install opentargets-py
With pandas support:
pip install opentargets-py[pandas]
Quick Start
from opentargets import OpenTargetsClient
client = OpenTargetsClient()
# Look up a target by gene symbol
target = client.get_target("EGFR")
print(target.approved_name) # epidermal growth factor receptor
# Get associated diseases
associations = client.get_target_associations("EGFR", limit=10)
for a in associations:
print(a.disease_name, a.score)
# Get drugs for a target
drugs = client.get_target_drugs("EGFR")
# Look up a disease
disease = client.get_disease("EFO_0003060")
# Search across the platform
results = client.search("lung cancer", entity_type="disease", limit=5)
Features
- Type-safe — full Pydantic v2 models,
py.typedmarker,mypy --strictcompliant - Symbol resolution — pass
"EGFR"instead of"ENSG00000146648" - Auto-pagination — fetches all pages transparently
- In-memory cache — LRU cache with TTL, reduces redundant API calls
- Retry with backoff — automatic retries on 429/5xx with exponential backoff
- Pandas integration —
as_dataframe=Trueon any list method - Minimal dependencies — only
httpxandpydantic
More Examples
See the examples/ directory:
basic_usage.py— targets, diseases, drugs, searchbatch_query.py— batch fetch + DataFrame outputnetwork_analysis.py— build a target–disease network
API Reference
Contributing
- Fork the repo and create a feature branch.
- Install dev dependencies:
pip install -e ".[dev,pandas]" - Run tests:
pytest - Run linting:
ruff check src tests && ruff format src tests - Open a pull request.
License
Apache 2.0 — see LICENSE.
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 opentargets_py-0.1.0.tar.gz.
File metadata
- Download URL: opentargets_py-0.1.0.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dc83310b845774e67512957cce25bd302652d4bbe099fd07636da6fb7f87b72
|
|
| MD5 |
003fc68e5614fee5662b2f6c2d33dc0a
|
|
| BLAKE2b-256 |
0eca92c5489b2e3a6897b33b8ffb13585dbfee39d98657784f8117d5445c1d9a
|
File details
Details for the file opentargets_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: opentargets_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b16fc0f703c925935906a4581fb901b95af1a509d15186db64fc2547b5000b9
|
|
| MD5 |
08f1d2da30e3ece8d8b1fc290ef82b22
|
|
| BLAKE2b-256 |
8053345f04911ddc82ad403e2ab2db538d4ea7ea12edfec316b945ebea1e732b
|