How to get more than 10K targets associated with one disease

The maximum amount of results that the Open Targets Platform REST API can return in each call is 10,000, but for some diseases such as breast carcinoma (EFO_0000305), the number of associated targets is beyond this limit.

How can you retrieve all the associations for a disease that contains more than 10,000 targets? Use next, a root-level field that contains a vector of elements to act as a token. If you add next when calling our API endpoints, such as the association/filter, you will implement pagination and retrieve the next chunk of results.

You can use next in either GET or POST methods:

  • GET - you will need to append the elements from the previous array to the next one

  • POST - you will need to add next as a JSON by inserting it as it is in the JSON payload structure

Please note, that although you can use next, we would still recommend not retrieving more than 10K results in each call. If you would like to access the all targets in our Open Targets Platform (over 20,000), please go to our Data Download page to download the entire dataset.

Let's look at one example with the GET method first:

http GET 'https://platform-api.opentargets.io/v3/platform/public/association/filter?size=100&disease=EFO_0000305'| jq '.next'

Make sure you have httpie and jq installed. Note that for example purposes we are only getting 100 results at a time.

You will get these elements:

1.1290116,

"ENSG00000108840-EFO_0000305"

To retrieve the following set of results, you will use the elements returned in the first array (see above) to make the next call:

http GET 'https://platform-api.opentargets.io/v3/platform/public/association/filter?size=100&disease=EFO_0000305&next=1.1290116&next=ENSG00000103089-EFO_0000305' | jq '.next'

You will get these elements:

0.98741496,

"ENSG00000118046-EFO_0000305"

To fetch the next set of results, you will append the elements from your previous call to the next one, and so on so forth.

Let's now try the POST method to retrieve the targets for breast carcinoma (EFO_0000305):

http POST 'https://platform-api.opentargets.io/v3/platform/public/association/filter?disease=EFO_0000305' @payload.json

# payload.json content # { # "next": [0.98741496,"ENSG00000118046-EFO_0000305"], # "size": 100 # }

```

Email us if you want to discuss this in more details or request additional tutorials using our REST API. Looking forward to hearing your suggestions.