# Batch download disease/association scores

**URL:** <https://community.opentargets.org/t/batch-download-disease-association-scores/682>\
**Category:** GraphQL API\
**Tags:** ot-platform\
**Created:** [27 June 2022 13:46 UTC](https://community.opentargets.org/t/batch-download-disease-association-scores/682 "2022-06-27T13:46:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![animesh](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/animesh/32/269_2.png) [@animesh](https://community.opentargets.org/u/animesh)\
**Post date:** [27 June 2022 13:46 UTC](https://community.opentargets.org/t/batch-download-disease-association-scores/682/1 "2022-06-27T13:46:40Z")

</div>

I am trying to download association scores from a list of IDs using the api/v4/graphql but it feels cumbersome as i am iterating through the lists and making individual calls then concatenating into a dataframe (python code appended below). Probably there is a better way of doing this, any recommendations will be deeply appreciated 🙂

```auto
import pandas as pd
import json
import requests
dfENSG=dfENSG.str.strip()#contains #gene_id like "ENSG00000169093"...
colS=pd.DataFrame(columns=["ID","name","disease", "datasourceScores"])
cntG=0;
for gene_id in dfENSG:
    cntG=cntG+1
    print(cntG,gene_id)
    query_string = """
      query target($ensemblId: String!){
        target(ensemblId: $ensemblId){
        id
        approvedSymbol
        associatedDiseases {
          count
          rows {
            disease {
              id
              name
            }
            datasourceScores {
              id
              score
            }
          }
        }
      }
    }
    """
    variables = {"ensemblId": gene_id}
    base_url = "https://api.platform.opentargets.org/api/v4/graphql"
    r = requests.post(base_url, json={"query": query_string, "variables": variables})
    print(r.status_code)
    if r.status_code==200:
        api_response = json.loads(r.text)
        iD=api_response['data']['target']['id']
        print(iD)
        iG=api_response['data']['target']['approvedSymbol']
        print(iG)
        aS=api_response['data']['target']['associatedDiseases']['rows']#[1]['datasourceScores'][0]['score']
        dataOIDP=pd.DataFrame(aS,columns=["disease", "datasourceScores"])
        dataOIDP["ID"]=iD
        dataOIDP["name"]=iG
        colS=pd.concat([colS,dataOIDP])
colS.to_csv("openTargetResults.csv")

```

---

<div class="post-metadata">

**Author:** ![hcornu](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/hcornu/32/716_2.png) [@hcornu](https://community.opentargets.org/u/hcornu)\
**Post date:** [27 June 2022 15:12 UTC](https://community.opentargets.org/t/batch-download-disease-association-scores/682/2 "2022-06-27T15:12:07Z")

</div>

Hi @animesh!

The API is optimised for queries about a single entity or association. For queries about multiple entities or associations, we recommend using one of our other data access points: Google BigQuery or our Data Downloads.

You can find out more information about these in our documentation: [Data and code access | Open Targets Platform Documentation](https://platform-docs.opentargets.org/data-access)

You can also take a look at some other threads on the Community, for example:

> [@Get marketed drugs for a set of targets with the data downloads](https://community.opentargets.org/t/get-marketed-drugs-for-a-set-of-targets-with-the-data-downloads/102):
>
> ``At Open Targets, we have several ways of accessing our data. If BigQuery falls short for you or you are simply comfortable using Pyspark, in this post, we illustrate what it would be like to reproduce [this analysis in BigQuery](https://community.opentargets.org/t/get-marketed-drugs-for-a-set-of-targets-with-bigquery/101) using our data files downloadable from the [Downloads page](https://platform.opentargets.org/downloads). Batch search using our data files This snippet is an example of how to extract the drugs that are on the market for a restricted list of targets. from pyspark.sql import SparkSession import pyspark.sql.functio…

> [@Returning all associations data using the Platform API](https://community.opentargets.org/t/returning-all-associations-data-using-the-platform-api/324):
>
> If I run a targets search with associatedDisease information how can I specify that I want all rows? For example this query says it has 947 associatedDiseases but not all of them are included in the rows: Write your query or mutation here query target\_disease { target(ensemblId: “ENSG00000105974”) { id approvedSymbol approvedName associatedDiseases { count rows { score disease { id name } } } } }

Or maybe another user has found a solution?

---

<div class="post-metadata">

**Author:** ![animesh](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/animesh/32/269_2.png) [@animesh](https://community.opentargets.org/u/animesh)\
**Post date:** [28 June 2022 07:30 UTC](https://community.opentargets.org/t/batch-download-disease-association-scores/682/3 "2022-06-28T07:30:26Z")

</div>

Thanks @hcornu , will check it out 👍
