uk-traffic
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

traffic

npm version Node.js CI

A Node module to provide access to UK traffic information

Prerequisities

Node 12.x

Installation

npm install uk-traffic --save

API

First you must obtain a reference to the module:

const traffic = require('uk-traffic')

Examples

There are some example uses of the library in the examples/ directory

Properties

Incidents

traffic.incidents(region: REGION?) : Promise

Takes a region, returns a promise containing an array of events.

Roadworks

traffic.roadworks(region: REGION?) : Promise

Takes a region, returns a promise containing an array of events.

Data Types

Region

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

Event

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
  }
}

Debugging

You can enable additional debug logging by setting the environment variable DEBUG=uk-traffic

Readme

Keywords

none

Package Sidebar

Install

npm i uk-traffic

Weekly Downloads

0

Version

3.0.2

License

MIT

Unpacked Size

11.5 kB

Total Files

16

Last publish

Collaborators

  • alexchesters