slowlydev / f1-dash

A real-time F1 dashboard
https://f1-dash.com
GNU General Public License v3.0
412 stars 39 forks source link

Is this real? Couldn’t find the formula1 api anywhere. #58

Closed mfts closed 4 months ago

mfts commented 4 months ago

If it’s real, why did you hardcode an API Key?

slowlydev commented 4 months ago

Eh, I think this is real... 😅 and I can't seem to find the hardcoded api key, if u found one, please point me to it! 😄

What I remember I send a "negotiation" request, where I get a cookie and a token.

coret commented 4 months ago

https://github.com/Slowlydev/f1-dash/blob/720e76d986024055bd45161a0d3d8410fc717ae2/data/src/endpoints/getEventTracker.ts#L5

slowlydev commented 4 months ago

Ah right, my bad, that's "only" for the next event tracker.

to the endpoint "https://api.formula1.com/v1/event-tracker"

I got this API by using the DevTools on the f1 website.

The "main" realtime web sockets part does not use this token.

slowlydev commented 4 months ago

@mfts any other questions to, if this is "real"? Or can we close this issue?

a-bowers commented 4 months ago

A somewhat related question: I haven't looked too extensively at the code but is there a reason for having an intermediate websocket server instead of connecting directly to the F1 server and processing the data locally?

slowlydev commented 4 months ago

Hey @a-bowers thanks for the comment! So, I saw it being done in another project and adopted the approach. Now this is as u might know hurting the performance quite a bit. (In the future, I am planning to be able to provide data older than the time the user visited the website)

But today I wanted to move the code to the frontend, but I noticed u need to set cookies on the requests for the WebSocket connection to f1.

And as far as I know, this is not possible with the browser WebSocket API.

And I am not sure if "set-cookie" headers and cookies in general work on websites where:

  1. the request domain is different from the domain of the website triggering it
  2. the cookie then gets sent to the backend with a different domain

Please correct me if I am wrong...

mfts commented 4 months ago

Thanks for clarifying the API key. Looks awesome.

Tried it yesterday during qualifying but got a websocket timeout. Will try again for the race.

slowlydev commented 4 months ago

No worries and thank your very much! And yeah currently experiencing some performance issues see #57