Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2020 Jul 6;9(7):e16543.
doi: 10.2196/16543.

Using Application Programming Interfaces to Access Google Data for Health Research: Protocol for a Methodological Framework

Affiliations

Using Application Programming Interfaces to Access Google Data for Health Research: Protocol for a Methodological Framework

Anne Zepecki et al. JMIR Res Protoc. .

Abstract

Background: Individuals are increasingly turning to search engines like Google to obtain health information and access resources. Analysis of Google search queries offers a novel approach, which is part of the methodological toolkit for infodemiology or infoveillance researchers, to understanding population health concerns and needs in real time or near-real time. While searches predominantly have been examined with the Google Trends website tool, newer application programming interfaces (APIs) are now available to academics to draw a richer landscape of searches. These APIs allow users to write code in languages like Python to retrieve sample data directly from Google servers.

Objective: The purpose of this paper is to describe a novel protocol to determine the top queries, volume of queries, and the top sites reached by a population searching on the web for a specific health term. The protocol retrieves Google search data obtained from three Google APIs: Google Trends, Google Health Trends (also referred to as Flu Trends), and Google Custom Search.

Methods: Our protocol consisted of four steps: (1) developing a master list of top search queries for an initial search term using Google Trends, (2) gathering information on relative search volume using Google Health Trends, (3) determining the most popular sites using Google Custom Search, and (4) calculating estimated total search volume. We tested the protocol following key procedures at each step and verified its usefulness by examining search traffic on birth control in 2017 in the United States. Two separate programmers working independently achieved similar results with insignificant variation due to sample variability.

Results: We successfully tested the methodology on the initial search term birth control. We identified top search queries for birth control, of which birth control pill was the most popular and obtained the relative and estimated total search volume for the top queries: relative search volume was 0.54 for the pill, corresponding to an estimated 9.3-10.7 million searches. We used the estimates of the proportion of search activity for the top queries to arrive at a generated list of the most popular websites: for the pill, the Planned Parenthood website was the top site.

Conclusions: The proposed methodological framework demonstrates how to retrieve Google query data from multiple Google APIs and provides thorough documentation required to systematically identify search queries and websites, as well as estimate relative and total search volume of queries in real time or near-real time in specific locations and time periods. Although the protocol needs further testing, it allows researchers to replicate the steps and shows promise in advancing our understanding of population-level health concerns.

International registered report identifier (irrid): RR1-10.2196/16543.

Keywords: APIs; Google; Google Trends; abortion; birth control; infodemic; infodemiology; infoveillance; reproductive health; search data.

PubMed Disclaimer

Conflict of interest statement

Conflicts of Interest: None declared.

Figures

Figure 1
Figure 1
Creation of a master list as visualized in Python for birth control in the United States, Mississippi, and Louisiana in 2017.
Figure 2
Figure 2
Top queries for birth control in the United States in 2017. Single circles in the graph represent search queries, whereas a double circle indicates an overarching topic coded for internal organizational purposes within the Google application programming interface (API) and is not included in the list of top queries. Numbers in parentheses indicate how relation of query to the provided initial search term. iud: intrauterine device.
Figure 3
Figure 3
Relative search volume for birth control in the United States in 2017. IUD: intrauterine device.
Figure 4
Figure 4
Estimated total search volume (range) and relative search volume (within parentheses) for birth control in the United States in 2017. IUD: intrauterine device.

Similar articles

Cited by

References

    1. Purcell K, Brenner J, Rainie L. Search Engine Use 2012. Washington, DC: Pew Internet & American Life Project; 2012. Mar 09, [2019-08-15]. https://www.pewinternet.org/wp-content/uploads/sites/9/media/Files/Repor....
    1. Stephens-Davidowitz S. Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are. New York, NY: HarperCollins Publishers; 2017.
    1. Google Trends. [2020-01-27]. https://trends.google.com/trends/
    1. Ginsberg J, Mohebbi MH, Patel RS, Brammer L, Smolinski MS, Brilliant L. Detecting influenza epidemics using search engine query data. Nature. 2009 Feb 19;457(7232):1012–1014. doi: 10.1038/nature07634. - DOI - PubMed
    1. Klembczyk JJ, Jalalpour M, Levin S, Washington RE, Pines JM, Rothman RE, Dugas AF. Google Flu Trends spatial variability validated against emergency department influenza-related visits. J Med Internet Res. 2016 Jun 28;18(6):e175. doi: 10.2196/jmir.5585. https://www.jmir.org/2016/6/e175/ - DOI - PMC - PubMed

LinkOut - more resources