# Set and Drift API
> Current-sailing (set and drift) navigation maths as an API, computed locally and deterministically — the course-over-ground, course-to-steer and current numbers a mariner, navigator or marine app plots a passage with. The course-made-good endpoint adds the boat's velocity through the water to the current vector to give the real track: the course over ground (COG) and speed over ground (SOG), with the drift angle the current pushes you off your nose — steering 090° through the water at 10 knots with a 2-knot current setting north comes out around 079° over the ground at 10.2 knots. The course-to-steer endpoint solves the other way: the heading to steer to make good a desired ground track, steering up-current to cancel the across-track set (sin(H−T) = −drift·sin(set−track) ÷ speed), and the resulting SOG — usually slower into a current, faster with it astern, and impossible if the current across the track beats your speed. The current endpoint finds the set and drift from the offset between a dead-reckoning position and an observed fix: the set is the bearing DR-to-fix and the drift is that distance ÷ the elapsed time, ready to carry forward. Everything is computed locally and deterministically, so it is instant and private. Ideal for marine-navigation and chartplotter apps, sailing and boating tools, and maritime-training utilities. Pure local computation — no key, no third-party service, instant. Degrees true. 3 compute endpoints. For great-circle distance use a geo-distance API; for tide times a tides API.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/setanddrift-api/..."
```

## Pricing
- **Free** (Free) — 5,450 calls/Mo, 2 req/s
- **Starter** ($13/Mo) — 54,500 calls/Mo, 6 req/s
- **Pro** ($40/Mo) — 229,500 calls/Mo, 15 req/s
- **Mega** ($122/Mo) — 1,145,000 calls/Mo, 40 req/s

## Endpoints

### Nav

#### `GET /v1/course-made-good` — Course/speed over ground

**Parameters:**
- `heading_deg` (query, required, string) — Heading through the water (°T) Example: `90`
- `speed_through_water_kt` (query, required, string) — Speed through water (knots) Example: `10`
- `set_deg` (query, required, string) — Current set — direction it flows toward (°T) Example: `0`
- `drift_kt` (query, required, string) — Current drift (knots) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/setanddrift-api/v1/course-made-good?heading_deg=90&speed_through_water_kt=10&set_deg=0&drift_kt=2"
```

**Response:**
```json
{
    "data": {
        "note": "Adding the boat's velocity through the water to the current vector gives the real track over the ground: the course over ground (COG) and speed over ground (SOG). 'Set' is the direction the current flows toward and 'drift' its speed. The difference between COG and the heading is the drift angle — the current quietly pushes you off your nose, so a steady heading is not a steady track.",
        "inputs": {
            "set_deg": 0,
            "drift_kt": 2,
            "heading_deg": 90,
            "speed_through_water_kt": 10
        },
        "drift_angle_deg": -11.31,
        "speed_over_ground_kt": 10.2,
        "course_over_ground_deg": 78.69
    },
    "meta": {
        "timestamp": "2026-06-07T08:17:58.893Z",
        "request_id": "24884640-ba59-4628-9ae4-30eb952f2fcf"
    },
    "status": "ok",
    "message": "Course made good",
    "success": true
}
```

#### `GET /v1/course-to-steer` — Heading to steer for a track

**Parameters:**
- `desired_track_deg` (query, required, string) — Desired ground track (°T) Example: `90`
- `speed_through_water_kt` (query, required, string) — Speed through water (knots) Example: `10`
- `set_deg` (query, required, string) — Current set (°T) Example: `0`
- `drift_kt` (query, required, string) — Current drift (knots) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/setanddrift-api/v1/course-to-steer?desired_track_deg=90&speed_through_water_kt=10&set_deg=0&drift_kt=2"
```

**Response:**
```json
{
    "data": {
        "note": "To hold a ground track against a current you must steer up-current of it: the heading = track + the drift correction, where the correction cancels the current's across-track component (sin(H−T) = −drift·sin(set−track)/STW). The resulting speed over ground is usually slower than your speed through the water when bucking a current, and faster with it behind you. If the current is stronger than your speed across the track, no heading can hold it.",
        "inputs": {
            "set_deg": 0,
            "drift_kt": 2,
            "desired_track_deg": 90,
            "speed_through_water_kt": 10
        },
        "drift_correction_deg": 11.54,
        "heading_to_steer_deg": 101.54,
        "speed_over_ground_kt": 9.8
    },
    "meta": {
        "timestamp": "2026-06-07T08:17:58.986Z",
        "request_id": "2d89428e-6a0f-4b6d-9884-e9b23bb1e432"
    },
    "status": "ok",
    "message": "Course to steer",
    "success": true
}
```

#### `GET /v1/current` — Set & drift from a DR-to-fix offset

**Parameters:**
- `dr_to_fix_bearing_deg` (query, required, string) — Bearing DR → fix (°T) Example: `45`
- `dr_to_fix_distance_nm` (query, required, string) — Distance DR → fix (nm) Example: `3`
- `elapsed_hours` (query, required, string) — Elapsed time (hours) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/setanddrift-api/v1/current?dr_to_fix_bearing_deg=45&dr_to_fix_distance_nm=3&elapsed_hours=2"
```

**Response:**
```json
{
    "data": {
        "note": "The current is found by comparing where dead reckoning said you'd be with where a fix actually puts you: the set is the bearing from the DR position to the fix (the way the current pushed you) and the drift is that distance ÷ the elapsed time. So a fix 3 nm at 045° from a 2-hour DR means a current setting 045° at 1.5 knots — carry it forward to correct the next leg.",
        "inputs": {
            "elapsed_hours": 2,
            "dr_to_fix_bearing_deg": 45,
            "dr_to_fix_distance_nm": 3
        },
        "set_deg": 45,
        "drift_kt": 1.5
    },
    "meta": {
        "timestamp": "2026-06-07T08:17:59.084Z",
        "request_id": "df9e9382-2894-40ac-a862-fb8b5c4be2f9"
    },
    "status": "ok",
    "message": "Set and drift",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/setanddrift-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "notes": "Degrees true, knots, nm, hours. COG/SOG by vector addition; course to steer from sin(H−T) = −drift·sin(set−track)/STW; current set = DR→fix bearing, drift = distance/time. Set is the direction the current flows toward. For great-circle distance use a geo-distance API; for tide times a tides API.",
        "service": "setanddrift-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/current": "Set & drift from a DR-to-fix offset.",
            "GET /v1/course-to-steer": "Heading to steer to hold a desired ground track.",
            "GET /v1/course-made-good": "Course and speed over ground from heading and current."
        },
        "description": "Current-sailing (set & drift) navigation: course/speed over ground, course to steer, and set & drift from a fix."
    },
    "meta": {
        "timestamp": "2026-06-07T08:17:59.170Z",
        "request_id": "9501d5d6-1a42-473b-9550-9923e4e4d20d"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/setanddrift-api
OpenAPI spec: https://www.oanor.com/api/setanddrift-api/openapi.json
