Last data update: 2014.03.03

R: Data Item Explorer API
dataItemExplorerR 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",
  apiurl = "http://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.

apiurl

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

Details

The function submits an enquiry to the destination API using XML over HTTP using SOAP standard. The HTTP response is in XML format which function will parse internally and return a R dataframe object.

Value

A dataframe object containing API response data.

Author(s)

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

References

Examples

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

# Initialise API (requires internet connection for this step)
response <- dataItemExplorer(dataitems,
                             fromdate = '2013-10-01',
                             todate='2015-09-30')

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

Results