Google Health Trends
| Attribute | Details |
|---|---|
| Source Name | ght |
| Data Source | Google Health Trends |
| Geographic Levels | US States and national level (US) |
| Temporal Granularity | Weekly (Epiweek) |
| Reporting Cadence | Inactive - No longer updated since 2022w36 |
| Temporal Scope Start | 1993w01 |
| License | Google Terms of Service |
This is the API documentation for accessing the Google Health Trends (ght)
endpoint of Delphi’s epidemiological data.
General topics not specific to any particular endpoint are discussed in the API overview. Such topics include: contributing, citing, and data licensing.
This data may be useful for real-time monitoring of diseases, as in:
- Herman Anthony Carneiro, Eleftherios Mylonakis. Google Trends: A Web-Based Tool for Real-Time Surveillance of Disease Outbreaks. Clinical Infectious Diseases, Volume 49, Issue 10, 15 November 2009, Pages 1557–1564.
- Abel Brodeur, Andrew E. Clark, Sarah Fleche, Nattavudh Powdthavee. COVID-19, lockdowns and well-being: Evidence from Google Trends. Journal of Public Economics, Volume 193, 2021, 104346.
- Sudhakar V. Nuti, Brian Wayda, Isuru Ranasinghe, Sisi Wang, Rachel P. Dreyer, Serene I. Chen, Karthik Murugiah. The Use of Google Trends in Health Care Research: A Systematic Review, October 2014.
Table of contents
The API
The base URL is: https://api.delphi.cmu.edu/epidata/ght/
Parameters
Required
| Parameter | Description | Type |
|---|---|---|
auth |
password | string |
epiweeks |
epiweeks (see Date Formats) | list of epiweeks |
locations |
locations | list of state codes (see Geographic Codes) and/or US |
query |
search query or topic ID (see Valid Queries) | string |
Valid Queries
Click to expand full list of valid queries
/m/0cyccinfluenza type aflu durationflu fevertreating flufever fluflu recoverybraun thermoscanoscillococcinumtreating the flucold or fluflu versus coldflu remediescontagious flutype a influenzaflu or coldduration of flucold versus fluflu coughflu headachethermoscaninfluenza incubation periodflu lastslength of fluflu stomachcold vs fluflu and fevergetting over the fluinfluenza atreatment for fluflu lengthtreatment for the fluinfluenza symptomsover the counter fluflu complicationscold and flu symptomsinfluenza incubationtreatment of fluhuman temperaturelow bodyflu contagiousrobitussin acflu how longear thermometerflu contagious periodtreat flucough flulow body temperatureexpectorantflu and coldrapid fluflu vs. coldhow to treat the fluhow long does the flu last?viral pneumoniaflu in kidstype a fluinfluenza treatmentfighting the fluflu relieftreat the fluflu medicinedangerous feverwhat is influenzatussinlow body tempflu careflu in infantsflu dizzinessfeed a feverflu vs coldflu vomitingbacterial pneumoniaflu activityflu chillsanas barbariaeflu germstylenol coldhow to get over the fluflu in childreninfluenza a and bduration of the flucold symptomsflu reportrapid flu testflu relapseget over the fluflu during pregnancyflu recovery timecure for flutamiflu and breastfeedingflu chest painflu treatmentflu nausearemedies for the flutamiflu in pregnancyside effects of tamifluhow to treat fluviral bronchitisflu how long contagiousflu remedy
Response
| Field | Description | Type |
|---|---|---|
result |
result code: 1 = success, 2 = too many results, -2 = no results | integer |
epidata |
list of results | array of objects |
epidata[].location |
location label | string |
epidata[].epiweek |
epiweek | integer |
epidata[].query |
search query | string |
epidata[].value |
search volume | float |
message |
success or error message |
string |
Example URLs
Google Health Trends for “how to get over the flu” on 2015w01 (US)
{
"result": 1,
"epidata": [
{
"location": "US",
"epiweek": 201501,
"query": "flu",
"value": 9.113
}
],
"message": "success"
}
Code Samples
Libraries are available for R and Python.
The following samples show how to import the library and fetch GHT data for “how to get over the flu” in the US for epiweek 201501.
Install the package using pip:
pip install -e "git+https://github.com/cmu-delphi/epidatpy.git#egg=epidatpy"
# Import
from epidatpy import CovidcastEpidata, EpiDataContext, EpiRange
# Fetch data
epidata = EpiDataContext()
res = epidata.ght('auth_token', ['US'], [201501], 'how to get over the flu')
print(res['result'], res['message'], len(res['epidata']))
library(epidatr)
# Fetch data
res <- pvt_ght(auth = 'auth_token', locations = 'US', epiweeks = 201501,
query = "how to get over the flu")
print(res)
Legacy Clients
We recommend using the modern client libraries mentioned above. Legacy clients are also available for Python, R, and JavaScript.
Optionally install the package using pip(env):
pip install delphi-epidata
Otherwise, place delphi_epidata.py from this repo next to your python script.
# Import
from delphi_epidata import Epidata
# Fetch data
res = Epidata.ght('auth_token', ['US'], [201501], 'how to get over the flu')
print(res['result'], res['message'], len(res['epidata']))
Place delphi_epidata.R from this repo next to your R script.
source("delphi_epidata.R")
# Fetch data
res <- Epidata$ght(auth = "auth_token", locations = list("US"), epiweeks = list(201501), query = "how to get over the flu")
print(res$message)
print(length(res$epidata))
<!-- Imports -->
<script src="delphi_epidata.js"></script>
<!-- Fetch data -->
<script>
EpidataAsync.ght('auth_token', ['US', 'CN'], EpidataAsync.range(201501, 201510), 'g').then((res) => {
console.log(res.result, res.message, res.epidata != null ? res.epidata.length : 0);
});
</script>