The National Grid publishes live market information through Market Information Provision Initiative (MIPI) API. It hosts a large volume of data (over 13,500 data items)1 and is used extensively on a daily basis.
The function dataItemExplorer calls the MIPI API and returns data from the Data Item Explorer. The first argument dataitems is a character vector of data items where multiple values are accepted. It must match with the data items provided on the Data Item Explorer. This function also requires fromdate and todate which specify the date range to return data from. The return type is a data.frame object.
response <- dataItemExplorer(dataitems = c("Storage Injection, Actual",
"Storage Withdrawal, Actual"),
fromdate = "2017-01-01",
todate = "2017-12-31")
head(response, 10)| ApplicableAt | ApplicableFor | Value | GeneratedTimeStamp | QualityIndicator | Substituted | CreatedDate | PublicationObjectName |
|---|---|---|---|---|---|---|---|
| 2017-02-10 15:00:00 | 2017-01-01 | 654339382 | 2017-02-10 15:01:38 | 2017-02-10 15:01:38 | Storage Injection, Actual | ||
| 2017-02-10 15:00:00 | 2017-01-02 | 191923757 | 2017-02-10 15:01:38 | 2017-02-10 15:01:39 | Storage Injection, Actual | ||
| 2017-02-10 15:00:00 | 2017-01-03 | 65808124 | 2017-02-10 15:01:38 | 2017-02-10 15:01:38 | Storage Injection, Actual | ||
| 2017-02-10 15:00:00 | 2017-01-04 | 2743671 | 2017-02-10 15:01:38 | 2017-02-10 15:01:39 | Storage Injection, Actual | ||
| 2017-02-10 15:00:00 | 2017-01-05 | 72190668 | 2017-02-10 15:01:38 | 2017-02-10 15:01:40 | Storage Injection, Actual | ||
| 2017-02-10 15:00:00 | 2017-01-06 | 2582168 | 2017-02-10 15:01:38 | 2017-02-10 15:01:46 | Storage Injection, Actual | ||
| 2017-02-10 15:00:00 | 2017-01-07 | 202786018 | 2017-02-10 15:01:38 | 2017-02-10 15:01:40 | Storage Injection, Actual | ||
| 2017-02-10 15:00:00 | 2017-01-08 | 354960293 | 2017-02-10 15:01:38 | 2017-02-10 15:01:45 | Storage Injection, Actual | ||
| 2017-02-10 15:00:00 | 2017-01-09 | 247556567 | 2017-02-10 15:01:38 | 2017-02-10 15:01:39 | Storage Injection, Actual | ||
| 2017-02-10 15:00:00 | 2017-01-10 | 121739669 | 2017-02-10 15:01:38 | 2017-02-10 15:01:45 | Storage Injection, Actual |
Since the return type is a data.frame object, users can use standard plotting packages such as ggplot2 to visualise the response.
library(ggplot2)
qplot(x = ApplicableFor,
y = Value,
data = response,
colour = PublicationObjectName,
geom = "line") +
theme(legend.position = "bottom")According to the National Grid↩