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