Public
Back
Version 24
10/18/2023
const simpleSurf = (async () => {
// fetch these from the surfline page
const spotIds = [
"5842041f4e65fad6a770883f",
"5842041f4e65fad6a77088af",
"5842041f4e65fad6a77088c4",
];
const spots = spotIds.join(",");
const surfForecast = await fetch(
`https://services.surfline.com/kbyg/spots/batch?units%5BswellHeight%5D=FT&units%5Btemperature%5D=F&units%5BtideHeight%5D=FT&units%5BwaveHeight%5D=FT&units%5BwindSpeed%5D=KTS&spotIds=${spots}`,
).then((r) => r.json()).then((d) => d.data);
console.log(surfForecast);
return surfForecast.map((f) => ({
name: f.name,
link: `https://www.surfline.com/surf-report/${
f.name.toLowerCase().replace(/[\s']/g, "-")
}/${f._id}`,
waterTemp: `${f.waterTemp.min}°F`,
windSpeed: `${Math.round(f.wind.speed * 1.15078)}mph`,
windDirection: f.wind.directionType,
waveHeight: `${f.waveHeight.min}-${f.waveHeight.max}ft`,
rating: f.rating.key,
tide: {
currTideHeight: f.tide.current.height,
nextTideHeight: f.tide.next.height,
nextTideTime: f.tide.next.timestamp,
},
stream: f.streamUrl,
}));
})();
Updated: October 23, 2023