npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tfl-journey-planner

v1.1.2

Published

A node js wrapper for the TFL journey planner API

Downloads

12

Readme

Node TFL Journey Planner

A simple Node wrapper for the for fetching real-time journey's from the TFL API

dependencies Status devDependencies Status npm Codacy Badge

Install

npm install tfl-journey-planner --save

Usage

tflJourneyPlanner = require('tfl-journey-planner');

// Specify locations in this format
locations = {
  to: {lat: 51.5002452, lng: 0.0035842},
  from: {lat: 51.5131652, lng: -0.0905267}
};

options = {}; // Specify additional options if you want (see below)

tflJourneyPlanner(locations, options, function(results){
  console.log(results); // Do awesome stuff with the TFL results!
});

Locations

Locations can either be specified like:

locations = {
  to: {lat: 51.5002452, lng: 0.0035842},
  from: {lat: 51.5131652, lng: -0.0905267}
}

or with their text value

locations = {
  to: 'Aldgate East',
  from: 'London Bridge'
};

However, using text values will more than likley have many matches, so your response may not be as you'd planned.

or with postal codes/ text addresses

locations = {
  to: 'SE18 7PH',
  from: 'EC3M 3AD'
};

Specifying additional options

The second param is a JSON object where you can put any of the following (all are optional):

| OPTION | DEFAULT | EXPLINATION | |-------------------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | via | | Travel through (if in coordinate format then must be "longitude,latitude") | | nationalSearch | [False] | Does the journey cover stops outside London? eg. "nationalSearch=true" | | date | | The date must be in yyyyMMdd format | | time | | The time must be in HHmm format | | timeIs | [Departing] | Does the time given relate to arrival or leaving time? Possible options: "departing" | "arriving" | | journeyPreference | [LeastTime] | The journey preference eg possible options: "leastinterchange" | "leasttime" | "leastwalking" | | mode | | The mode must be a comma separated list of modes. eg possible options: "public-bus,overground,train,tube,coach,dlr,cablecar,tram,river,walking,cycle" | | accessibilityPreference | | The accessibility preference must be a comma separated list eg. "noSolidStairs,noEscalators,noElevators,stepFreeToVehicle,stepFreeToPlatform" | | fromName | | From name is the location name associated with a from coordinate | | toName | | To name is the label location associated with a to coordinate | | viaName | | Via name is the location name associated with a via coordinate. | | maxTransferMinutes | | The max walking time in minutes for transfer eg. "120" | | maxWalkingMinutes | | The max walking time in minutes for journeys eg. "120" | | walkingSpeed | [Average] | The walking speed. eg possible options: "slow" | "average" | "fast". | | cyclePreference | [None] | The cycle preference. eg possible options: "allTheWay" | "leaveAtStation" | "takeOnTransport" | "cycleHire" | | adjustment | | Time adjustment command. eg possible options: "TripFirst" | "TripLast" | | bikeProficiency | | A comma separated list of cycling proficiency levels. eg possible options: "easy,moderate,fast" | | alternativeCycle | [False] | Option to determine whether to return alternative cycling journey | | alternativeWalking | [True] | Option to determine whether to return alternative walking journey | | applyHtmlMarkup | [False] | Flag to determine whether certain text (e.g. walking instructions) should be output with HTML tags or not. | | useMultiModalCall | [False] | A boolean to indicate whether or not to return 3 public transport journeys, a bus journey, a cycle hire journey, a personal cycle journey and a walking journey | | walkingOptimization | [False] | A boolean to indicate whether to optimize journeys using walking |

Specify options like this:

options = {
    walkingOptimization: true,
    bikeProficiency: 'easy',
    accessibilityPreference: 'noEscalators'
}

Developing

Written in LiveScript, run npm run build to build, or npm run watch to watch for changes then build

Unit Tests

npm test

Issues

Report on GitHub repo issue page

Authenticating

Authentication is not required any longer or tfl requests. If you do need to authenticate then you can sign up for an API key at https://api-portal.tfl.gov.uk/signup Create a JSON object similar to the one below

    tfl = {
        appId: 'xxxxxxxx',
        appKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    };