本 API 文档提供了 NOAA 潮汐与海流相关的数据查询、天文事件查询等功能,同时介绍了 FastMCP 框架,帮助开发者快速构建和部署海流与潮汐监测系统。
所有请求必须使用 GET 方法。
API 支持以下响应格式:
https://api.tidesandcurrents.noaa.gov/api/prod/tidepredictions?station=8537062
https://api.tidesandcurrents.noaa.gov/api/prod/currents?station=9410160
async function getTidePredictions(stationId) {
const response = await fetch(`https://api.tidesandcurrents.noaa.gov/api/prod/tidepredictions?station=${stationId}`);
return await response.json();
}
async function getHistoricalCurrents(stationId, date) {
const response = await fetch(`https://api.tidesandcurrents.noaa.gov/api/prod/currents/historical?station=${stationId}&date=${date}`);
return await response.json();
}
async function getWarnings(warningType) {
const response = await fetch(`https://api.tidesandcurrents.noaa.gov/dpapi/prod/alerts?type=${warningType}`);
return await response.json();
}
async function getStationInfo(stationId) {
const response = await fetch(`https://api.tidesandcurrents.noaa.gov/mdapi/prod/stations/${stationId}`);
return await response.json();
}
async function getCurrentMoonPhase() {
const response = await fetch('https://api.tidesandcurrents.noaa.gov/moon/currentphase');
return await response.json();
}
async function getNextMoonPhases(count) {
const response = await fetch(`https://api.tidesandcurrents.noaa.gov/moon/nextphases?count=${count}`);
return await response.json();
}
async function getSunriseSunset(latitude, longitude) {
const response = await fetch(`https://api.tidesandcurrents.noaa.gov/sun?lat=${latitude}&lon=${longitude}`);
return await response.json();
}
FastMCP 是一个用于开发高效、可扩展的海流与潮汐监测系统的框架。它提供了一系列工具和服务,帮助开发者快速构建和部署相关应用。
npm install fastmcp
const FastMCP = require('fastmcp');
const app = new FastMCP({
port: 3000,
plugins: ['dataCollector', 'visualizer']
});
app.start().then(() => {
console.log('Application started on port 3000');
});
app.use('dataProcessor', (data, next) => {
// 处理数据
next();
});
async function fetchCurrents() {
const response = await fetch('https://api.tidesandcurrents.noaa.gov/api/prod/currents');
return await response.json();
}
fetchCurrents().then(data => {
console.log(data);
});
项目遵循 MIT 许可证,具体内容请参考 LICENSE 文件。
感谢您使用 NOAA 潮汐与海流 API!如需更多信息,请访问我们的官方网站或查阅详细的开发者文档。