diff --git a/docs/api/api_keys.md b/docs/api/api_keys.md index d8c5ab306..9db40bc80 100644 --- a/docs/api/api_keys.md +++ b/docs/api/api_keys.md @@ -42,11 +42,12 @@ there are several ways to use your key to authenticate your requests: ### Using a client -* covidcast +* [epidatr](https://cmu-delphi.github.io/epidatr/#api-keys) +* [epidatpy](https://cmu-delphi.github.io/epidatpy/#api-keys) +* [delphi-epidata](https://cmu-delphi.github.io/delphi-epidata/api/client_libraries.html) +* covidcast (deprecated in favor of `epidatr` and `epidatpy`) * [R client](https://cmu-delphi.github.io/covidcast/covidcastR/reference/covidcast_signal.html#api-keys-1) * [Python client](https://cmu-delphi.github.io/covidcast/covidcast-py/html/signals.html#covidcast.use_api_key) -* [epidatr](https://github.com/cmu-delphi/epidatr#api-keys) -* [delphi-epidata](https://cmu-delphi.github.io/delphi-epidata/api/client_libraries.html) ### Via request parameter diff --git a/docs/api/client_libraries.md b/docs/api/client_libraries.md index cf27e30ca..ef825a156 100644 --- a/docs/api/client_libraries.md +++ b/docs/api/client_libraries.md @@ -9,7 +9,7 @@ nav_order: 1 To access Delphi Epidata programmatically, we recommend our client libraries: - R: [epidatr](https://cmu-delphi.github.io/epidatr/), -- Python: [delphi-epidata](https://pypi.org/project/delphi-epidata/) (soon to be replaced with [epidatpy](https://github.com/cmu-delphi/epidatpy)), +- Python: [epidatpy](https://cmu-delphi.github.io/epidatpy/) (recommended) and [delphi-epidata](https://pypi.org/project/delphi-epidata/), - Javascript: [delphi-epidata](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.js). For anyone looking for COVIDCast data, please visit our [COVIDCast API Client Libraries](covidcast_clients.md). @@ -23,18 +23,41 @@ COVID-19 Surveillance Streams from Facebook Survey CLI for county 06001 and days Install [`epidatr` from CRAN](https://cran.r-project.org/package=epidatr) with `install.packages("epidatr")`. -```R +```r # Configure API key interactively, if needed. See # https://cmu-delphi.github.io/epidatr/articles/epidatr.html#api-keys for details. #save_api_key() library(epidatr) -res <- pub_covidcast('fb-survey', 'smoothed_cli', 'county', 'day', geo_values = '06001', +data <- pub_covidcast('fb-survey', 'smoothed_cli', 'county', 'day', geo_values = '06001', time_values = c(20200401, 20200405:20200414)) -cat(res) +cat(data) ``` ### Python +The `epidatpy` package will soon be [available on PyPI as `epidatpy`](https://pypi.org/project/epidatpy/). +Meanwhile, it can be [installed from GitHub](https://github.com/cmu-delphi/epidatpy/) with +`pip install "git+https://github.com/cmu-delphi/epidatpy.git#egg=epidatpy"`. + +```python +# Configure API key, if needed. +# https://github.com/cmu-delphi/epidatpy/blob/dev/docs/index.rst#api-keys + +from epidatpy import EpiDataContext, EpiRange + +# Create the client object. +epidata = EpiDataContext() +apicall = epidata.pub_covidcast( + data_source="jhu-csse", + signals="confirmed_cumulative_num", + geo_type="nation", + time_type="day", + geo_values="us", + time_values=EpiRange(20210405, 20210410), +) +print(apicall.df()) +``` + Install [`delphi-epidata` from PyPI](https://pypi.org/project/delphi-epidata/) with `pip install delphi-epidata`. diff --git a/docs/api/covidcast.md b/docs/api/covidcast.md index 94fb9acb8..d283fb8a8 100644 --- a/docs/api/covidcast.md +++ b/docs/api/covidcast.md @@ -56,20 +56,27 @@ COVIDcast data. Once you install the appropriate client for your programming language, accessing data is as easy as, in [R](https://www.r-project.org/): ```r -library(covidcast) +library(epidatr) -data <- covidcast_signal("fb-survey", "smoothed_cli", start_day = "2020-05-01", - end_day = "2020-05-07") +data <- pub_covidcast('fb-survey', 'smoothed_cli', 'county', 'day', geo_values = '06001', + time_values = c(20200401, 20200405:20200414)) ``` or, in [Python](https://www.python.org): ```python -import covidcast -from datetime import date - -data = covidcast.signal("fb-survey", "smoothed_cli", date(2020, 5, 1), date(2020, 5, 7), - "county") +from epidatpy import EpiDataContext, EpiRange + +epidata = EpiDataContext() +apicall = epidata.pub_covidcast( + data_source="fb-survey", + signals="smoothed_cli", + geo_type="county", + time_type="day", + geo_values="*", + time_values=EpiRange(20200501, 20200507), +) +data = apicall.df() ``` [The API clients](covidcast_clients.md) have extensive documentation providing diff --git a/docs/api/covidcast_clients.md b/docs/api/covidcast_clients.md index 8066e33f5..d4fe77699 100644 --- a/docs/api/covidcast_clients.md +++ b/docs/api/covidcast_clients.md @@ -9,7 +9,7 @@ nav_order: 1 To access COVIDcast data, we recommend using the following client libraries: - R: [epidatr](https://cmu-delphi.github.io/epidatr/) -- Python: [covidcast](https://cmu-delphi.github.io/covidcast/covidcast-py/html/) (soon to be replaced with [epidatpy](https://github.com/cmu-delphi/epidatpy)) +- Python: [epidatpy](https://cmu-delphi.github.io/epidatpy/) (recommended) and [delphi-epidata](https://pypi.org/project/delphi-epidata/), These packages provide a convenient way to obtain COVIDcast data as a data frame ready to be used in further analyses and provide convenient mapping and analysis