Skip to content

Latest commit

 

History

History
126 lines (100 loc) · 3.52 KB

covidcast_meta.md

File metadata and controls

126 lines (100 loc) · 3.52 KB

About

This is the documentation of the API for accessing the Delphi's COVID-19 Surveillance Streams Metadata (covidcast_meta) data source of the Delphi's epidemiological data.

General topics not specific to any particular data source are discussed in the API overview. Such topics include: contributing, citing, and data licensing.

Delphi's COVID-19 Surveillance Streams Metadata

...

The API

The base URL is: https://delphi.cmu.edu/epidata/api.php

See this documentation for details on specifying epiweeks, dates, and lists.

Parameters

None.

Response

Field Description Type
result result code: 1 = success, 2 = too many results, -2 = no results integer
epidata list of results, one per name/geo_type pair array of objects
epidata[].data_source data souce string
epidata[].time_type temporal resolution of the signal (e.g., day, week) string
epidata[].geo_type geographic resolution (e.g. county, hrr, msa, dma, state) string
epidata[].min_time minimum time (e.g., 20200406) integer
epidata[].max_time maximum time (e.g., 20200413) integer
epidata[].num_locations number of locations integer
epidata[].min_value minimum value float
epidata[].max_value maximum value float
epidata[].mean_value mean of value float
epidata[].stdev_value standard deviation of value float
message success or error message string

Example URLs

https://delphi.cmu.edu/epidata/api.php?source=covidcast_meta

{
  "result": 1,
  "epidata": [
    {
      "data_source": "doctor-visits",
      "signal": "cli",
      "time_type": "day",
      "geo_type": "county",
      "min_time": 20200201,
      "max_time": 20200418,
      "num_locations": 1411,
      "min_value": 0,
      "max_value": 23.079023,
      "mean_value": 0.42745842933726,
      "stdev_value": 0.96461526722895
    },
    ...
  ],
  "message": "success"
}

Code Samples

Libraries 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 metadata.

CoffeeScript (in Node.js)

# Import
{Epidata} = require('./delphi_epidata')
# Fetch data
callback = (result, message, epidata) ->
  console.log(result, message, epidata?.length)
Epidata.covidcast_meta(callback)

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_meta(callback);
</script>

Python

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.covidcast_meta()
print(res['result'], res['message'], len(res['epidata']))

R

# Import
source('delphi_epidata.R')
# Fetch data
res <- Epidata$covidcast_meta()
cat(paste(res$result, res$message, length(res$epidata), "\n"))