Link Search Menu Expand Document

COVIDcast API Clients

Dedicated COVIDcast clients are available for several languages:

These packages provide a convenient way to obtain COVIDcast data as a data frame ready to be used in further analyses. For installation instructions and examples, consult their respective webpages.

Generic Epidata Clients

More generic clients that support the entire Epidata API are available as well. Epidata clients are available for CoffeeScript, 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).

CoffeeScript (in Node.js)

# Import
{Epidata} = require('./delphi_epidata')
# Fetch data
callback = (result, message, epidata) ->
  console.log(result, message, epidata?.length)
Epidata.covidcast(callback, 'fb-survey', 'raw_cli', 'day', 'county', [20200401, Epidata.range(20200405, 20200414)], '06001')

JavaScript (in a web browser)

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

Python

Note: For COVIDcast usage, Python users should prefer the covidcast-py package; these instructions are for advanced users who want access to the entire Epidata API, including data on influenza, dengue, and norovirus.

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
# Fetch data
res = Epidata.covidcast('fb-survey', 'raw_cli', 'day', 'county', [20200401, Epidata.range(20200405, 20200414)], '06001')
print(res['result'], res['message'], len(res['epidata']))

R

Note: For COVIDcast usage, R users should prefer the covidcast package; these instructions are for advanced users who want access to the entire Epidata API, including data on influenza, dengue, and norovirus.

# Import
source('delphi_epidata.R')
# Fetch data
res <- Epidata$covidcast('fb-survey', 'raw_cli', 'day', 'county', list(20200401, Epidata$range(20200405, 20200414)), '06001')
cat(paste(res$result, res$message, length(res$epidata), "\n"))