Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Scraping XML data from ClinicalTrials API V2

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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'},

...
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading