LiarPrincess / Wroclive-server

Real-time public transport in Wrocław. With push notifications for all of the “tree is blocking the road, so the replacement bus was dispatched” events.
Mozilla Public License 2.0
4 stars 0 forks source link

Public use of API #8

Open konhi opened 2 years ago

konhi commented 2 years ago

Hi!

When I was doing research on Wrocław's API, I've stumbled upon this repository, and it's incredible! It gives a good example of enterprise-grade API that works on production and uses modern infrastructure. I especially appreciate clear documentation of every detail (not omitting even the costs!) that makes understanding how does it work frictionless! Furthermore, the project doesn't limit only to a server, but also powers beautiful app! I wish I would have iOS to check it out. 😄 I hope this repository is going to have more stars, so it's easier to discover. Besides that, it seems to be perfect project to be put into portfolio! 👏

I work on a related project, poland-public-transport-api, and I was wondering if your API (/api/v1/lines;stops;vehicles) could be integrated into my middleware. It would leverage Cloudflare's Cache, so usage would be limited to minimum. Hopefully, your project could gain popularity and use among programmers! Of course, if it's something you wouldn't like, let me know, and I will just leave link to this repo in my project!

LiarPrincess commented 2 years ago

Ooo… thanks!


Ultra important!

If you want to use government data then you HAVE TO ask them for permission! Apply using one of the following legal acts as your base:


Anyway…

I wish I would have iOS to check it out.

If you have a mac then you can download, compile and run the app in the simulator. If not, then there is a video that I send to Apple with each update (this is an old version, now we also have bell for notifications from @AlertMPK).

As for the using Wroclive api:

Some tips:

konhi commented 2 years ago

If you want to use government data then you HAVE TO ask them for permission! Apply using one of the following legal acts as your base

Big thanks for letting me know. I will definitely look into it, I really hope it won't complicate things - I didn't worry about legal things before! 😄 thank you for possibly saving me from being sued lol

If not, then there is a video that I send to Apple with each update

Wow, thank you so much for sharing! I love the select design - I wanted to implement something similar in other project I'll be doing, and I will definitely take inspiration from that. App looks lovely in general, great artistic job! ✨

You can use Wroclive api for this, but this is rather trivial to implement (you already did this for Zielona Góra).

Dezipping and things is not a task suited for Cloud Functions (which my API works on), but I think GitHub Actions will do the work! Thank you for explaining how does this process work.

As for the using Wroclive api: I would like to avoid additional unpredictable traffic hitting our servers. This leaves us with:

Since I do not have personal interest in API for Wrocław yet, and I don't want to stress your servers, I will leave a link to your repository for now! It's incredibly big help that you managed to wrote all these details. It should be easy to incorporate it into the API, eventually! Thank you a thousand times 🎉

using AWS/GCP/Azure gives you a lot of free things:

This is how I ended trying to use my free $100 on Azure for this project before even going to production, hehe

image

Though, I'm amazed how much cloud services were smartly used in this project!

think carefully about what you are going to do - one may think that this is trivial and they can write it in one weekend. This is extremely wrong. There is a big difference between production-ready and “it works”. You will spend hundreds of hours on this. If you do not have enough free time then…

Seems to be a very universal tip, thank you for giving advice!

include timestamp with every response - this will allow you to check if the server hangs (obsolete timestamp) or the data is stale (fresh timestamp, old data).

Makes sense, it seems to be a really useful feature.

Sending time as "18:05" makes parsing difficult.

Noted, very useful tip!


Technical questions:

both data sources include vehicles in depots/outside of their schedule etc. - you have to remove them by yourself

LiarPrincess commented 2 years ago

You can use Wroclive api for this, but this is rather trivial to implement (you already did this for Zielona Góra).

Dezipping and things is not a task suited for Cloud Functions (which my API works on), but I think GitHub Actions will do the work! Thank you for explaining how does this process work.

Depends on what “Cloud Functions” mean:

both data sources include vehicles in depots/outside of their schedule etc. - you have to remove them by yourself

what's the reason for doing that? I tried to fetch data for every possible bus and tram, and this is what I got. Is there anything off?

Try open data at 3 am -> you will see a lot of vehicles just standing there in depots. This is a pure visual noise.

LiarPrincess commented 2 years ago

using AWS/GCP/Azure gives you a lot of free things:

This is how I ended trying to use my free $100 on Azure for this project before even going to production, hehe

The whole Wroclive is based on GCP - Free Tier products. Though you have to be careful when reading terms, for example: for Compute Engine you get “1 non-preemptible e2-micro VM instance per month” but only in us-west1, us-central1, us-east1.

This does not matter for AppEngine, so you can place them wherever you like.

konhi commented 2 years ago

Thank you once again for explaining all these things in so much detail! I don't have any more questions, but I feel like it's good to leave this issue opened, so others might see it.