Skip to content

Commit 54ee545

Browse files
committed
ex direct from database, title, * notes, Renviron
the delphi endpoint's fetch_classic output has been modified to just names, since the full output is too long Secrets moved to the .Reviron file. Duplicate copy of Google Health Trends removed various references fixed
1 parent 5d8cf0c commit 54ee545

File tree

1 file changed

+38
-43
lines changed

1 file changed

+38
-43
lines changed

vignettes/endpoints.Rmd

+38-43
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: "COVIDcast API Client"
2+
title: "Endpoint Examples"
33
author: "Delphi Group"
44
date: "`r Sys.Date()`"
55
output: rmarkdown::html_vignette
66
vignette: >
7-
%\VignetteIndexEntry{COVIDcast API Client}
7+
%\VignetteIndexEntry{Endpoint Examples}
88
%\VignetteEngine{knitr::rmarkdown}
99
\usepackage[utf8]{inputenc}
1010
---
@@ -23,6 +23,7 @@ library("dplyr")
2323
```
2424

2525
The API endpoints, organized by data sources.
26+
Some endpoints allow for the use of `*` to access data at all locations. Check the help for a given endpoint to see if it supports `*`.
2627

2728
## COVIDcast Main Endpoint
2829

@@ -59,6 +60,17 @@ covidcast(
5960
) %>% fetch_tbl()
6061
```
6162
County geo_values are [FIPS codes](https://en.wikipedia.org/wiki/List_of_United_States_FIPS_codes_by_county) and are discussed more here: <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html>. The example above is for Orange County, California.
63+
Since `covidcast` is an endpoint which supports `*`, here is an example of its use:
64+
```{r}
65+
covidcast(
66+
data_source = "fb-survey",
67+
signals = "smoothed_accept_covid_vaccine",
68+
geo_type = "county",
69+
time_type = "day",
70+
time_values = epirange(20201221, 20201225),
71+
geo_values = "*"
72+
) %>% fetch_tbl()
73+
```
6274

6375
## Other Covid Endpoints
6476

@@ -121,10 +133,10 @@ Function reference: <https://cmu-delphi.github.io/epidatr/reference/delphi.html>
121133
Example call:
122134

123135
```{r}
124-
delphi(system = "ec", epiweek = 201501) %>% fetch_classic()
136+
del <- delphi(system = "ec", epiweek = 201501) %>% fetch_classic()
137+
names(del$epidata$forecast)
125138
```
126139

127-
128140
### FluSurv hospitalization data
129141

130142
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/flusurv.html>
@@ -170,8 +182,6 @@ Example call:
170182
fluview_meta() %>% fetch_tbl()
171183
```
172184

173-
TODO broken?
174-
175185
### Google Flu Trends data
176186
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/gft.html>
177187

@@ -186,9 +196,9 @@ API docs: <https://cmu-delphi.github.io/delphi-epidata/api/kcdc_ili.html>
186196

187197
Function reference: <https://cmu-delphi.github.io/epidatr/reference/kcdc_ili.html>
188198

189-
kcdc_ili(regions = "01", epiweeks = epirange(199001, 202301)) %>% fetch_tbl()
190-
TODO example is broken
191-
199+
```{r}
200+
kcdc_ili(regions = "ROK", epiweeks = 200436) %>% fetch_tbl()
201+
```
192202
### NIDSS Flu
193203
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/nidss_flu.html>
194204

@@ -237,9 +247,8 @@ API docs: <https://cmu-delphi.github.io/delphi-epidata/api/paho_dengue.html>
237247
Function reference: <https://cmu-delphi.github.io/epidatr/reference/paho_dengue.html>
238248

239249
```{r, eval=FALSE}
240-
paho_dengue(regions = "1", epiweeks = epirange(200201, 202319)) %>% fetch_tbl()
250+
paho_dengue(regions = "ca", epiweeks = epirange(200201, 202319)) %>% fetch_tbl()
241251
```
242-
TODO this is disallowed (http 401)
243252

244253
## Other Endpoints
245254
### Wikipedia Access
@@ -252,23 +261,20 @@ wiki(language = "en", articles = "influenza", epiweeks = epirange(202001, 202319
252261
```
253262
# Private methods
254263

255-
These require private access keys to use. To actually run these locally, if you have stored these secrets in `secrets.R` in the root directory of this project, first run
256-
```{r, eval=FALSE}
257-
source("../secrets.R")
258-
```
259-
Each source has it's own auth that it needs, which is the first argument.
264+
These require private access keys to use. To actually run these locally, you will need to store these secrets in your `.Reviron` file, or set them as environmental variables.
260265

261266
### AFHSB metadata
262267

263-
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/ght.html>
268+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/meta_afhsb.html>
264269

265-
Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_ght.html>
270+
Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_meta_afhsb.html>
266271

267272
Example call:
268273
```{r, eval=FALSE}
269-
pvt_afhsb_meta(auth = SECRET_API_AUTH_AFHSB) %>% fetch_classic()
274+
pvt_meta_afhsb(auth = Sys.getenv("SECRET_API_AUTH_AFHSB")) %>% fetch_classic()
270275
```
271276
TODO internal server error
277+
not on the server I was given access to
272278

273279
### AFHSB data
274280

@@ -279,10 +285,11 @@ Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_afhsb.ht
279285
Example call:
280286

281287
```{r, eval=FALSE}
282-
pvt_afhsb(auth = SECRET_API_AUTH_AFHSB, locations = "mn", epiweeks = epirange(202002, 202110), flu_types = "flu1") %>% fetch_tbl()
288+
pvt_afhsb(auth = Sys.getenv("SECRET_API_AUTH_AFHSB"), locations = "mn", epiweeks = epirange(202002, 202110), flu_types = "flu1") %>% fetch_tbl()
283289
```
284290

285291
TODO 500 internal server error
292+
not on the server I was given access to
286293

287294
### CDC
288295

@@ -292,7 +299,7 @@ Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_cdc.html
292299

293300
Example call:
294301
```{r, eval=FALSE}
295-
pvt_cdc(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl()
302+
pvt_cdc(auth = Sys.getenv("SECRET_API_AUTH_CDC"), epiweeks = epirange(202003, 202304), locations = "ma") %>% fetch_tbl()
296303
```
297304

298305
### Dengue Digital Surveillance Sensors
@@ -304,9 +311,8 @@ Function reference: <https://cmu-delphi.github.io/epidatr/reference/dengue_senso
304311
Example call:
305312

306313
```{r, eval=FALSE}
307-
pvt_dengue_sensors(auth = SECRET_API_SENSORS, names = ) %>% fetch_tbl()
314+
pvt_dengue_sensors(auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "ght", locations = "ag", epiweeks = epirange(201404, 202004)) %>% fetch_tbl()
308315
```
309-
TODO not in the reference docs either...
310316

311317
### Google Health Trends
312318

@@ -316,18 +322,7 @@ Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_ght.html
316322

317323
Example call:
318324
```{r, eval=FALSE}
319-
pvt_ght(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl()
320-
```
321-
322-
### Google Health Trends
323-
324-
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/ght.html>
325-
326-
Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_ght.html>
327-
328-
Example call:
329-
```{r, eval=FALSE}
330-
pvt_ght(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl()
325+
pvt_ght(auth = Sys.getenv("SECRET_API_AUTH_GHT"), epiweeks = epirange(199301, 202304), locations = "ma", query = "how to get over the flu") %>% fetch_tbl()
331326
```
332327

333328
### NoroSTAT metadata
@@ -338,18 +333,18 @@ Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_meta_nor
338333

339334
Example call:
340335
```{r, eval=FALSE}
341-
pvt_meta_norostat(auth = SECRET_API_AUTH_NOROSTAT) %>% fetch_classic()
336+
pvt_meta_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT")) %>% fetch_classic()
342337
```
343338

344-
### NoroSTAT NoroSTAT data
339+
### NoroSTAT data
345340

346341
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/norostat.html>
347342

348343
Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_norostat.html>
349344

350345
Example call:
351346
```{r, eval=FALSE}
352-
pvt_norostat(auth = SECRET_API_AUTH_NOROSTAT, locations = "mn", epiweeks = epirange(201301, 202105)) %>% fetch_tbl()
347+
pvt_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"), locations = "ma", epiweeks = epirange(199001, 202105)) %>% fetch_classic()
353348
```
354349
TODO can't seem to get a relevant sample, the example in the reference section is borked.
355350

@@ -361,7 +356,7 @@ Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_quidel.h
361356

362357
Example call:
363358
```{r, eval=FALSE}
364-
pvt_quidel(auth = SECRET_API_AUTH_QUIDEL, locations = "hhs1", epiweeks = epirange(200301, 202105)) %>% fetch_tbl()
359+
pvt_quidel(auth = Sys.getenv("SECRET_API_AUTH_QUIDEL"), locations = "hhs1", epiweeks = epirange(200301, 202105)) %>% fetch_tbl()
365360
```
366361

367362
### Sensors
@@ -372,16 +367,16 @@ Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_sensors.
372367

373368
Example call:
374369
```{r, eval=FALSE}
375-
pvt_sensors(auth = SECRET_API_AUTH_SENSORS, names = "sar3", locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl()
370+
pvt_sensors(auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "sar3", locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl()
376371
```
377372

378373
### Twitter
379374

380-
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/sensors.html>
375+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/twitter.html>
381376

382-
Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_sensors.html>
377+
Function reference: <https://cmu-delphi.github.io/epidatr/reference/pvt_twitter.html>
383378

384379
Example call:
385380
```{r, eval=FALSE}
386-
pvt_twitter(auth = SECRET_API_AUTH_TWITTER, locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl()
381+
pvt_twitter(auth = Sys.getenv("SECRET_API_AUTH_TWITTER"), locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl()
387382
```

0 commit comments

Comments
 (0)