Total Beginner trying to use GTFS-rt data on a website

322 views
Skip to first unread message

David Song

unread,
Mar 20, 2023, 2:50:57 AM3/20/23
to GTFS-realtime
Hello, everybody. 
I'm a student who is currently totally new to any format of APIs. 
However, when I'm trying to use GTFS-rt data on a website, I have no idea where i should start from. 
I'm trying to show how many minutes there are left for a bus to come for a specific bus stop. 
How should I do it? 
I have read the protobuf document by google and followed the steps but I'm not quite sure how i'm supposed to use GTFS' .proto file and GTFS-rt's json file to display data on a website. 

It would be grateful to get any help from the gurus. 
Thank you!!

David Song

unread,
Mar 20, 2023, 3:00:34 AM3/20/23
to GTFS-realtime
Oh to add on, I only worked with HTML, JS for web development so I only looked at the JavaScript documents of the protbuf. Can I use other languages(ex. Java, Python) to create the website? Also, is there any possible way for me to not use the proto?? Thank you!

Stefan de Konink

unread,
Mar 20, 2023, 5:37:54 AM3/20/23
to gtfs-r...@googlegroups.com
On Monday, March 20, 2023 8:00:34 AM CET, David Song wrote:
> Oh to add on, I only worked with HTML, JS for web development so I only
> looked at the JavaScript documents of the protbuf. Can I use other
> languages(ex. Java, Python) to create the website? Also, is there any
> possible way for me to not use the proto?? Thank you!

Practically you take a backend process (Java, Python, NodeJs, etc.) to
download the .proto file and transform it in the backend into a message
which you can display on the client. This message could be a HTML page, a
JSON message, etc. you could obviously show the protofile as whole to the
client but you must understand that mean you will transfer an entire
database to a single user, which may only be interested in a single bus
stop.

So in terms of design:

backend
0. process the 'base' GTFS file
1. download .proto fol GTFS-RT
2. transform .proto into a database or separate files, a language binding
will help you <https://github.com/MobilityData/gtfs-realtime-bindings>

frontend
1. interact with the backend to filter for a specific selection

--
Stefan

Walter Jenkins

unread,
Mar 20, 2023, 9:18:06 AM3/20/23
to GTFS-realtime
This is a great blog post from a dev at esri that explaning bringing in PB's in the browser. Specifically he is looking at vehicle locations. The only gotcha is that when you are developing you may get a CORS error.

https://gavinr.com/protocol-buffers-protobuf-browser/

E Sall

unread,
Mar 20, 2023, 1:30:55 PM3/20/23
to gtfs-r...@googlegroups.com
David,
It can certainly be intimidating to get started with protobuf encoded data - even to read it you need to know a few things that aren't necessarily obvious.  I just grabbed a few of the functions that I tend to use to just scan data (not in any production capacity) and turn them into pandas dataframes to review and put them in a public gist: https://gist.github.com/e-lo/7a2aa41ba361dba1f2525e9964eae1b0

Notes: 
- there are certainly more efficient and elegant ways to do this...I'm by no means. a computer scientist or expert in any way, but I did want to share something that I figured out that worked for me in hopes that it might save others some time.
- I copied/pasted various code snippets to the gist so it might take some editing to work for you...I haven't debugged it in any way.

Best,
E

--
You received this message because you are subscribed to the Google Groups "GTFS-realtime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gtfs-realtim...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gtfs-realtime/28ee5b27-22af-4c42-8857-b878e8f75b26n%40googlegroups.com.

Sandro Batista

unread,
Mar 20, 2023, 2:10:14 PM3/20/23
to GTFS-realtime
Hi David,

With Mapify IoT you can easily, without any code, connect to your GTFS RT feed, create your information layers and even a no-code web application.

We have a lot of tutorials here but feel free to send me a DM.

Best,
Sandro
Reply all
Reply to author
Forward
0 new messages