- Notifications
You must be signed in to change notification settings - Fork7
Fetch buoy and tide information from government NDBC data using JavaScript.
License
NotificationsYou must be signed in to change notification settings
derekdowling/buoy-kit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Fetch data about buoys in the ocean with JavaScript (or TypeScript) using NOAA data sources.
- Wave information viaNDBC APIs.
- (coming soon) Tide information viaNOAA 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 iteasy to find the closest buoy(s) to a nearby location. In the mean time, you can explore the world-wide buoy map on theNDBC site and clicking on one of the squares. The number of the "Station" is the Buoy ID you would use.
This library uses theFetch API to manageHTTP requests. You'll want to importisomorphic-fetch ifyou'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');