Skip to content

Instantly share code, notes, and snippets.

@caodac
Created February 13, 2021 13:47
Show Gist options
  • Save caodac/e81d908ea30ce111455e21963819da14 to your computer and use it in GitHub Desktop.
Save caodac/e81d908ea30ce111455e21963819da14 to your computer and use it in GitHub Desktop.
Fetching data from Pharos's graphql api
import json, requests
QUERY = """
{
batch(targets: ["abl1", "P42858"]) {
targetResult {
facets {
facet
values {
name
value
}
}
count
targets {
sym
name
description
ligandCounts {
name
value
}
ligands(skip:0,top:100,isdrug:true) {
name
isdrug
smiles
synonyms {
name
value
}
}
tinxCount
tinx(top:5){
tinxid
novelty
score
disease{
doid
name
def
}
}
}
}
}
}
"""
if __name__ == "__main__":
res = requests.post('https://pharos-api.ncats.io/graphql',
json={'query': QUERY})
if 200 == res.status_code:
print (json.dumps(res.json(), indent=2))
else:
print ('%d: %s' % (res.status_code, res.text))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment