A Node module to provide access to UK traffic information
Node 12.x
npm install uk-traffic --save
First you must obtain a reference to the module:
const traffic = require('uk-traffic')
There are some example uses of the library in the examples/
directory
traffic.incidents(region: REGION?) : Promise
Takes a region, returns a promise containing an array of events.
traffic.roadworks(region: REGION?) : Promise
Takes a region, returns a promise containing an array of events.
A Region is an enum representing a region which can be used to
narrow down results; you should use traffic.Region
to get a valid region
(e.g. traffic.Region.NORTH_WEST
). The available regions are:
SOUTH_EAST
SOUTH_WEST
EASTERN
WEST_MIDLANDS
EAST_MIDLANDS
NORTH_WEST
NORTH_EAST
An Event is the standard data type returned by the module for all
functions. See below for an example; all keys will be present, but they may have
undefined
or null
values.
{
title: "M25 J25 clockwise access",
category: "Road Works",
delay: "Severe Disruption - in excess of 3 hours delay or road closure",
link: "https://www.mycooltrafficsite.com/1234",
timing: {
start: "2020-07-07T21:00:00+01:00",
end: "2020-07-08T05:00:00+01:00"
},
location: {
road: "M25",
county: "Greater London Authority",
region: "Eastern",
latitude: 51.68319,
longitude: -0.04578481
}
}
You can enable additional debug logging by setting the environment variable
DEBUG=uk-traffic