Skip to content

A Flask server which pushes NJT bus times to Tidbyt devices.

License

Notifications You must be signed in to change notification settings

mattcaruso/njt-bus-time-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NJ Transit Bus Times Flask API

This project utilizes Flask to create a minimal HTTP API, connected to a Postgres database, which serves NJ Transit's bus scheduled GTFS data. It's based on the minimal-flask-api repo and blog post by Mark Douthwaite which lays out helpful guidelines to host Flask in a production environment.

Why is this service necessary?

Components

minimal-flask-api

This template repository was used as a starting point because it contains a number of architectural decisions already made and great recommendations for dockerized hosting.

The template has been set up for use with Python >= 3.7 and Docker.

axilla

Tidbyt's SDK for designing applets is called Pixlet. btjones has created an excellent Netlify template dubbed axilla to run Pixlet and render images via HTTP API. You'll need to stand up your own axilla server or find another way to render the Starlark script via Pixlet into a base64 image.

NJ Transit GTFS Data

NJ Transit only provides bus data as a GTFS archive. They provide no official HTTP API. To make up for this, I've leveraged gtfs-db, which ingests the GTFS zip file and loads it into a Postgres database. You'll need to follow the instructions in their README to get yourself set up with a database.

Environment

Note: These variables must be set in your local environment before any tests will pass.

Key Example Value Notes
TIDBYT_DEVICE_IDS monkey-banana-231,seal-fish-456 The Tidbyt device IDs, as found in your Tidbyt app. To push to multiple Tidbyts, use a comma separated list format, as shown. A single string without commas will work for a single target device.
TIDBYT_API_KEYS ey9178fhalkdgh...,x187dhgladkgh Your Tidbyt API key, found in the app. You'll have a different API key for each Tidbyt. Note: You need to put the order of the API keys in the same order you used for the device IDs!
PGDATABASE datbasename Your database credentials where you host NJ Transit GTFS data.
PGHOST monorail.proxy.rlwy.net
PGPASSWORD password1234
PGPORT 5432
PGUSER postgres

About

A Flask server which pushes NJT bus times to Tidbyt devices.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published