How to find the Ensembl ID for a gene

You need to know the Ensembl gene ID for your gene of interest e.g. PCSK9 before using the Open Targets Genetics GraphQL API for more complex queries.

Use thesearchWithSymbolquery:

{
searchWithSymbol: search(queryString: "PCSK9") {
genes {
id
symbol
}
}
}

Response

{
"data": {
"searchWithSymbol": {
"genes": [
{
"id": "ENSG00000169174",
"symbol": "PCSK9"
}
]
}
}
}
Finding the Ensembl Gene ID for PCSK9 using the GraphiQL browser

As an alternative to using the GraphIiQL browser, you can use curl instead to retrieve this information in the command line:

curl -X POST https://genetics-api.opentargets.io/graphql -H 'Content-Type: application/json' -d '{ "query": "{ geneInfo(geneId: \"ENSG00000091831\") { symbol }}"}'

For more complex queries, save your query in a separate file in JSON, for example, as illustrated elsewhere.