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

lametro

v0.3.1

Published

A thin wrapper around the LA Metro realtime api

Downloads

9

Readme

LAMetro

Greenkeeper badge

This is a thin wrapper around the LA Metro realtime api.

Build Status Coverage Status

It seems as tho only bus info is included in this api :( for now.

Usage

npm install lametro

Once you have the package installed now you can include it in your project.

import metro from 'lametro'
const {bus} = metro

// get all bus routes
bus.routes((err, res) => {
  if (err) return console.error(err)
  console.log('all routes', res)
})

Available methods

  • routes
  • routesStops
  • stopsPredictions
  • stopsMessages
  • routesSequence
  • routesRuns
  • routesVehicles

All methods are in the namespace of a agency. eg To get all the bus routes it is.

metro.bus.routes([option, callback])

To get a specific route you will need to call with some options.

metro.bus.routes({id: 704}, (err, res) => {
  if (err) return console.error(err)
  console.log(res)
})

Mapping method to endpoints

I am not going to document exactly what info comes back from the endpoints here, because that info can be found at realtime examples page, but it is good to know how the methods of this lib map to the endpoints of the api.

Lets say we want to make the api call to this url.

http://api.metro.net/agencies/lametro/stops/6033/predictions/

The method that we would be looking for would be.

metro.bus.stopsPredictions

The to get the lib to pass the correct id to the path we would just need to put it in the first option.

metro.bus.stopsPredictions({id: 6033}, (err, res) => {
  if (err) return console.error(err)
  console.log(res)
})

This would make the api call to the predictions endpoint. The bus namespace is a clearer indication for the lametro agency in the endpoint. The idea behind is that there will eventually be a rails version that will bring back LA Metro rails times.

All method names are made from the routes. If you are looking for a specific route try the method name that is closest to it.

Missing info?

If there is something missing the setup is fairly easy to add in a missing endpoint, so if your missing something please make a PR adding the route