0
disease_trait = input("Enter disease trait to search: ")
url = "https://www.ebi.ac.uk/gwas/rest/api/studies"
query_params = {"diseaseTrait": disease_trait, "size": 200}

headers = {"Accept": "application/json"}
response = requests.get(url, params=query_params, headers=headers)

if response.status_code == 200:
    data= response.json()["_embedded"]["studies"]
    # Use the content variable as needed
else:
    print(f"Error retrieving content: {response.content}")

I try to run GWAS api by using python to get accession id, ancestral area,initial sample size informations.When I run the code you see, no matter what disease I search for, the same information always comes up. I can't get specific results for the disease.

I try to modify the code

import requests
import json
phenotype = “body mass index”
url = f”https://www.ebi.ac.uk/gwas/rest/api/associations/phenotype/{phenotype}?projection=association”
response = requests.get(url)
data = json.loads(response.text)
print(data)

but it gives error. I also try other url but they all gave errors.

BScpj
  • 15
  • 3

0 Answers0