scientific-skills/database-lookup/references/opentargets.md
GraphQL API (primary, recommended):
https://api.platform.opentargets.org/api/v4/graphql
Important: The GraphQL endpoint requires HTTP POST with Content-Type: application/json. WebFetch (GET-only) will not work — use curl via shell instead:
curl -s -X POST -H "Content-Type: application/json" \
-d '{"query":"{ target(ensemblId: \"ENSG00000157764\") { approvedSymbol approvedName } }"}' \
https://api.platform.opentargets.org/api/v4/graphql
REST API (simpler queries):
https://api.platform.opentargets.org/api/v4
No API key required. All endpoints are public.
All GraphQL queries are sent as POST requests to the GraphQL endpoint.
POST https://api.platform.opentargets.org/api/v4/graphql
Content-Type: application/json
{
"query": "...",
"variables": { ... }
}
query TargetInfo($ensemblId: String!) {
target(ensemblId: $ensemblId) {
id
approvedSymbol
approvedName
biotype
proteinIds {
id
source
}
tractability {
label
modality
value
}
safetyLiabilities {
event
effects {
direction
dosing
}
}
pathways {
pathway
pathwayId
}
functionDescriptions
subcellularLocations {
location
}
}
}
Variables: { "ensemblId": "ENSG00000141510" }
Example as URL (GET also supported for simple queries):
https://api.platform.opentargets.org/api/v4/graphql?query={target(ensemblId:"ENSG00000141510"){id approvedSymbol approvedName biotype functionDescriptions}}
query DiseaseInfo($efoId: String!) {
disease(efoId: $efoId) {
id
name
description
therapeuticAreas {
id
name
}
synonyms {
terms
}
}
}
Variables: { "efoId": "EFO_0000311" } (cancer)
Example as URL:
https://api.platform.opentargets.org/api/v4/graphql?query={disease(efoId:"EFO_0000311"){id name description therapeuticAreas{id name}}}
query Associations($ensemblId: String!, $page: Pagination!) {
target(ensemblId: $ensemblId) {
approvedSymbol
associatedDiseases(page: $page) {
count
rows {
disease {
id
name
}
score
datasourceScores {
id
score
}
}
}
}
}
Variables:
{
"ensemblId": "ENSG00000141510",
"page": { "index": 0, "size": 10 }
}
Example as URL:
https://api.platform.opentargets.org/api/v4/graphql?query={target(ensemblId:"ENSG00000141510"){approvedSymbol associatedDiseases(page:{index:0,size:5}){count rows{disease{id name}score}}}}
query DiseaseAssociations($efoId: String!, $page: Pagination!) {
disease(efoId: $efoId) {
name
associatedTargets(page: $page) {
count
rows {
target {
id
approvedSymbol
}
score
datasourceScores {
id
score
}
}
}
}
}
Variables:
{
"efoId": "EFO_0000311",
"page": { "index": 0, "size": 10 }
}
query Evidence($ensemblId: String!, $efoId: String!, $size: Int!) {
disease(efoId: $efoId) {
evidences(ensemblIds: [$ensemblId], size: $size) {
count
rows {
id
score
datasourceId
datatypeId
literature
diseaseFromSource
targetFromSourceId
resourceScore
urls {
niceName
url
}
}
}
}
}
Variables:
{
"ensemblId": "ENSG00000141510",
"efoId": "EFO_0000311",
"size": 10
}
query DrugInfo($chemblId: String!) {
drug(chemblId: $chemblId) {
id
name
drugType
maximumClinicalTrialPhase
hasBeenWithdrawn
mechanismsOfAction {
rows {
mechanismOfAction
targets {
id
approvedSymbol
}
}
}
indications {
rows {
disease {
id
name
}
maxPhaseForIndication
}
}
linkedDiseases {
count
rows {
id
name
}
}
linkedTargets {
count
rows {
id
approvedSymbol
}
}
}
}
Variables: { "chemblId": "CHEMBL25" } (aspirin)
Example as URL:
https://api.platform.opentargets.org/api/v4/graphql?query={drug(chemblId:"CHEMBL25"){id name drugType maximumClinicalTrialPhase mechanismsOfAction{rows{mechanismOfAction targets{id approvedSymbol}}}}}
query Search($queryString: String!, $entityNames: [String!], $page: Pagination!) {
search(queryString: $queryString, entityNames: $entityNames, page: $page) {
total
hits {
id
entity
name
description
score
}
}
}
Variables:
{
"queryString": "BRAF melanoma",
"entityNames": ["target", "disease", "drug"],
"page": { "index": 0, "size": 10 }
}
Example as URL:
https://api.platform.opentargets.org/api/v4/graphql?query={search(queryString:"BRAF",entityNames:["target"],page:{index:0,size:5}){total hits{id entity name description}}}
query KnownDrugs($ensemblId: String!, $size: Int!) {
target(ensemblId: $ensemblId) {
approvedSymbol
knownDrugs(size: $size) {
count
rows {
drug {
id
name
drugType
maximumClinicalTrialPhase
}
disease {
id
name
}
phase
status
mechanismOfAction
urls {
niceName
url
}
}
}
}
}
Variables:
{
"ensemblId": "ENSG00000157764",
"size": 10
}
(ENSG00000157764 = BRAF)
Included in the target query (see endpoint 1 above). Modalities include:
SM (small molecule)AB (antibody)PR (PROTAC)OC (other clinical)These are simpler alternatives for common operations.
GET /api/v4/search?q={query}&page=0&size=10
Example:
https://api.platform.opentargets.org/api/v4/search?q=TP53&size=5
Response:
{
"total": 15,
"data": [
{
"id": "ENSG00000141510",
"entity": "target",
"name": "TP53",
"description": "Cellular tumor antigen p53",
"score": 142.5
}
]
}
| Entity | ID Format | Example |
|---|---|---|
| Target | Ensembl Gene ID | ENSG00000141510 (TP53) |
| Disease | EFO/Mondo/HP/Orphanet | EFO_0000311 (cancer), MONDO_0007254 |
| Drug | ChEMBL ID | CHEMBL25 (aspirin) |
ot_genetics_portal -- Open Targets Geneticseva -- ClinVar (via EVA)cancer_gene_census -- COSMIC Cancer Gene Censuschembl -- ChEMBL (clinical trials)europepmc -- Literature miningexpression_atlas -- Expression Atlasgene2phenotype -- Gene2Phenotypegenomics_england -- Genomics England PanelAppintogen -- IntOGen (cancer drivers)ot_crispr -- Open Targets CRISPR screensprogeny -- PROGENy (pathway activity)reactome -- Reactome pathwaysslapenrich -- SLAPenrichsysbio -- Systems biologyuniprot_literature -- UniProt literatureGraphQL uses page: { index: Int, size: Int } (0-based index).
REST uses page and size query parameters.
Retry-After headers.GraphQL errors:
{
"errors": [
{
"message": "Variable '$ensemblId' expected value of type 'String!' but got: null",
"locations": [{"line": 1, "column": 7}]
}
]
}
REST errors return appropriate HTTP status codes with JSON error bodies.
datasourceScores in association queries to see which evidence sources contribute most.https://platform.opentargets.org has a GraphQL playground for testing queries.