GraphQL API
The Open Targets Platform GraphQL — available at http://api.platform.opentargets.org — is our new API that allows for language-agnostic access to our data, along with other key benefits:
You can construct a query that returns only the fields that you need
You can build graphical queries that traverse a data graph through resolvable entities and this reduces the need for multiple queries
You can access the GraphQL API playground with built-in documentation and schema showing required and optional parameters
You can view the schema that shows the available fields for each object along with a description and data type attribute
You only have to use
POST
requests with a simple query string and variables object
Our GraphQL API supports queries for a single target, disease/phenotype, drug, or target-disease association. For more systematic queries (e.g. for multiple targets), please use our data downloads or our Google BigQuery instance.
Available endpoints
The base URL endpoint for our new GraphQL API is:
You can then access relevant data from the following endpoints:
/target: contains annotation information for targets including tractability assessments, mouse phenotype models, and baseline expression; also contains data on diseases and phenotypes association with the given target
/disease: contains annotation information for diseases and phenotypes including ontology, known drugs, and clinical signs and symptoms; also contains data on targets associated with the given disease or phenotype
/drug: contains annotation information for compounds and drugs including mechanisms of action, indications, and pharmacovigilance data
/search: contains index of all entities contained within the Platform
Example GraphQL query
Below is an example GraphQL query for AR (ENSG00000169083) that will return Genetic Constraint and Tractability data.
Run this query in our GraphQL API playground
Using GraphQL's query strings and variables object constructs, you can also access the data using a programming language that supports HTTP POST
requests. While this is a valid approach, we discourage users from repeatedly querying the GraphQL API one entity at a time. Instead, our comprehensive datasets available for download provide a simpler and more performant strategy to achieve the same result.
Sample scripts
Below is an example script using the same AR query above, but written for Python and R:
Tutorials and how-to guides
For more information on how to use the GraphQL API and example queries based on actual use cases and research questions, check out the Open Targets Community.
Last updated