docs

    SDKs & Libraries

    Install the official SDK or integrate directly with any HTTP client.

    OpenAPI Specification

    The entire public HTTP surface is described by a machine-readable OpenAPI 3.1 spec at https://api.chrt.co/openapi.json — public, unauthenticated, and CI-verified against production. Non-JavaScript clients (Swift, Kotlin, Python, Go) should generate a typed client from it rather than hand-rolling requests.

    terminal
    # Swift (swift-openapi-generator): add the plugin, then
    curl -o openapi.json https://api.chrt.co/openapi.json
    
    # Or any language via openapi-generator:
    npx @openapitools/openapi-generator-cli generate \
      -i https://api.chrt.co/openapi.json -g swift5 -o ./CHRTClient

    The spec is the canonical parameter vocabulary — where these docs and the spec disagree, the spec wins. Compliance fields (attribution, disclaimer, notice, coverage) are required in every response schema.

    Install

    terminal
    npm install @chrtco/sdk

    Zero dependencies · Node 18+ · Browsers · Deno · Bun · Full TypeScript types

    Quick Start

    quickstart.ts
    import { Chrt } from '@chrtco/sdk';
    
    const chrt = new Chrt('chrt_sk_live_...');
    
    // Get depth areas in a bounding box
    const features = await chrt.features({
      bbox: [-71, 42, -70, 43],
      layer: 'DEPARE',
    });
    console.log(`Found ${features.features.length} features`);
    
    // Find nav aids near a position
    const nearby = await chrt.query({
      point: [-70.86, 42.02],
      radius: 2000,
    });

    MapLibre GL JS / Mapbox GL JS

    The SDK includes built-in helpers that work with MapLibre GL JS (recommended) and Mapbox GL JS — no manual header wiring needed. Examples use MapLibre; substitute maplibre-gl → mapbox-gl if you're already on Mapbox.

    map-integration.ts
    import maplibregl from 'maplibre-gl';
    import { Chrt } from '@chrtco/sdk';
    
    const chrt = new Chrt('chrt_sk_live_...');
    
    const map = new maplibregl.Map({
      container: 'map',
      style: chrt.style({ palette: 'DAY' }),
      center: [-70.25, 43.66],
      zoom: 12,
      transformRequest: chrt.transformRequest(),
    });

    React Hook

    useChrtMap.tsx
    import { useEffect, useRef } from 'react';
    import maplibregl from 'maplibre-gl';
    import { Chrt } from '@chrtco/sdk';
    
    const chrt = new Chrt(import.meta.env.VITE_CHRT_API_KEY);
    
    export function useChrtMap(containerRef: React.RefObject<HTMLDivElement>) {
      const mapRef = useRef<maplibregl.Map | null>(null);
    
      useEffect(() => {
        if (!containerRef.current) return;
    
        const map = new maplibregl.Map({
          container: containerRef.current,
          style: chrt.style({ palette: 'DAY' }),
          center: [-70.25, 43.66],
          zoom: 12,
          transformRequest: chrt.transformRequest(),
        });
    
        mapRef.current = map;
        return () => map.remove();
      }, []);
    
      return mapRef;
    }

    SDK API Reference

    Features

    features.ts
    const features = await chrt.features({
      bbox: [-71, 42, -70, 43],
      layer: 'LIGHTS',   // optional S-57 layer filter
      limit: 50,         // default 100
      offset: 0,         // pagination
    });

    Spatial Query

    query.ts
    const nearby = await chrt.query({
      point: [-70.86, 42.02],
      radius: 2000,                // metres, default 500 (max 50,000)
      layer: 'BOYCAR,BOYLAT',     // optional
    });

    What's ahead

    The significant charted features in a sector from a point along a bearing — for a craft that has a heading but no planned route. See Spatial Queries.

    ahead.ts
    const fan = await chrt.ahead({
      point: [-70.9245, 42.33604],
      bearing: gps.cog,   // degrees true
      arc: 60,            // FULL sector width, so ±30°
      rangeNm: 3,         // or range: 5556 (metres)
      safetyDepth: 3,     // your draft plus a margin
    });
    
    // An empty result is NOT an all-clear — it may mean there is no chart here.
    if (!fan.coverage.covered) { /* say so; do not report "clear" */ }
    
    for (const f of fan.features) {
      const { distance_m, bearing_deg, depth_clearance_m } = f.properties;
      // negative depth_clearance_m = shallower than you declared safe
    }

    Along a route

    The same question for a planned passage — a corridor either side of the track, ordered by how far into the passage you meet each feature.

    along-route.ts
    const passage = await chrt.alongRoute({
      route: [[-70.95, 42.33], [-71.0, 42.35], [-71.02, 42.36]],
      bufferNm: 0.5,      // or buffer: 926 (metres)
      safetyDepth: 3,
    });
    
    for (const f of passage.features) {
      const { along_m, distance_m, depth_clearance_m } = f.properties;
    }
    
    // Auto-paginate every feature along the route:
    for await (const f of chrt.alongRouteIter({ route, bufferNm: 0.5 })) { /* … */ }

    Charts a passage needs

    A different question, so a different call: which ENC cells cover a route, largest scale first, with the currency of each.

    coverage-route.ts
    const { cells } = await chrt.coverage.forRoute({
      route: [[-70.95, 42.33], [-71.0, 42.35]],
      bufferNm: 1,
    });
    
    for (const c of cells) {
      console.log(c.cell_id, c.edition, c.update_number, c.issue_date);
    }

    Your vessel

    Set the safety depth once and every depth-aware call inherits it — the query filters at it, and the generated style shades soundings and draws danger rings at it. An explicit per-call value still wins.

    vessel.ts
    const chrt = new Chrt({ apiKey, vessel: { safetyDepthM: 3 } });
    
    await chrt.ahead({ point, bearing });   // filters at 3 m
    chrt.style();                           // labels + danger rings at 3 m

    It's client-side and per-instance, deliberately — not bound to your API key. A consumer app has one key and many skippers with different boats, so construct a Chrt per user. With no profile CHRT sends no depth at all rather than guessing a draft.

    Cells

    cells.ts
    // List cells — 'source' is the chart-source id, not the agency name
    // ('NOAA' matches nothing and returns an empty list). See Coverage below.
    const cells = await chrt.cells.list({ source: 'NOAA_ENC', limit: 20 });
    
    // Filter by usage band (case-sensitive) or bounding box
    const harbors = await chrt.cells.list({ scaleBand: 'Harbor' });
    const nearBoston = await chrt.cells.list({ bbox: [-71, 42, -70, 43] });
    
    // Get specific cell
    const cell = await chrt.cells.get('US5MA11M');
    console.log(cell.bbox_north);      // number | null — bounds are flat, as on coverage.forRoute()
    console.log(cell.edition);         // the edition CHRT holds and serves for this cell
    console.log(cell.last_checked_at); // a lower bound on the last check against the issuing office

    Coverage

    coverage.ts
    // List available chart sources with cell counts. 'source' is the id you
    // filter on; 'agency' is the issuing office's display name.
    const coverage = await chrt.coverage.list();
    console.log(coverage.sources);   // [{ source: 'NOAA_ENC', agency: 'NOAA', country: 'US', ... }]
    console.log(coverage.total_cells);
    
    // Filter by country
    const us = await chrt.coverage.list({ country: 'US' });
    
    // Filter by source id
    const noaa = await chrt.coverage.list({ source: 'NOAA_ENC' });

    Tiles

    tiles.ts
    // CHRTstyle style object for MapLibre / Mapbox GL
    // symbolSet: 's52' (default) | 's101' | 'chrt' | 'int1' | 'uschart1'
    //   ('raster' is int1's earlier id, still accepted) — every family is free on every plan
    // look: 'paper' | 'engraved' | 'handcolored' — over 'DAY' only
    const style = chrt.style({ palette: 'DAY', symbolSet: 's52' });   // 'DAY' | 'DUSK' | 'NIGHT' | 'EINK_COLOR' | 'EINK_MONO' | 'EINK_NIGHT' (e-ink screens)
    
    // transformRequest mints the tile JWT and attaches it on tile requests
    const transformRequest = chrt.transformRequest();
    
    // Optional: pre-mint to surface auth errors before the map loads
    await chrt.warmTiles('NOAA_ENC');

    Interact (Dev plan and above)

    interact.ts
    // Click-to-inspect: decoded popups/events on any GL map showing CHRT tiles.
    // Entitlement is checked server-side — Free keys get InteractError
    // code 'interact_not_enabled'.
    const handle = await chrt.interact.attach(map, {
      onInspect: (result) => console.log(result.title, result.notice.dataCurrency),
    });
    
    // Headless decode + full properties & cell data currency (metered)
    const detail = await chrt.interact.inspect(feature, { enrich: true });

    Full guide: CHRTinteract documentation.

    Offline (Pro plan and above)

    offline.ts
    // Download an MBTiles bundle for offline rendering. Entitlement is
    // checked server-side at mint — Free/Dev keys get OfflineError code
    // 'offline_requires_pro_plan'. Requires deviceId in the client config.
    const result = await chrt.offline.download('NOAA_ENC', {
      path: './noaa.mbtiles',
      fs,                                     // e.g. nodeFileSystemAdapter()
      onProgress: (p) => console.log(p.fraction),
    });
    // Resumable + SHA-256 verified before the file is committed
    console.log(result.sha256, result.resumed);
    
    // A style pointed at the local bundle
    const { style } = await chrt.offline.fetchStyle('NOAA_ENC', { palette: 'DAY' });
    
    await chrt.offline.heartbeat({ fs });   // call while online; no auto-scheduler in v1

    Full guide: CHRToffline documentation.

    Auto-Pagination

    The SDK provides async iterators that automatically paginate through large result sets. No need to manage offsets manually.

    Iterate Features

    iterate-features.ts
    // Automatically fetches all pages
    for await (const feature of chrt.featuresIter({
      bbox: [-74, 40, -73, 41],
      layer: 'DEPARE',
      limit: 100,   // page size (default 100)
    })) {
      console.log(feature.properties);
    }
    
    // Supports AbortSignal for cancellation
    const controller = new AbortController();
    for await (const feature of chrt.featuresIter({
      bbox: [-74, 40, -73, 41],
      signal: controller.signal,
    })) {
      if (someCondition) controller.abort();
    }

    Iterate Cells

    iterate-cells.ts
    // Page through all cells from a source
    for await (const cell of chrt.cellsIter({ source: 'NOAA_ENC' })) {
      console.log(cell.cell_id, cell.title, cell.scale_band);
    }

    Webhooks

    Parse and validate incoming webhook payloads with the parseWebhook helper. Supported event types: cell.updated, cell.new, cell.deleted.

    webhook-handler.ts
    import { parseWebhook } from '@chrtco/sdk';
    
    // Express / Node.js example
    app.post('/webhooks/chrt', (req, res) => {
      const event = parseWebhook(req.body);
    
      switch (event.type) {
        case 'cell.updated':
          console.log('Updated:', event.data.cell_id);
          console.log('Edition:', event.data.previous_edition, '→', event.data.edition);
          break;
        case 'cell.new':
          console.log('New cell:', event.data.cell_id, event.data.title);
          break;
        case 'cell.deleted':
          console.log('Deleted:', event.data.cell_id);
          break;
      }
    
      res.sendStatus(200);
    });

    Error Handling

    errors.ts
    import { Chrt, ChrtError } from '@chrtco/sdk';
    
    try {
      await chrt.features({ bbox: [-71, 42, -70, 43] });
    } catch (e) {
      if (e instanceof ChrtError) {
        console.error(e.status, e.code, e.message);
        // e.status: 401, 403, 429, etc.
        // e.code:   matches /docs/error-codes
      }
    }

    Configuration

    config.ts
    import { Chrt } from '@chrtco/sdk';
    
    // Simple — just an API key
    const chrt = new Chrt('chrt_sk_live_...');
    
    // Advanced — full config object
    const chrt2 = new Chrt({
      apiKey: 'chrt_sk_live_...',
      baseUrl: 'https://api.chrt.co/v1',  // default
      retries: 2,                          // retry on 5xx
    });

    Without the SDK

    The CHRT API is a standard REST API — you can use any HTTP client. Pass your key via the x-api-key header.

    Python

    chrt_example.py
    import requests
    
    API_KEY = "chrt_sk_live_..."
    BASE = "https://api.chrt.co/v1"
    headers = {"x-api-key": API_KEY}
    
    # Features in a bbox
    res = requests.get(f"{BASE}/features", headers=headers, params={
        "bbox": "-71,42,-70,43",
        "layer": "LIGHTS",
        "limit": 50,
    })
    data = res.json()
    print(f"Found {len(data['features'])} lights")

    cURL

    Fetch features via cURL
    curl
    curl "https://api.chrt.co/v1/features?bbox=-71,42,-70,43&layer=DEPARE&limit=5" \
      -H "x-api-key: YOUR_API_KEY"
    response
    {
      "type": "FeatureCollection",
      "features": [
        {
          "type": "Feature",
          "geometry": { "type": "Polygon", "coordinates": [[...]] },
          "properties": {
            "layer": "DEPARE",
            "DRVAL1": 0,
            "DRVAL2": 3.5,
            "cell_id": "US5MA11M"
          }
        }
      ],
      "total_count": 847,
      "limit": 5,
      "offset": 0
    }

    CORS

    The CHRT API supports CORS for all origins. You can make requests directly from browser-based applications without a proxy server. For domain-restricted API keys, add your domains in the key settings at /app/keys.

    For situational awareness only — not for primary navigation. CHRT is not an ECDIS and is not SOLAS-compliant.

    CHRT uses only the cookies and local storage the site needs to work — keeping you signed in, remembering your preferences, and protecting the forms. There is no analytics, no advertising and no cross-site tracking, so there is nothing here to opt out of. Privacy Policy