Skip to content

External API Calls (VBB Metaweather)

misteu edited this page Mar 20, 2018 · 2 revisions

I stopped the crypto-mining on the Raspberry Pi and implemented two other APIs instead. It is still possible to check the miners status via the URL /?infos=show&mining=show but I reused its button for checking train departure times.

I use the hafas-API, which is free but you need to write an email to vbb to get a demo-key. If you want to use it after trying it out, you have to sign some kind of agreement. But still it is free to use ;-)

You can get infos to their API here: http://demo.hafas.de/openapi/vbb-proxy/

Before that I used a public API without authentication, that was very slow (more than 3 seconds for retrieving departure information). The hafas-API ist much faster. Postman measures ~440ms response delay for a request on their service "departureBoard".

The second API I integrated is the https://www.metaweather.com/. This one is one of the nicest APIs I have seen so far. It is structured very good (no deep trees of JSON) and the creators even give access to some nice weather icons you may use. The icon's filenames are exactly like the corresponding JSON values, e.g. "lc" and "lc.svg" for "Light Cloud"! How cool is that? No need to search for icons or parse anything :-)

And: No need to sign up for anything! For example, here is the ressource (for Berlin) I use: https://www.metaweather.com/api/location/638242/ :-)

I gave it a very subtle look, to not distract too much from the WebApps main purpose ;) Image of weather gadget

I do extract only the trains with the direction I need and limit the initially shown departure times to five trains. With the button "Mehr Verbindungen" (= show more connections), every departure time I extracted is shown. The API shows only trains with max. one hour depature time in future resulting in ~19 rows after clicking that button. Image of train departure table