@@ -6,83 +6,81 @@ nav_order: 1
6
6
7
7
# Epidata API Client Libraries
8
8
9
+ To access Delphi Epidata programmatically, we recommend our client libraries:
10
+
11
+ - R: [ epidatr] ( https://cmu-delphi.github.io/epidatr/ ) ,
12
+ - Python: [ delphi-epidata] ( https://pypi.org/project/delphi-epidata/ ) (soon to be replaced with [ epidatpy] ( https://github.com/cmu-delphi/epidatpy ) ),
13
+ - Javascript: [ delphi-epidata] ( https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.js ) .
14
+
9
15
For anyone looking for COVIDCast data, please visit our [ COVIDCast Libraries] ( covidcast_clients.md ) .
10
16
11
- A full-featured Epidata client for R is available at
12
- [ epidatr] ( https://github.com/cmu-delphi/epidatr ) and
13
- [ also on CRAN] ( https://cran.r-project.org/web/packages/epidatr/index.html ) .
14
-
15
- We are currently working on a new full-featured Epidata client for Python. It is not ready
16
- for release yet, but you can track our development progress and help us test it out at
17
- [ epidatpy] ( https://github.com/cmu-delphi/epidatpy ) .
18
-
19
- In the meantime, minimalist Epidata clients remain available for
20
- [ Python] ( https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.py ) ,
21
- [ JavaScript] ( https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.js ) ,
22
- and
23
- [ R (legacy)] ( https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.R ) .
24
- The following samples show how to import the library and fetch Delphi's COVID-19
25
- Surveillance Streams from Facebook Survey CLI for county 06001, and days
17
+ The following samples show how to import the library and fetch Delphi's
18
+ COVID-19 Surveillance Streams from Facebook Survey CLI for county 06001 and days
26
19
` 20200401 ` and ` 20200405-20200414 ` (11 days total).
27
20
28
21
### R
29
22
30
- ```` R
31
- # [Optional] configure your API key, if desired
32
- # Interactive. See https://cmu-delphi.github.io/epidatr/articles/epidatr.html#api-keys for details.
23
+ Install [ ` epidatr ` from CRAN] ( https://cran.r-project.org/package=epidatr )
24
+ with ` install.packages("epidatr") ` .
25
+
26
+ ``` R
27
+ # Configure API key interactively, if needed. See
28
+ # https://cmu-delphi.github.io/epidatr/articles/epidatr.html#api-keys for details.
33
29
# save_api_key()
34
- # Import
35
30
library(epidatr )
36
- # Fetch data
37
31
res <- pub_covidcast(' fb-survey' , ' smoothed_cli' , ' county' , ' day' , geo_values = ' 06001' ,
38
32
time_values = c(20200401 , 20200405 : 20200414 ))
39
33
cat(res )
40
- ````
34
+ ```
41
35
42
36
### Python
43
37
44
- Optionally install the [ package from PyPI] ( https://pypi.org/project/delphi-epidata/ ) using pip(env):
45
- ```` bash
46
- pip install delphi-epidata
47
- ````
38
+ Install [ ` delphi-epidata ` from PyPI] ( https://pypi.org/project/delphi-epidata/ ) with
39
+ ` pip install delphi-epidata ` .
48
40
49
- Otherwise, place
50
- [ ` delphi_epidata.py ` ] ( https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.py )
51
- in the same directory as your Python script.
52
-
53
- ```` python
54
- # Import
41
+ ``` python
55
42
from delphi_epidata import Epidata
56
- # [Optional] configure your API key, if desired
43
+ # Configure API key, if needed.
57
44
# Epidata.auth = ('epidata', <your API key>)
58
- # Fetch data
59
45
res = Epidata.covidcast(' fb-survey' , ' smoothed_cli' , ' day' , ' county' , [20200401 , Epidata.range(20200405 , 20200414 )], ' 06001' )
60
46
print (res[' result' ], res[' message' ], len (res[' epidata' ]))
61
- ````
47
+ ```
62
48
63
49
### JavaScript (in a web browser)
64
50
65
- The minimalist JavaScript client does not currently support API keys. If you need API key support in JavaScript, contact
[email protected] .
51
+ The minimalist JavaScript client does not currently support API keys.
52
+ If you need API key support in JavaScript, contact
[email protected] .
66
53
67
- ```` html
68
- <!-- Imports -->
54
+ ``` html
69
55
<script src =" delphi_epidata.js" ></script >
70
- <!-- Fetch data -->
71
56
<script >
72
- EpidataAsync .covidcast (' fb-survey' , ' smoothed_cli' , ' day' , ' county' , [20200401 , EpidataAsync .range (20200405 , 20200414 )], ' 06001' ).then ((res ) => {
73
- console .log (res .result , res .message , res .epidata != null ? res .epidata .length : 0 );
57
+ EpidataAsync .covidcast (
58
+ " fb-survey" ,
59
+ " smoothed_cli" ,
60
+ " day" ,
61
+ " county" ,
62
+ [20200401 , EpidataAsync .range (20200405 , 20200414 )],
63
+ " 06001"
64
+ ).then ((res ) => {
65
+ console .log (
66
+ res .result ,
67
+ res .message ,
68
+ res .epidata != null ? res .epidata .length : 0
69
+ );
74
70
});
75
71
</script >
76
- ````
72
+ ```
77
73
78
74
### R (legacy)
79
75
76
+ The old Delphi Epidata R client is available
77
+ [ here] ( https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R ) ,
78
+ but its use is discouraged.
79
+
80
80
``` R
81
- # [Optional] configure your API key, if desired
81
+ # Configure API key, if needed.
82
82
# option('epidata.auth', <your API key>)
83
- # Import
84
83
source(' delphi_epidata.R' )
85
- # Fetch data
86
84
res <- Epidata $ covidcast(' fb-survey' , ' smoothed_cli' , ' day' , ' county' , list (20200401 , Epidata $ range(20200405 , 20200414 )), ' 06001' )
87
85
cat(paste(res $ result , res $ message , length(res $ epidata ), " \n " ))
88
86
```
0 commit comments