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

oasa-telematics-api

v0.2.6

Published

The Athens' bus telematics API, complete with types and helper methods

Downloads

29

Readme

OASA Telematics API

npm npm GitHub Workflow Status

The (unofficial) Telematics API of Athens' public buses, complete with types and helper methods 🚌🚌🚌

This is the package that powers the popular greek messenger bot "Πότε έρχεται το λεωφορείο μου 🚌".

Getting Started

Install the package: $ npm i oasa-telematics-api

import { APIRequests, APIHelpers } from 'oasa-telematics-api';

const api = new APIRequests();
const b = new APIHelpers();

(async () => {
    // You can fetch all the lines:
    console.log("You can fetch all the lines...");
    console.log(await api.webGetLines());

    // You can fetch a single line:
    console.log("You can fetch a single line...");
    console.log(await b.findLine('140'));

    // You can fetch a stop of a line:
    console.log("You can fetch a stop of a line...");
    const line = await b.findLine('140');
    if (line) {
        const { directions } = await b.getDirectionsOfLine(line.LineCode)
        const [come, go ] = directions;
        console.log(await b.findStop('LAMIAS', come.RouteCodes));

        // Or in greek
        console.log("Or by searching in Greek...");
        console.log(await b.findStop('ΛΑΜΙΑΣ', come.RouteCodes));

        // Or by searching with a typo
        console.log("Or by searching with a typo...");
        console.log(await b.findStop('ΛΑΜΙΑ', come.RouteCodes));

        // And then you can check which buses are passing through that stop:
        console.log("And then you can check which buses are passing through that stop...");
        const stops = await b.findStop('ΛΑΜΙΑ', come.RouteCodes);
        if (stops.length > 0) {
            console.log(await api.getStopArrivals(stops[0].StopCode));
        }
    }
})();

You can explore more by visiting the (mostly auto-generated) docs here:

https://chrispanag.github.io/oasa-telematics-api/

Also, feel free to open an issue if you want to ask or suggest anything :)

Can I use my own request method?

Yes. The constructors APIRequests and APIHelpers can get a request function as an argument.

The request function will need to have the form:

export type RequestFunction = <T>(url: string, query: string, ...params: any[]) => Promise<T>;

You can see a reference request function here.

Why would I want to use my own request method?

Caching.

Also, see below...

Can I use this for frontend development?

Yes. But you'll need to create a custom request function using the browser fetch method instead of the default one installed (node-fetch). You can see the above question for more details.

Next Steps

  • Add tests
  • Add some more helper methods for schedule management