dataItemExplorer {ukgasapi} | R Documentation |
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 |
latestflag |
A character object with length of one to specify whether to extract the latest data. This can either be |
applicableforflag |
A character object with length of one to specify whether dates specified are 'applicable for' or 'applicable on'. This can either be |
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
Graphical User Interface for Data Item Explorer
https://mip-prd-web.azurewebsites.net/DataItemExplorerAPI specification
https://marketinformation.natgrid.co.uk/MIPIws-public/public/publicwebservice.asmx?op=GetPublicationDataWM
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)