Skip to main content
Glama
README.md
# @shadojus/open-air-sea

Zero-dependency **ADS-B aircraft transponders**, **NOAA NDBC wave buoys** and **harmonic tides** — as a Node library, REST API, CLI and MCP server. Python port in [`python/`](python), radar UI in [`docs/`](docs).

- Seed: 62 real NDBC buoy stations, 42 CO-OPS tide stations, 16 sample ADS-B states (works offline).
- Live adapters (HTTPS, host allowlist, 8 s timeout, 2 MB cap, automatic seed fallback):

| Source | License |
|---|---|
| [ADSB.lol](https://api.adsb.lol) `/v2/point/{lat}/{lon}/{radiusNm}` | ODbL-1.0 |
| [NOAA NDBC Realtime2](https://www.ndbc.noaa.gov/data/realtime2/) | Public Domain |
| [NOAA CO-OPS](https://api.tidesandcurrents.noaa.gov/api/prod/datagetter) (`predictions`, MLLW, `hilo`, metric) | Public Domain |

> Seed observations/aircraft are illustrative samples and seed tides use a single M2 harmonic approximation. Use `live: true` for real data. **Not for navigation.**

## Library

```js
import { aircraftNear, buoysNear, getBuoyObservation, tideStationsNear, getTidePredictions } from '@shadojus/open-air-sea';

await aircraftNear(40.7, -74, { radiusNm: 50, live: true });  // hex, flight, altBaroFt, groundSpeedKt, trackDeg, verticalRateFpm, squawk, category
buoysNear(40.5, -69.5, { radiusKm: 300, limit: 5 });
await getBuoyObservation('44008', { live: true });            // waveHeightM, dominantPeriodSec, waterTempC, windSpeedKts, pressureHpa
tideStationsNear(40.7, -74);
await getTidePredictions('8518750', { live: true });          // [{ time, type: 'H'|'L', heightM }]
```
All live functions accept `fetchImpl` for injection/testing. Types in `src/index.d.ts`.

## CLI / server / MCP

```sh
npx open-air-sea buoys 40.5 -69.5 --limit 3
npx open-air-sea tide 8518750 --live
node src/server.mjs            # PORT, HOST, TRUST_PROXY=1
node src/mcp.mjs               # MCP 2024-11-05 over stdio
```

REST: `/health`, `/openapi.json` (3.1.0), `/v1/aircraft/near?lat&lng&radiusNm&live`, `/v1/buoys/near`, `/v1/buoys/:id`, `/v1/tides/near`, `/v1/tides/:id`, `/v1/sources`. Responses carry `ETag` (`If-None-Match` → `304`); per-client rate limit with IPv6 clients bucketed by `/64` (`429` + `Retry-After`).

MCP tools: `aircraft_near`, `buoys_near`, `buoy_observation`, `tide_stations_near`, `tide_predictions`.

## Development

```sh
npm test                      # node:test, no network
node tools/build-data.mjs     # data/air-sea.db via node:sqlite (Node >= 22.5)
node tools/gen-seed.mjs       # regenerate data/seed.json
python -m unittest discover -s python/tests -t python
```

MIT © Shadojus. Data licenses per source above.