Skip to content

Commit 41f85d2

Browse files
authored
Merge pull request #550 from cmu-delphi/sgratzl/docs_covidcast2.0
update docs for flask server
2 parents 448fd45 + f27c12f commit 41f85d2

33 files changed

+158
-329
lines changed

docs/api/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Please note that our `endpoint` parameters were previously referenced as `source
7070

7171
# The API
7272

73-
The base URL is: https://delphi.cmu.edu/epidata/api.php
73+
The base URL is: https://delphi.cmu.edu/epidata/
7474

7575
## Specifying Epiweeks, Dates, and Lists
7676

@@ -154,7 +154,7 @@ The parameters available for each source are documented in each linked source-sp
154154
# Example URLs
155155

156156
### FluView on 2015w01 (national)
157-
https://delphi.cmu.edu/epidata/api.php?endpoint=fluview&regions=nat&epiweeks=201501
157+
https://delphi.cmu.edu/epidata/fluview/?regions=nat&epiweeks=201501
158158

159159
```json
160160
{
@@ -184,7 +184,7 @@ https://delphi.cmu.edu/epidata/api.php?endpoint=fluview&regions=nat&epiweeks=201
184184
```
185185

186186
### Wikipedia Access article "influenza" on 2020w01
187-
https://delphi.cmu.edu/epidata/api.php?endpoint=wiki&language=en&articles=influenza&epiweeks=202001
187+
https://delphi.cmu.edu/epidata/wiki/?language=en&articles=influenza&epiweeks=202001
188188

189189
```json
190190
{

docs/api/afhsb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ General topics not specific to any particular endpoint are discussed in the
1919

2020
# The API
2121

22-
The base URL is: https://delphi.cmu.edu/epidata/api.php
22+
The base URL is: https://delphi.cmu.edu/epidata/afhsb/
2323

2424
See [this documentation](README.md) for details on specifying epiweeks, dates, and lists.
2525

docs/api/cdc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ General topics not specific to any particular endpoint are discussed in the
1919

2020
# The API
2121

22-
The base URL is: https://delphi.cmu.edu/epidata/api.php
22+
The base URL is: https://delphi.cmu.edu/epidata/cdc/
2323

2424
See [this documentation](README.md) for details on specifying epiweeks, dates, and lists.
2525

docs/api/client_libraries.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ nav_order: 1
77
# Epidata API Client Libraries.
88

99
Epidata clients are available for
10-
[CoffeeScript](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.coffee),
1110
[JavaScript](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.js),
1211
[Python](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.py),
1312
and
@@ -18,29 +17,16 @@ Surveillance Streams from Facebook Survey CLI for county 06001 and days
1817

1918
For anyone looking for COVIDCast data, please visit our [COVIDCast Libraries](covidcast_clients.md).
2019

21-
### CoffeeScript (in Node.js)
22-
23-
````coffeescript
24-
# Import
25-
{Epidata} = require('./delphi_epidata')
26-
# Fetch data
27-
callback = (result, message, epidata) ->
28-
console.log(result, message, epidata?.length)
29-
Epidata.covidcast(callback, 'fb-survey', 'smoothed_cli', 'day', 'county', [20200401, Epidata.range(20200405, 20200414)], '06001')
30-
````
31-
3220
### JavaScript (in a web browser)
3321

3422
````html
3523
<!-- Imports -->
36-
<script src="jquery.js"></script>
3724
<script src="delphi_epidata.js"></script>
3825
<!-- Fetch data -->
3926
<script>
40-
var callback = function(result, message, epidata) {
41-
console.log(result, message, epidata != null ? epidata.length : void 0);
42-
};
43-
Epidata.covidcast(callback, 'fb-survey', 'smoothed_cli', 'day', 'county', [20200401, Epidata.range(20200405, 20200414)], '06001');
27+
EpidataAsync.covidcast('fb-survey', 'smoothed_cli', 'day', 'county', [20200401, Epidata.range(20200405, 20200414)], '06001').then((res) => {
28+
console.log(res.result, res.message, res.epidata != null ? res.epidata.length : 0);
29+
});
4430
</script>
4531
````
4632

docs/api/covid_hosp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ parent: Epidata API (Other Diseases)
66
# COVID-19 Hospitalization by State
77

88
This data source is a mirror of the "COVID-19 Reported Patient Impact and
9-
Hospital Capacity by State Timeseries" and "COVID-19 Reported Patient Impact and
9+
Hospital Capacity by State Timeseries" and "COVID-19 Reported Patient Impact and
1010
Hospital Capacity by State" datasets provided by the US Department of
1111
Health & Human Services via healthdata.gov. The latter provides more frequent updates,
1212
so it is combined with the former to create a single dataset which is as recent as possible.
1313

1414
For more information, see the
1515
[official description and data dictionary at healthdata.gov](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/g62h-syeh)
16-
for "COVID-19 Reported Patient Impact and Hospital Capacity by State Timeseries,"
16+
for "COVID-19 Reported Patient Impact and Hospital Capacity by State Timeseries,"
1717
as well as the [official description](https://healthdata.gov/dataset/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/6xf2-c3ie)
1818
for "COVID-19 Reported Patient Impact and Hospital Capacity by State."
1919

@@ -72,7 +72,7 @@ If `issues` is not specified, then the most recent issue is used by default.
7272
# Example URLs
7373

7474
### MA on 2020-05-10 (per most recent issue)
75-
https://delphi.cmu.edu/epidata/api.php?endpoint=covid_hosp&states=MA&dates=20200510
75+
https://delphi.cmu.edu/epidata/covid_hosp/?states=MA&dates=20200510
7676

7777
```json
7878
{
@@ -143,7 +143,7 @@ https://delphi.cmu.edu/epidata/api.php?endpoint=covid_hosp&states=MA&dates=20200
143143

144144
# Code Samples
145145

146-
Libraries are available for [CoffeeScript](../../src/client/delphi_epidata.coffee), [JavaScript](../../src/client/delphi_epidata.js), [Python](../../src/client/delphi_epidata.py), and [R](../../src/client/delphi_epidata.R).
146+
Libraries are available for [JavaScript](../../src/client/delphi_epidata.js), [Python](../../src/client/delphi_epidata.py), and [R](../../src/client/delphi_epidata.R).
147147
The following sample shows how to import the library and fetch MA on 2020-05-10
148148
(per most recent issue).
149149

docs/api/covid_hosp_facility.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ HHS. New versions are expected to be published roughly weekly.
3030

3131
# The API
3232

33-
The base URL is: https://delphi.cmu.edu/epidata/api.php
33+
The base URL is: https://delphi.cmu.edu/epidata/covid_hosp_facility/
3434

3535
See [this documentation](README.md) for details on specifying locations and dates.
3636

@@ -80,7 +80,7 @@ has been renamed here for clarity.
8080
# Example URLs
8181

8282
### Moses Taylor Hospital (Scranton, PA) on the first collection week of December 2020 (per most recent issue)
83-
https://delphi.cmu.edu/epidata/api.php?source=covid_hosp_facility&hospital_pks=390119&collection_weeks=20201201-20201207
83+
https://delphi.cmu.edu/epidata/covid_hosp_facility/?hospital_pks=390119&collection_weeks=20201201-20201207
8484

8585
```json
8686
{
@@ -190,7 +190,7 @@ https://delphi.cmu.edu/epidata/api.php?source=covid_hosp_facility&hospital_pks=3
190190

191191
# Code Samples
192192

193-
Libraries are available for [CoffeeScript](../../src/client/delphi_epidata.coffee), [JavaScript](../../src/client/delphi_epidata.js), [Python](../../src/client/delphi_epidata.py), and [R](../../src/client/delphi_epidata.R).
193+
Libraries are available for [JavaScript](../../src/client/delphi_epidata.js), [Python](../../src/client/delphi_epidata.py), and [R](../../src/client/delphi_epidata.R).
194194
The following sample shows how to import the library and fetch Moses Taylor
195195
Hospital (Scranton, PA) on the first collection week of December 2020 (per most
196196
recent issue).

docs/api/covid_hosp_facility_lookup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This data source provides metadata about healthcare facilities in the US.
3030

3131
# The API
3232

33-
The base URL is: https://delphi.cmu.edu/epidata/api.php?source=covid_hosp_facility_lookup
33+
The base URL is: https://delphi.cmu.edu/epidata/covid_hosp_facility_lookup/
3434

3535
See [this documentation](README.md) for details on specifying locations and dates.
3636

@@ -61,7 +61,7 @@ supported.
6161
# Example URLs
6262

6363
### Lookup facilities in the city of Southlake (TX)
64-
https://delphi.cmu.edu/epidata/api.php?source=covid_hosp_facility_lookup&city=southlake
64+
https://delphi.cmu.edu/epidata/covid_hosp_facility_lookup/?city=southlake
6565

6666
```json
6767
{
@@ -99,7 +99,7 @@ https://delphi.cmu.edu/epidata/api.php?source=covid_hosp_facility_lookup&city=so
9999

100100
# Code Samples
101101

102-
Libraries are available for [CoffeeScript](../../src/client/delphi_epidata.coffee), [JavaScript](../../src/client/delphi_epidata.js), [Python](../../src/client/delphi_epidata.py), and [R](../../src/client/delphi_epidata.R).
102+
Libraries are available for [JavaScript](../../src/client/delphi_epidata.js), [Python](../../src/client/delphi_epidata.py), and [R](../../src/client/delphi_epidata.R).
103103
The following sample shows how to import the library and fetch facilities in
104104
the city of Southlake (TX).
105105

docs/api/covidcast.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ nav_order: 1
99
This is the documentation for accessing Delphi's COVID-19 indicators via the `covidcast` endpoint of [Delphi](https://delphi.cmu.edu/)'s
1010
epidemiological data API. This API provides data on the spread and impact of the COVID-19 pandemic across the United States, most of which is available at the
1111
county level and updated daily. This data powers our public [COVIDcast
12-
map](https://covidcast.cmu.edu/) which includes testing, cases, and death data,
12+
map](https://delphi.cmu.edu/covidcast/) which includes testing, cases, and death data,
1313
as well as unique healthcare and survey data Delphi acquires through its
1414
partners. The API allows users to select specific signals and download data for
1515
selected geographical areas---counties, states, metropolitan statistical areas,
@@ -43,7 +43,7 @@ in the [API overview](README.md).
4343

4444
## Accessing the Data
4545

46-
Our [COVIDcast site](https://covidcast.cmu.edu) provides an interactive
46+
Our [COVIDcast site](https://delphi.cmu.edu/covidcast/) provides an interactive
4747
visualization of a select set of the data signals available in the COVIDcast
4848
API, and provides a data export feature to download any data range as a
4949
CSV file.
@@ -92,8 +92,7 @@ sources and signals.
9292
## Constructing API Queries
9393

9494
The COVIDcast API is based on HTTP GET queries and returns data in JSON form.
95-
The base URL is `https://api.covidcast.cmu.edu/epidata/api.php`. The covidcast
96-
endpoint is `https://api.covidcast.cmu.edu/epidata/api.php?endpoint=covidcast`.
95+
The base URL is `https://api.covidcast.cmu.edu/epidata/covidcast/`.
9796

9897
See [this documentation](README.md) for details on specifying epiweeks, dates,
9998
and lists.
@@ -139,10 +138,10 @@ Use cases:
139138
do not include any updates that became available after June 1, use
140139
`as_of=20200601`.
141140
* To retrieve only data that was published or updated on June 1, and exclude
142-
records whose most recent update occured earlier than June 1, use
141+
records whose most recent update occurred earlier than June 1, use
143142
`issues=20200601`.
144143
* To retrieve all data that was published between May 1 and June 1, and exclude
145-
records whose most recent update occured earlier than May 1, use
144+
records whose most recent update occurred earlier than May 1, use
146145
`issues=20200501-20200601`. The results will include all matching issues for
147146
each `time_value`, not just the most recent.
148147
* To retrieve only data that was published or updated exactly 3 days after the
@@ -160,11 +159,15 @@ require knowing when we last confirmed an unchanged value, please get in touch.
160159
| --- | --- | --- |
161160
| `result` | result code: 1 = success, 2 = too many results, -2 = no results | integer |
162161
| `epidata` | list of results, 1 per geo/time pair | array of objects |
162+
| `epidata[].source` | selected `data_source` | string |
163+
| `epidata[].signal` | selected `signal` | string |
164+
| `epidata[].geo_type` | selected `geo_type` | string |
163165
| `epidata[].geo_value` | location code, depending on `geo_type` | string |
166+
| `epidata[].time_type` | selected `time_type` | string |
164167
| `epidata[].time_value` | time unit (e.g. date) over which underlying events happened (see [date coding details](covidcast_times.md)) | integer |
165-
| `epidata[].direction` | trend classifier (+1 -> increasing, 0 -> steady or not determined, -1 -> decreasing) | integer |
166168
| `epidata[].value` | value (statistic) derived from the underlying data source | float |
167169
| `epidata[].stderr` | approximate standard error of the statistic with respect to its sampling distribution, `null` when not applicable | float |
170+
| `epidata[].direction` | trend classifier (+1 -> increasing, 0 -> steady or not determined, -1 -> decreasing) | integer |
168171
| `epidata[].sample_size` | number of "data points" used in computing the statistic, `null` when not applicable | float |
169172
| `epidata[].issue` | time unit (e.g. date) when this statistic was published | integer |
170173
| `epidata[].lag` | time delta (e.g. days) between when the underlying events happened and when this statistic was published | integer |
@@ -179,11 +182,32 @@ returned, but not all of the results you requested. API clients should check the
179182
results code and consider breaking up requests for e.g. large time intervals into multiple
180183
API calls.
181184

185+
### Alternative Response Formats
186+
187+
In addition to the default EpiData Response format, users can customize the response format using the `format=` parameter.
188+
189+
#### JSON List Response
190+
191+
When setting the format parameter to `format=json`, it will return a plain list of the `epidata` response objects without the `result` and `message` wrapper. The status of the query is returned via HTTP status codes. For example, a status code of 200 means the query succeeded, while 400 indicates that the query has a missing, misspelled, or otherwise invalid parameter. For all status codes != 200, the returned JSON includes details about what part of the query couldn't be interpreted.
192+
193+
#### CSV File Response
194+
195+
When setting the format parameter to `format=csv`, it will return a CSV file with same columns as the response objects. HTTP status codes are used to communicate success/failure, similar to `format=json`.
196+
197+
#### JSON New Lines Response
198+
199+
When setting the format parameter to `format=jsonl`, it will return each row as an JSON file separated by a single new line character `\n`. This format is useful for incremental streaming of the results. Similar to the JSON list response status codes are used.
200+
201+
### Limit Returned Fields
202+
203+
The `fields` parameter can be used to limit which fields are included in each returned row. This is useful in web applications to reduce the amount of data transmitted. The `fields` parameter supports two syntaxes: allow and deny. Using allowlist syntax, only the listed fields will be returned. For example, `fields=geo_value,value` will drop all fields from the returned data except for `geo_value` and `value`. To use denylist syntax instead, prefix each field name with a dash (-) to exclude it from the results. For example, `fields=-direction` will include all fields in the returned data except for the `direction` field.
204+
205+
182206
## Example URLs
183207

184208
### Facebook Survey CLI on 2020-04-06 to 2010-04-10 (county 06001)
185209

186-
https://api.covidcast.cmu.edu/epidata/api.php?endpoint=covidcast&data_source=fb-survey&signal=smoothed_cli&time_type=day&geo_type=county&time_values=20200406-20200410&geo_value=06001
210+
https://api.covidcast.cmu.edu/epidata/covidcast/?data_source=fb-survey&signal=smoothed_cli&time_type=day&geo_type=county&time_values=20200406-20200410&geo_value=06001
187211

188212
```json
189213
{
@@ -205,7 +229,7 @@ https://api.covidcast.cmu.edu/epidata/api.php?endpoint=covidcast&data_source=fb-
205229

206230
### Facebook Survey CLI on 2020-04-06 (all counties)
207231

208-
https://api.covidcast.cmu.edu/epidata/api.php?endpoint=covidcast&data_source=fb-survey&signal=smoothed_cli&time_type=day&geo_type=county&time_values=20200406&geo_value=*
232+
https://api.covidcast.cmu.edu/epidata/covidcast/?data_source=fb-survey&signal=smoothed_cli&time_type=day&geo_type=county&time_values=20200406&geo_value=*
209233

210234
```json
211235
{

docs/api/covidcast_meta.md

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ geographic levels at which they are reported.
1313

1414
## The API
1515

16-
The base URL is: https://api.covidcast.cmu.edu/epidata/api.php
16+
The base URL is: https://api.covidcast.cmu.edu/epidata/covidcast_meta/
1717

1818
See [this documentation](README.md) for details on specifying epiweeks, dates, and lists.
1919

@@ -45,7 +45,7 @@ None required.
4545

4646
## Example URLs
4747

48-
https://api.covidcast.cmu.edu/epidata/api.php?endpoint=covidcast_meta
48+
https://api.covidcast.cmu.edu/epidata/covidcast_meta/
4949

5050
```json
5151
{
@@ -73,32 +73,19 @@ https://api.covidcast.cmu.edu/epidata/api.php?endpoint=covidcast_meta
7373

7474
## Code Samples
7575

76-
Libraries are available for [CoffeeScript](../../src/client/delphi_epidata.coffee), [JavaScript](../../src/client/delphi_epidata.js), [Python](../../src/client/delphi_epidata.py), and [R](../../src/client/delphi_epidata.R).
76+
Libraries are available for [JavaScript](../../src/client/delphi_epidata.js), [Python](../../src/client/delphi_epidata.py), and [R](../../src/client/delphi_epidata.R).
7777
The following samples show how to import the library and fetch Delphi's COVID-19 Surveillance Streams metadata.
7878

79-
### CoffeeScript (in Node.js)
80-
81-
````coffeescript
82-
# Import
83-
{Epidata} = require('./delphi_epidata')
84-
# Fetch data
85-
callback = (result, message, epidata) ->
86-
console.log(result, message, epidata?.length)
87-
Epidata.covidcast_meta(callback)
88-
````
89-
9079
### JavaScript (in a web browser)
9180

9281
````html
9382
<!-- Imports -->
94-
<script src="jquery.js"></script>
9583
<script src="delphi_epidata.js"></script>
9684
<!-- Fetch data -->
9785
<script>
98-
var callback = function(result, message, epidata) {
99-
console.log(result, message, epidata != null ? epidata.length : void 0);
100-
};
101-
Epidata.covidcast_meta(callback);
86+
EpidataAsync.covidcast_meta().then((res) => {
87+
console.log(res.result, res.message, res.epidata != null ? res.epidata.length : 0);
88+
});
10289
</script>
10390
````
10491

docs/api/delphi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ General topics not specific to any particular endpoint are discussed in the
1919

2020
# The API
2121

22-
The base URL is: https://delphi.cmu.edu/epidata/api.php
22+
The base URL is: https://delphi.cmu.edu/epidata/delphi/
2323

2424
See [this documentation](README.md) for details on specifying epiweeks, dates, and lists.
2525

@@ -58,7 +58,7 @@ See [this documentation](README.md) for details on specifying epiweeks, dates, a
5858
# Example URLs
5959

6060
### Delphi on 2020w01 (EC)
61-
https://delphi.cmu.edu/epidata/api.php?endpoint=delphi&system=ec&epiweek=202001
61+
https://delphi.cmu.edu/epidata/delphi/?system=ec&epiweek=202001
6262

6363
```json
6464
{

docs/api/dengue_nowcast.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ General topics not specific to any particular endpoint are discussed in the
2020

2121
# The API
2222

23-
The base URL is: https://delphi.cmu.edu/epidata/api.php
23+
The base URL is: https://delphi.cmu.edu/epidata/dengue_nowcast/
2424

2525
See [this documentation](README.md) for details on specifying epiweeks, dates, and lists.
2626

docs/api/dengue_sensors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ General topics not specific to any particular endpoint are discussed in the
2020

2121
# The API
2222

23-
The base URL is: https://delphi.cmu.edu/epidata/api.php
23+
The base URL is: https://delphi.cmu.edu/epidata/dengue_sensors/
2424

2525
See [this documentation](README.md) for details on specifying epiweeks, dates, and lists.
2626

docs/api/ecdc_ili.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ECDC ILI data from ECDC website. ... <!-- TODO -->
1919

2020
# The API
2121

22-
The base URL is: https://delphi.cmu.edu/epidata/api.php
22+
The base URL is: https://delphi.cmu.edu/epidata/ecdc_ili/
2323

2424
See [this documentation](README.md) for details on specifying epiweeks, dates, and lists.
2525

0 commit comments

Comments
 (0)