Skip to content

Commit 632fa25

Browse files
committed
doc: update instructions for client libraries
1 parent 988f10a commit 632fa25

File tree

2 files changed

+46
-35
lines changed

2 files changed

+46
-35
lines changed

docs/api/client_libraries.md

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,81 @@ nav_order: 1
66

77
# Epidata API Client Libraries
88

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:
1010

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).
1314

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).
1616

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
2419
`20200401` and `20200405-20200414` (11 days total).
2520

2621
### JavaScript (in a web browser)
2722

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].
2925

30-
````html
26+
```html
3127
<!-- Imports -->
3228
<script src="delphi_epidata.js"></script>
3329
<!-- Fetch data -->
3430
<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+
);
3744
});
3845
</script>
39-
````
46+
```
4047

4148
### Python
4249

50+
First, install `delphi-epidata` using pip:
4351

44-
Optionally install the [package from PyPI](https://pypi.org/project/delphi-epidata/) using pip(env):
45-
````bash
52+
```bash
4653
pip install delphi-epidata
47-
````
54+
```
4855

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:
5257

53-
````python
58+
```python
5459
# Import
5560
from delphi_epidata import Epidata
5661
# [Optional] configure your API key, if desired
5762
#Epidata.auth = ('epidata', <your API key>)
5863
# Fetch data
5964
res = Epidata.covidcast('fb-survey', 'smoothed_cli', 'day', 'county', [20200401, Epidata.range(20200405, 20200414)], '06001')
6065
print(res['result'], res['message'], len(res['epidata']))
61-
````
66+
```
6267

6368
### R
6469

70+
First, install `epidatr` from CRAN:
71+
72+
```R
73+
pak::pkg_install("epidatr")
74+
```
75+
76+
Then, run the following R code:
6577

66-
````R
78+
```R
6779
# [Optional] configure your API key, if desired
68-
#option('epidata.auth', <your API key>)
80+
#Sys.setenv('DELPHI_EPIDATA_KEY', <your API key>)
6981
# Import
70-
source('delphi_epidata.R')
82+
library('epidatr')
7183
# 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+
```

docs/api/covidcast_clients.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ nav_order: 1
66

77
# COVIDcast Libraries
88

9-
Dedicated COVIDcast access and analysis libraries are available for several languages:
9+
To access COVIDcast data, we recommend using the following client libraries:
1010

11-
* R: [covidcast](https://cmu-delphi.github.io/covidcast/covidcastR/)
12-
* Python: [covidcast](https://cmu-delphi.github.io/covidcast/covidcast-py/html/)
11+
- R: [epidatr](https://cmu-delphi.github.io/epidatr/).
12+
- Python: [covidcast](https://cmu-delphi.github.io/covidcast/covidcast-py/html/) (soon to be replaced [epidatpy](https://github.com/cmu-delphi/epidatpy)).
1313

1414
These packages provide a convenient way to obtain COVIDcast data as a data frame
1515
ready to be used in further analyses and provide convenient mapping and
1616
analysis functions. For installation instructions and examples, consult their
1717
respective webpages.
1818

19-
2019
To access Epidata datasets on other diseases, visit our [Epidata API Client Libraries)](client_libraries.md) documentation.

0 commit comments

Comments
 (0)