Issue
I am trying to reproduce the results of these questions:
Scraping xml data from clinicaltrials and extracting xml data from clinicaltrials using the new ClinicalTrials V2 API. According to it, /api/query/full_studies
should be replaced with /api/v2/studies
However, when I try it, I received 0 results
import requests
import pandas as pd
def download(keyword):
#base_url = "https://clinicaltrials.gov/api/query/full_studies"
base_url = "https://clinicaltrials.gov/api/v2/studies"
params = {
"expr": palabra_clave,
"min_rnk": 1,
"max_rnk": 40,
"fmt": "json"
}
response = requests.get(base_url, params=params)
if response.status_code == 200:
return response.json()
else:
return None
result = download("diabetes")
result
Solution
According to this page you need to change name of parameters too:
import pandas as pd
import requests
def download(keyword):
base_url = "https://clinicaltrials.gov/api/v2/studies"
params = {"query.term": keyword, "format": "json"}
response = requests.get(base_url, params=params)
if response.status_code == 200:
return response.json()
else:
return None
result = download("diabetes")
print(result)
Prints:
{'studies': [{'protocolSection': {'identificationModule': {'nctId': 'NCT04617405', 'orgStudyIdInfo': {'id': 'PADME1'}, 'organization': {'fullName': 'University of Aarhus', 'class': 'OTHER'}, 'briefTitle': 'Hormonal and Inflammatory Changes During Pregnancy in Women With Glucose Metabolic Disorders.', 'officialTitle': 'Hormonal and Inflammatory Changes During Pregnancy in Women With Glucose Metabolic Disorders.', 'acronym': 'HI-MET'}, 'statusModule': {'statusVerifiedDate': '2022-11', 'overallStatus': 'RECRUITING', 'expandedAccessInfo': {'hasExpandedAccess': False}, 'startDateStruct': {'date': '2021-01-11', 'type': 'ACTUAL'}, 'primaryCompletionDateStruct': {'date': '2023-12', 'type': 'ESTIMATED'}, 'completionDateStruct': {'date': '2023-12', 'type': 'ESTIMATED'},
...
Answered By - Andrej Kesely
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.