Fetch data about buoys in the ocean with JavaScript (or TypeScript) using NOAA data sources.
- Wave information via NDBC APIs.
- (coming soon) Tide information via NOAA Tide API
- TypeScript support
yarn add buoy-kit
fetchBuoyRealTimeData
fetches, parses, and returns realtime2 station data (.txt extension):
import { fetchBuoyRealTimeData, BuoyData } from 'buoy-kit';
export async function getBuoy(buoyID: string): Promise<BuoyData> {
let buoyData: BuoyData;
try {
buoyData = await fetchBuoyRealTimeData(buoyID: string);
} catch (e) {
console.log(e);
}
return buoyData;
}
There are plans to make it easy to find the closest buoy(s) to a nearby location. In the mean time, you can explore the world-wide buoy map on the NDBC site and clicking on one of the squares. The number of the "Station" is the Buoy ID you would use.
This library uses the Fetch API to manage HTTP requests. You'll want to import isomorphic-fetch if you're using this library in a Node environment.
yarn add isomorphic-fetch
Then in your server's initialization file, polyfill Fetch via:
require('isomorphic-fetch');