Public transport API from python to Home Assistant

Hello,

I was wondering how would you make a simple python script that queries public transport API compatible with home assistant so one could show the data on frontend?

Here is a link to the script, that I have not coded or are not involved with it in any way. I am just curious how this kind of script could be changed so it can be make as a sensor to HA.

Thank you in advance :slight_smile:

Edit:
Here is the link to the API if anyone is interested.

Curious what you ended up doing/using? I currently have a python script that is very similar to what you have posted above. I want to eventually have a card on my dashboard that tells me the next 2 or 3 trains that’ll come to my stop. Ideally, I won’t have to build from scratch!!