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:

Table of contents

  1. The API
    1. Parameters
      1. Required
        1. Valid Queries
    2. Response
  2. Example URLs
    1. Google Health Trends for “how to get over the flu” on 2015w01 (US)
  3. Code Samples
    1. Legacy Clients

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/0cycc
  • influenza type a
  • flu duration
  • flu fever
  • treating flu
  • fever flu
  • flu recovery
  • braun thermoscan
  • oscillococcinum
  • treating the flu
  • cold or flu
  • flu versus cold
  • flu remedies
  • contagious flu
  • type a influenza
  • flu or cold
  • duration of flu
  • cold versus flu
  • flu cough
  • flu headache
  • thermoscan
  • influenza incubation period
  • flu lasts
  • length of flu
  • flu stomach
  • cold vs flu
  • flu and fever
  • getting over the flu
  • influenza a
  • treatment for flu
  • flu length
  • treatment for the flu
  • influenza symptoms
  • over the counter flu
  • flu complications
  • cold and flu symptoms
  • influenza incubation
  • treatment of flu
  • human temperature
  • low body
  • flu contagious
  • robitussin ac
  • flu how long
  • ear thermometer
  • flu contagious period
  • treat flu
  • cough flu
  • low body temperature
  • expectorant
  • flu and cold
  • rapid flu
  • flu vs. cold
  • how to treat the flu
  • how long does the flu last?
  • viral pneumonia
  • flu in kids
  • type a flu
  • influenza treatment
  • fighting the flu
  • flu relief
  • treat the flu
  • flu medicine
  • dangerous fever
  • what is influenza
  • tussin
  • low body temp
  • flu care
  • flu in infants
  • flu dizziness
  • feed a fever
  • flu vs cold
  • flu vomiting
  • bacterial pneumonia
  • flu activity
  • flu chills
  • anas barbariae
  • flu germs
  • tylenol cold
  • how to get over the flu
  • flu in children
  • influenza a and b
  • duration of the flu
  • cold symptoms
  • flu report
  • rapid flu test
  • flu relapse
  • get over the flu
  • flu during pregnancy
  • flu recovery time
  • cure for flu
  • tamiflu and breastfeeding
  • flu chest pain
  • flu treatment
  • flu nausea
  • remedies for the flu
  • tamiflu in pregnancy
  • side effects of tamiflu
  • how to treat flu
  • viral bronchitis
  • flu how long contagious
  • flu 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

https://api.delphi.cmu.edu/epidata/ght/?auth=...&locations=US&epiweeks=201501&query=how%20to%20get%20over%20the%20flu

{
  "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>