# Data source scores

**URL:** <https://community.opentargets.org/t/data-source-scores/1065>\
**Category:** GraphQL API\
**Tags:** ot-platform\
**Created:** [28 April 2023 13:08 UTC](https://community.opentargets.org/t/data-source-scores/1065 "2023-04-28T13:08:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![philge\_philip](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/philge_philip/32/413_2.png) [@philge\_philip](https://community.opentargets.org/u/philge_philip)\
**Post date:** [28 April 2023 13:08 UTC](https://community.opentargets.org/t/data-source-scores/1065/1 "2023-04-28T13:08:35Z")

</div>

Hi,

Is the data source scores accessible through API weighted?

Thanks  
Philge

---

<div class="post-metadata">

**Author:** ![irene](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/irene/32/50_2.png) [@irene](https://community.opentargets.org/u/irene)\
**Post date:** [2 May 2023 09:58 UTC](https://community.opentargets.org/t/data-source-scores/1065/2 "2023-05-02T09:58:31Z")

</div>

Hi @philge_philip,

yes, this is available through the API. We provide some examples that can be helpful in our [/api](https://platform.opentargets.org/api) page. This is how the query would look like to fetch the associations for IL22 split by data source:

```auto
query associatedDiseases {
  target(ensemblId: "ENSG00000127318") {
    id
    approvedSymbol
    associatedDiseases {
      count
      rows {
        disease {
          id
          name
        }
        datasourceScores {
          id
          score
        }
      }
    }
  }
}

```

In this case, the default weights are already applied.  
I hope this is helpful!  
Irene

---

<div class="post-metadata">

**Author:** ![Shicheng\_Guo](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/shicheng_guo/32/217_2.png) [@Shicheng\_Guo](https://community.opentargets.org/u/Shicheng_Guo)\
**Post date:** [16 July 2024 17:03 UTC](https://community.opentargets.org/t/data-source-scores/1065/3 "2024-07-16T17:03:53Z")

</div>

Thanks Irene for the great solution!!! I’d like to share the R version based on Irene’s solution

```auto
library(httr)
library(jsonlite)

# Define the query string
query_string <- '
query associatedDiseases {
  target(ensemblId: "ENSG00000127318") {
    id
    approvedSymbol
    associatedDiseases {
      count
      rows {
        disease {
          id
          name
        }
        datasourceScores {
          id
          score
        }
      }
    }
  }
}
'

# Define the URL for the API endpoint
base_url <- "https://api.platform.opentargets.org/api/v4/graphql"

# Perform the POST request
response <- POST(
  url = base_url,
  body = list(query = query_string),
  encode = "json"
)

# Check the status code of the response
if (status_code(response) == 200) {
  # Parse the response from JSON
  api_response <- content(response, as = "parsed", type = "application/json")
  
  # Print the response in a readable format
  print(toJSON(api_response, pretty = TRUE))
} else {
  # Print the error message if the request failed
  print(paste("Error:", status_code(response)))
}

```
