❔ Best way to set up a websocket and API to access the data?
I'm working on a website that gathers data through a websocket on the backend, using raw UDP packets. The protocol indicates that I can request data, and then immediately receive that data in batches until a special code is retreived to indicate the end of the collection. I want to display this data on the frontend by calling an API to fetch it.
The big challenge here is how I set up the backend to properly contain the data. I was thinking of having a background task occasionally fetch the data in an interval, and then have it store the data in a database. The API then always has this data available, or it will wait a bit whilst the newer batch is fetched.
Would this be viable, or is there a better way to fetch the data and making sure the API always retrieves the data for the frontend? How can I properly create a background task that is invoked every 5 minutes so that I can fetch the data?
The big challenge here is how I set up the backend to properly contain the data. I was thinking of having a background task occasionally fetch the data in an interval, and then have it store the data in a database. The API then always has this data available, or it will wait a bit whilst the newer batch is fetched.
Would this be viable, or is there a better way to fetch the data and making sure the API always retrieves the data for the frontend? How can I properly create a background task that is invoked every 5 minutes so that I can fetch the data?