Title: API for UK Energy Market Information
Version: 0.21
Author: Timothy Wong [aut, cre]
Maintainer: Timothy Wong <timothy.wong@hotmail.co.uk>
Description: Allows users to access live UK energy market information via various APIs.
Depends: R (≥ 3.0.0)
BugReports: https://github.com/timothywong731/ukgasapi/issues
License: GPL-2
Imports: httr,XML
LazyData: true
Suggests: ggplot2, knitr, rmarkdown
RoxygenNote: 7.1.1
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2020-10-26 23:52:32 UTC; Timothy Wong
Repository: CRAN
Date/Publication: 2020-11-06 16:50:02 UTC

BMRS Initial Demand Outturn API Service

Description

This function connects to the Elexon's BMRS API to retrieve Initial Demand Outturn (INDO) and Initial Transmission System Demand Out-Turn (ITSDO) data. Internet connection must be available.

Usage

bmrsIndoItsdo(
  fromdate,
  todate,
  apikey,
  batchsize = 60,
  apiurl = "https://api.bmreports.com/BMRS/INDOITSDO/v1"
)

Arguments

fromdate

A character object specifying the start date. Date is inclusive.

todate

A character object specifying the end date. Date is inclusive.

apikey

A character object specifying the API key. This is also known as scripting key on Elexon's website.

batchsize

An interger value indicating the batch size of each API call. (Number of days included in one call)

apiurl

A character object which points to the BMRS INDO/ITSDO API. Under most circumstances users do not have to change this. Default to 'https://api.bmreports.com/BMRS/INDOITSDO/v1'

Details

The function submits a request to the API. The response is in CSV format which function will parse internally and returns a R dataframe object. The data returned by this API is identical to the data displayed on BMRS dashboard https://www.bmreports.com/bmrs/?q=demand/initialdemandoutturn.

Value

A dataframe object containing API response data.

Author(s)

Timothy Wong, timothy.wong@hotmail.co.uk

References

Examples

## Not run: 
# Invoke the API (requires internet connection at this step)
response <- bmrsIndoItsdo(fromdate = "2020-01-01",
                          todate =  "2020-01-10",
                          apikey = "your api key goes here")

# Visualise the results on a chart
library(ggplot2)
ggplot(response, aes(x=publishtime, y=value,colour=recordtype)) +
  geom_line()

## End(Not run)

Data Item Explorer API

Description

This function connects to the UK National Grid's API for Data Item Explorer, which is a major data source for gas-related information. Internet connection must be available.

Usage

dataItemExplorer(
  dataitems,
  fromdate,
  todate,
  datetype = "gasday",
  latestflag = "Y",
  applicableforflag = "Y",
  batchsize = -1,
  apiurl = paste0("https://marketinformation.natgrid.co.uk/",
    "MIPIws-public/public/publicwebservice.asmx")
)

Arguments

dataitems

A vector of characters containing data items to enquire via API.

fromdate

A character object specifying the start date. Date is inclusive.

todate

A character object specifying the end date. Date is inclusive.

datetype

A character object specifying the data type. Defaults to gasday

latestflag

A character object with length of one to specify whether to extract the latest data. This can either be Y or N. Defaults to Y.

applicableforflag

A character object with length of one to specify whether dates specified are 'applicable for' or 'applicable on'. This can either be Y or N where Y indicates 'applicable for'. Defaults to Y.

batchsize

An interger value indicating the batch size of each API call. To invoke a single API call, use zero or negative values.

apiurl

A character object which points to National Grid's SOAP API. Under most circumstances users do not have to change this. Default to 'http://marketinformation.natgrid.co.uk/MIPIws-public/public/publicwebservice.asmx'

Details

The function submits a request to the API using XML over SOAP protocol. The response is in XML format which function will parse internally and returns a R dataframe object.

Value

A dataframe object containing API response data.

Author(s)

Timothy Wong, timothy.wong@hotmail.co.uk

References

Examples

## Not run: 
# Specify the data item(s) to enquire from API
dataitems <- c("Storage Injection, Actual",
               "Storage Withdrawal, Actual")

# Invoke the API (requires internet connection at this step)
response <- dataItemExplorer(dataitems,
                             fromdate = "2020-01-01",
                             todate="2020-01-31")

# Visualise the results on a chart
library(ggplot2)
ggplot(response,aes(x=ApplicableFor,y=Value,colour=PublicationObjectName)) +
 geom_line()

## End(Not run)