Epidata API Client Libraries

For anyone looking for COVIDCast data, please visit our COVIDCast Libraries.

We are currently working on fully-featured Epidata clients for R and Python. They are not ready for release yet, but you can track our development progress and help us test them out at:

In the meantime, minimalist Epidata clients remain available for JavaScript, Python, and R. The following samples show how to import the library and fetch Delphi’s COVID-19 Surveillance Streams from Facebook Survey CLI for county 06001 and days 20200401 and 20200405-20200414 (11 days total).

JavaScript (in a web browser)

The minimalist JavaScript client does not currently support API keys. If you need API key support in JavaScript, contact delphi-support+privacy@andrew.cmu.edu.

<!-- Imports -->
<script src="delphi_epidata.js"></script>
<!-- Fetch data -->
<script>
  EpidataAsync.covidcast('fb-survey', 'smoothed_cli', 'day', 'county', [20200401, EpidataAsync.range(20200405, 20200414)], '06001').then((res) => {
    console.log(res.result, res.message, res.epidata != null ? res.epidata.length : 0);
  });
</script>

Python

Optionally install the package from PyPI using pip(env):

pip install delphi-epidata

Otherwise, place delphi_epidata.py in the same directory as your Python script.

# Import
from delphi_epidata import Epidata
# [Optional] configure your API key, if desired
#Epidata.auth = ('epidata', <your API key>)
# Fetch data
res = Epidata.covidcast('fb-survey', 'smoothed_cli', 'day', 'county', [20200401, Epidata.range(20200405, 20200414)], '06001')
print(res['result'], res['message'], len(res['epidata']))

R

# [Optional] configure your API key, if desired
#option('epidata.auth', <your API key>)
# Import
source('delphi_epidata.R')
# Fetch data
res <- Epidata$covidcast('fb-survey', 'smoothed_cli', 'day', 'county', list(20200401, Epidata$range(20200405, 20200414)), '06001')
cat(paste(res$result, res$message, length(res$epidata), "\n"))