@coopersamuel @rschenk Thanks a lot for the awesome project.
I wanted to point you to my app https://github.com/fabriziobertoglio1987/surf-rails which includes all surfspots in the world, but surf forecast are not built so well...
You can consume them with my api.
I read your messages from https://www.reddit.com/r/surfing/comments/a3rh3n/for_those_of_you_who_like_to_play_with_buoy_data/
Itβs pretty simple. The buoys expose the raw energy spectra so you take the energy spectra and split it and solve for wave height as a function of frequency and power. I can link to the exact math I use to do it if you want
I'll prob write a blog post this weekend about it from a high level
But if you understand code heres a simple breakdown.. look here for parsing
|
def parse_wave_spectra_reading_data(self, energy_data, directional_data, count_limit): |
and here for math
|
def swell_components(self): |
From the rest of the discussion I find out about the magicseaweek-cli which allows you to scrape msw.... Probably that the best solution once you have all the surfspots information from my api... I will probably give up on calculating surf forecast and just retrieve them via api from MSW.
But I am not sure if all the information from my backend are available while scraping the api, for example degrees direction of swell and wind, as you can check in my mobile app I use them to display and arrow with the wind.. Additionally I calculate for almost 90% of the spots the optimal wind/swell direction .. and many other things that by scraping MSW would not be possible (like calculating long term surf forecast in the future using AI)
Edit: https://github.com/rschenk/surfdash/tree/master/lib the two files you're interested in are new_surfline_scraper.rb and surfline_county_scraper.rb
Ya! So it's kind of a pain in the butt to figure out because surfline's api is a mess. I think that they recently updated their id system, because each spot has two ids (a four digit one, that I think is legacy, and a longer one (looks like 12 bytes) this is the one you want)
Basically, what I do is find a spot id with a searchterm (ie "hanalei") from here https://services.surfline.com/search/site?q=hanalei&querySize=10&suggestionSize=10 then use that spot id (you'll have to dig it out of the response) to get the forecast for that spot. There is an overall forecast endpoint that gives you wind, swell and conditions for 17 days out. However, I find that one more difficult to use b/c it requires the legacy spot ID, go for the individual forecast endpoints instead, described below.
There are individual endpoints for wind (https://services.surfline.com/kbyg/spots/forecasts/wind?spotId=5842041f4e65fad6a7708b2c&days=1), swell (https://services.surfline.com/kbyg/spots/forecasts/wave?spotId=5842041f4e65fad6a7708b2c&days=1) and conditions (https://services.surfline.com/kbyg/spots/forecasts/conditions?spotId=5842041f4e65fad6a7708b2c&days=1) that you can use with that spot id. You'll have to decipher the response, IIRC, each of these three has a different structure but the same idea. The swell forecast has a min and max for every two hours all the way up to 17 days out(specify the number of days you want), wind has a value for every hour, and I think conditions is once or twice a day. Hope this helps! Go ahead and plug all of the reqs into postman, they should work.
Edit: You can also take a look at the network tab in the dev tools on the Surfline site to see what requests it's making - IIRC it does the above, makes a request to all three apis.
Edit 2: Also, if you want to contribute to my (unfortunately unfinished) project, here's the repo: https://github.com/coopersamuel/seaweed-cli
For the surfforecast I pull data from stormglass.io but I am not very accurate. stormglass.io does not provide long term surf forecasts. I wonder if Machine Learning models are used to calculate the long term forecasts...
I decided to post this here and unify our efforts as surfforecasting is very complex field... maybe we could build a bunch of apis and make a unified repository/documentation for it ...
or any other ideas, I'm willing to work weekend on them...
other interesting repositories
https://github.com/rschenk/surfdash
https://github.com/coopersamuel/seaweed-cli
Thanks a lot
Fabrizio Bertoglio
https://fabriziobertoglio.xyz