# Gillby SDK & CLI · 0.1.0

A dependency-free ESM JavaScript client, TypeScript declarations and a Node.js CLI for Gillby's v1 HTTP API. Node.js 20+ for the CLI; the SDK also works in modern browsers with Fetch, URL and AbortController. Public marine data needs no API key.

## Install the downloadable release

```sh
npm install https://www.gillby.com/downloads/onewave-ai-gillby-0.1.0.tgz
```

This is a Gillby-hosted tarball, not a claim that the package is published in the npm registry. The installed package name is `@onewave-ai/gillby` and its executable is `gillby`.

## JavaScript / TypeScript

```js
import { Gillby, GillbyError } from '@onewave-ai/gillby';

const gillby = new Gillby();
const result = await gillby.getConditions('boca-inlet', { view: 'summary' });
console.log(result.data);
console.log(result.meta); // Preserve sources, timestamps and unavailable states.
```

Helpers: `listSpots(query?)`, `getSpot(id)`, `getConditions(spot, query?)`, `getForecast(spot, {hours: 24})`, `getTides(spot, {days: 3})`, `getHazards(spot)`, `listDatasets(query?)`. Helpers accept an optional final `{signal}`. They return the complete JSON response; values are not normalized or invented. Response data defaults to TypeScript `unknown`; provide your own validated endpoint type as a generic when appropriate.

```js
// Other documented v1 endpoints: use the exact path and inputs from OpenAPI.
const result = await gillby.request('/conditions', {
  query: { spot: 'boca-inlet', view: 'summary' },
  signal: new AbortController().signal,
});
```

`new Gillby({baseUrl, timeoutMs, token, fetch})` supports a custom origin, timeout (default 15 seconds), an optional OAuth token or async token provider, and an injectable Fetch implementation. Use HTTPS; HTTP is accepted only for loopback development. Request paths are relative to `/api/v1`, not arbitrary external URLs. Redirects fail rather than forwarding authorization.

Personal endpoints require a valid Gillby OAuth token and explicit consent; this package does not implement the sign-in flow or store credentials. Keep tokens out of source control and chat. In a browser, use an appropriate short-lived session/token flow; do not bundle secrets. The SDK's generic `request` supports documented POST/PATCH/PUT/DELETE requests when explicitly needed. The caller owns validation and authorization of mutations; the SDK does not auto-retry any request.

## CLI

```sh
npx --no-install gillby spots
npx --no-install gillby conditions --spot boca-inlet --view summary
npx --no-install gillby forecast --spot boca-inlet --hours 24
npx --no-install gillby tides --spot boca-inlet --days 3
npx --no-install gillby hazards --spot boca-inlet
npx --no-install gillby request /conditions --query spot=boca-inlet --query view=summary --compact
```

Run these commands inside the project where you installed the tarball. `npx` resolves the local installed binary; do not assume an independently published registry package exists. For a global install, use `npm install -g` with the same tarball URL, then `gillby ...`.

Options: `--base-url URL`, repeatable `--query key=value`, `--compact`, `--timeout-ms NUMBER`, `--help`, `--version`. Environment: `GILLBY_BASE_URL`, optional `GILLBY_TOKEN`. No token command-line flag or credential store. The CLI only makes GET requests. JSON results go to stdout; diagnostics go to stderr. Exit codes: 0 success, 1 request/API failure, 2 usage error. Pipe JSON to `jq` if desired.

## Errors and limits

`GillbyError` exposes `status`, `code`, `details` and `retryAfter` (seconds when supplied by the server). Network failures and cancellations retain the underlying Fetch error. No automatic retry is performed. Respect rate limits and Retry-After; back off and cache appropriately. Missing upstream data is not replaced by a zero or a guess. See https://www.gillby.com/developers for current limits and full contracts.

## Development

```sh
node --test distribution/gillby-sdk/test/*.test.mjs
node scripts/distribution/package-gillby-sdk.mjs
```

Release packaging creates the versioned tarball, an SHA-256 checksum and a release manifest in `public/downloads`. The package has no install scripts or runtime dependencies. Code license: MIT. Hosted API access, attribution, commercial usage and upstream data rights are governed separately by Gillby's terms: https://www.gillby.com/terms.

## Hurricanes and full historical tracks

The public API includes `get_hurricanes` for active NHC cyclones and `get_hurricane_history` for 2000–2025 HURDAT2 history (973 cyclones, 27,812 records). Use the existing generic request method; no new SDK installation is needed:

```js
const result = await gillby.request('/tools/get_hurricane_history', {
  query: { id: 'al122005', includeTrack: true },
});
// Each storm has its full recorded track from first observation to last.
console.log(result.data, result.meta);
```

```sh
npx --no-install gillby request /tools/get_hurricane_history --query id=al122005 --query includeTrack=true
```

Optional filters include `basin`, `startYear`, `endYear`, `name`, `id`, `hurricanesOnly` and `landfallOnly`. Summaries are paginated with `limit`, `offset` and returned `nextOffset`. Tracks include UTC times, coordinates, sustained wind in knots, pressure in millibars and landfall flags. Preserve null measurements. Read the [complete hurricane guide](https://github.com/OneWave-AI/gillby-mcp/blob/main/HURRICANES.md) for field meanings and limitations.
