Skip to main content

Unofficial community-maintained Python client for the Open Targets Platform GraphQL API

Project description

opentargets-py

PyPI version Python versions CI License

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.typed marker, mypy --strict compliant
  • 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 integrationas_dataframe=True on any list method
  • Minimal dependencies — only httpx and pydantic

More Examples

See the examples/ directory:

API Reference

See docs/api-reference.md.

Contributing

  1. Fork the repo and create a feature branch.
  2. Install dev dependencies: pip install -e ".[dev,pandas]"
  3. Run tests: pytest
  4. Run linting: ruff check src tests && ruff format src tests
  5. Open a pull request.

License

Apache 2.0 — see LICENSE.

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

opentargets_py-0.1.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opentargets_py-0.1.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

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

Hashes for opentargets_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4dc83310b845774e67512957cce25bd302652d4bbe099fd07636da6fb7f87b72
MD5 003fc68e5614fee5662b2f6c2d33dc0a
BLAKE2b-256 0eca92c5489b2e3a6897b33b8ffb13585dbfee39d98657784f8117d5445c1d9a

See more details on using hashes here.

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

Hashes for opentargets_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b16fc0f703c925935906a4581fb901b95af1a509d15186db64fc2547b5000b9
MD5 08f1d2da30e3ece8d8b1fc290ef82b22
BLAKE2b-256 8053345f04911ddc82ad403e2ab2db538d4ea7ea12edfec316b945ebea1e732b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page