Python client for the Open Targets REST API at
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Merge branch 'master' into af-url-update Feb 14, 2019
tests update testing Feb 14, 2019
MANIFEST fix: vesion update Jan 10, 2019 Merge branch 'master' into af-url-update Feb 14, 2019
readthedocs.yml refactor: add codecov travis pytest and python 3.6 check Jan 10, 2019
requirements.txt fix: get_stats() works properly Jan 19, 2019


Python client for the Open Targets REST API at Build Status Documentation Status

Why should you use this client instead of the REST API directly?

  • Include wrappers for all public methods, with query validation
  • Tools for the most common calls (E.g. get data for a target gene symbol even if you do not know its Ensembl Gene Id)
  • Supports automatic retrieval of paginated results with an iterator pattern
  • Easily save query results as JSON, CSV or Excel file
  • Handles Authentication
  • Handles fair usage limits transparently
  • Follows HTTP cache as set by the REST API
  • Experimental HTTP2 support for better performance (beware the client library is in alpha)
  • Support for advanced SSL and proxy configuration

This client is supported for Python 3.5 and upper. Works on pythoon 2.7 on a best effort basis.

Documentation is available on ReadTheDocs


from opentargets import OpenTargetsClient

ot = OpenTargetsClient()

search_result ='BRAF')

a_for_target = ot.get_associations_for_target('BRAF')
for a in a_for_target:
    print(a['id'], a['association_score']['overall'])

a_for_disease = ot.get_associations_for_disease('cancer')


e_for_target = ot.get_evidence_for_target('BRAF')

e_for_disease = ot.get_evidence_for_disease('medulloblastoma')





To create a development environment:

git clone <this repo>
cd opentargets-py
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

How to contribute:

  1. (if you are not part of the open targets team) fork the repo
  2. branch from master, always start with git checkout -b yourname-featureyouareadding
  3. code
  4. push your branch and submit a PR
  5. ask for reviews for your PR
  6. Travis tests have to pass
  7. Your PR is approved and merged

How to release

  1. Draft a new release
  2. add a tag using semantic versioning, pointing to master
  3. Press publish

Releases will automatically deploy to pypi (thanks to travis) once they are created in the github console.