octopusR is an R package that provides access to the Octopus Energy API. With octopusR, you can easily retrieve data from the Octopus Energy API and use it in your R projects.
octopusR is not yet available on CRAN, so must be installed from
GitHub, to install, you can use the devtools
package:
# Install devtools if needed
if (!require("devtools")) install.packages("devtools")
::install_github("moohan/octopusR") devtools
To use most function in octopusR, you will need an API key from
Octopus Energy, you can find this on the developer
dashboard. Once you have your API key, you can use the
set_api_key()
function to interactively input and store the
API key for the session:
library(octopusR)
# Set your API key
set_api_key()
Once you have authenticated with the API, you may also want to set your meter-point details.
# 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:
# Get data about your energy usage
<- get_consumption(meter_type = "elec")
energy_usage #> ℹ Returning 100 rows only as a date range wasn't provided.
#> ✔ Specify a date range with `period_to` and `period_from`.
# View the data
head(energy_usage)
#> # A tibble: 6 × 3
#> consumption interval_start interval_end
#> <dbl> <dttm> <dttm>
#> 1 0.096 2023-01-15 23:30:00 2023-01-16 00:00:00
#> 2 0.097 2023-01-15 23:00:00 2023-01-15 23:30:00
#> 3 0.097 2023-01-15 22:30:00 2023-01-15 23:00:00
#> 4 0.097 2023-01-15 22:00:00 2023-01-15 22:30:00
#> 5 0.098 2023-01-15 21:30:00 2023-01-15 22:00:00
#> 6 0.098 2023-01-15 21:00:00 2023-01-15 21:30:00
For more information and examples, see the package documentation and the Octopus Energy API documentation.
If you have suggestions for improving octopusR, or if you have found a bug, please open an issue. Contributions in the form of pull requests are also welcome. See the guide to contributing for more details.
Please note that the octopusR project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
octopusR is licensed under the MIT License. See LICENSE for more information.