dataItemExplorer: Data Item Explorer API

Description Usage Arguments Details Value Author(s) References Examples

View source: R/dataItemExplorer.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## 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)

ukgasapi documentation built on Jan. 13, 2021, 3:17 p.m.