-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
103 lines (75 loc) · 3.57 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# octopusR
<!-- badges: start -->
[![CRAN
status](https://www.r-pkg.org/badges/version/octopusR)](https://CRAN.R-project.org/package=octopusR)
[![R-CMD-check](https://github.com/Moohan/octopusR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Moohan/octopusR/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/Moohan/octopusR/branch/main/graph/badge.svg)](https://app.codecov.io/gh/Moohan/octopusR?branch=main)
<!-- badges: end -->
octopusR is an R package that provides access to the [Octopus Energy REST API](https://developer.octopus.energy/rest). With octopusR, you can easily retrieve data from the Octopus Energy API and use it in your R projects, or Shiny dashboards.
If you find this package useful, why not [sponsor me on GitHub](https://github.com/sponsors/Moohan) or sign up for an Octopus Energy account with [my referral code (young-snake-740)](https://share.octopus.energy/young-snake-740)!
## Installation
octopusR can be installed from CRAN.
```r
install.packages("octopusR")
```
If you would like the development version, it can be installed from GitHub, using the `devtools` package:
```r
# Install devtools if needed
if (!require("devtools")) install.packages("devtools")
devtools::install_github("moohan/octopusR")
```
## Usage
To use most functions in octopusR, you will need an API key from Octopus Energy, you can find this on the [developer dashboard](https://octopus.energy/dashboard/developer/). Once you have your API key, you can use `set_api_key()` to interactively input and store the API key for the session:
```r
library(octopusR)
# Set your API key
set_api_key()
```
Once you have authenticated with the API, you may also want to set your electric and/or gas meter details.
```r
# Set details for your electricity meter
set_meter_details(meter_type = "electricity")
# Set details for your gas meter
set_meter_details(meter_type = "gas")
```
You can use the other functions in the package to interact with the API. For example, you can use the `get_consumption()` function to retrieve data about your energy usage:
```{r setup, include=FALSE}
library(octopusR)
set_api_key(api_key = octopusR:::testing_key())
set_meter_details(
meter_type = "electricity",
mpan_mprn = octopusR:::testing_meter("electricity")[["mpan_mprn"]],
serial_number = octopusR:::testing_meter("electricity")[["serial_number"]]
)
```
```{r get_consumption}
# Get data about your energy usage
energy_usage <- get_consumption(meter_type = "elec")
# View the data
head(energy_usage)
```
For more information and examples, see the [package documentation](https://moohan.github.io/octopusR/) and the [Octopus Energy API documentation](https://developer.octopus.energy/docs/api/).
## Contributing
If you have suggestions for improving octopusR, or if you have found a
bug, please [open an issue](https://github.com/Moohan/octopusR/issues).
Contributions in the form of pull requests are also welcome. See the
[guide to contributing](https://moohan.github.io/octopusR/CONTRIBUTING.html) for more details.
### Code of Conduct
Please note that the octopusR project is released with a [Contributor
Code of
Conduct](https://moohan.github.io/octopusR/CODE_OF_CONDUCT.html). By
contributing to this project, you agree to abide by its terms.
## License
octopusR is licensed under the MIT License. See LICENSE for more information.