Skip to content
API WHO
import requests
# Specify the URL endpoint of the WHO API and the parameters to retrieve the TB data
url = "http://apps.who.int/gho/athena/data/GHO/TB_burden"
params = {
"filter": "COUNTRY:*",
"format": "json",
"profile": "table",
"x-sideaxis": "YEAR",
"x-topaxis": "GHO",
"x-collapse": "true"
}
# Send a GET request to the API endpoint with the specified parameters
response = requests.get(url, params=params)
# Check if the response was successful (HTTP status code 200)
if response.status_code == 200:
# Extract the TB data from the JSON response
tb_data = response.json()
print(tb_data)
else:
print("Error:", response.status_code)