Skip to content

Commit

Permalink
suggest how to store purple air api key
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-brokamp committed Jul 5, 2024
1 parent 265c657 commit 1d0ee05
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
8 changes: 6 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ Install the development version of PurpleAir with:
pak::pak("cole-brokamp/PurpleAir")
```

Querying data from the PurpleAir API requires a free [PurpleAir Developer API key](https://develop.purpleair.com/sign-in?redirectURL=%2Fdashboards%2Fkeys) linked to a Google account.

## Usage

```{r}
library(PurpleAir)
```

Querying data from the PurpleAir API requires a free [PurpleAir Developer API key](https://develop.purpleair.com/sign-in?redirectURL=%2Fdashboards%2Fkeys) linked to a Google account. Functions in the package each take a `purple_air_api_key` argument or your key can be stored in an environment variable called `PURPLE_AIR_API_KEY`). To check your key, use:

```{r}
check_api_key(Sys.getenv("PURPLE_AIR_API_KEY"))
```

Get the latest data from a single PurpleAir sensor, defined by its [sensor key](https://community.purpleair.com/t/sensor-index/4000):

```{r}
Expand Down
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,23 @@ Install the development version of PurpleAir with:
pak::pak("cole-brokamp/PurpleAir")
```

## Usage

``` r
library(PurpleAir)
```

Querying data from the PurpleAir API requires a free [PurpleAir
Developer API
key](https://develop.purpleair.com/sign-in?redirectURL=%2Fdashboards%2Fkeys)
linked to a Google account.

## Usage
linked to a Google account. Functions in the package each take a
`purple_air_api_key` argument or your key can be stored in an
environment variable called `PURPLE_AIR_API_KEY`). To check your key,
use:

``` r
library(PurpleAir)
check_api_key(Sys.getenv("PURPLE_AIR_API_KEY"))
#> ✔ Using valid 'READ' key with version V1.0.14-0.0.57 of the PurpleAir API on 2024-07-05 14:44:18
```

Get the latest data from a single PurpleAir sensor, defined by its
Expand All @@ -56,7 +64,7 @@ Get the latest data from a single PurpleAir sensor, defined by its
get_sensor_data(sensor_index = 175413,
fields = c("name", "last_seen", "pm2.5_cf_1", "pm2.5_atm"))
#> $last_seen
#> [1] "2024-07-05 14:37:43 EDT"
#> [1] "2024-07-05 14:41:43 EDT"
#>
#> $name
#> [1] "JN-Clifton,OH"
Expand All @@ -77,8 +85,8 @@ get_sensors_data(x = as.integer(c(175257, 175413)),
#> # A tibble: 2 × 5
#> sensor_index last_seen name pm2.5_atm pm2.5_cf_1
#> <int> <dttm> <chr> <dbl> <dbl>
#> 1 175257 2024-07-05 14:38:00 Lillard 4.4 4.4
#> 2 175413 2024-07-05 14:39:43 JN-Clifton,OH 5 5
#> 1 175257 2024-07-05 14:42:00 Lillard 3.9 3.9
#> 2 175413 2024-07-05 14:41:43 JN-Clifton,OH 4.6 4.6
```

a geographic bounding box,
Expand Down

0 comments on commit 1d0ee05

Please sign in to comment.