Vessels and tracks
Ships broadcast AIS: who they are, where, how fast, which way, and what they say they are doing. Three routes read one layer of those reports, and each answers a different question:
/v1/vessels— who was here: the latest position of every vessel seen in an area during a time window./v1/track— where did this one go: every position of one vessel in a window, in time order./v1/vessel— where was it last: the latest position the layer holds for one vessel.
Two more are built on the same reports: zone crossings, which turns a track into entries, exits and stays, and traffic density, which counts traffic by cell and hour.
Nothing here is a live feed. "Latest" means the last report the loaded day holds, and a sea no loaded receiver covers has no ships in it. Every answer's provenance names the source and its day, asrelease; read it before calling a position current. The examples on this page are from 31 December 2024.
A position
Every route answers with the same record, the fields AIS carries, in AIS's own units:
| Field | Is | Not available |
|---|---|---|
vessel | The MMSI, the nine-digit number a vessel's radio identifies itself by. | — |
time | The report's time, unix seconds. | — |
lat, lon | Degrees, kept to five decimals — about a metre, the source's own precision. | — |
sog | Speed over ground, tenths of a knot: 196 is 19.6 kn. | 65535, or AIS's 1023 |
cog | Course over ground, tenths of a degree from true north: 1670 is 167.0°. | 65535, or AIS's 3600 |
heading | Which way the bow points, whole degrees from true north, 0–359. | 65535, or AIS's 511 |
status | Navigational status, 0–15, as the crew set it. | 15, which is also what a missing status becomes |
There are two spellings of "not available" because sources differ. A feed decoded from raw AIS messages has AIS's not-available codes mapped to 65535; a source that recorded the codes as numbers — NOAA's files do — passes them through, and the answers below carry heading: 511 and cog: 3600.Decode by range, not by one sentinel: a speed of 1023 tenths or more, a course of 3600 or more, a heading of 360 or more are not measurements.
status | Means | status | Means |
|---|---|---|---|
| 0 | under way using engine | 8 | under way sailing |
| 1 | at anchor | 9, 10 | reserved (high-speed craft, wing-in-ground) |
| 2 | not under command | 11 | towing astern |
| 3 | restricted manoeuvrability | 12 | pushing ahead or towing alongside |
| 4 | constrained by her draught | 13 | reserved |
| 5 | moored | 14 | AIS-SART, man overboard or EPIRB active |
| 6 | aground | 15 | not defined |
| 7 | engaged in fishing |
Status is set by the crew, and often left alone or never set: the vessel in the track below makes 10 kn with status 15, not defined, and "under way using engine" at 0.0 kn is as often a ship tied up as one about to leave. Trustsog for whether a vessel is moving.
STATUS = [
"under way using engine", "at anchor", "not under command", "restricted manoeuvrability",
"constrained by her draught", "moored", "aground", "engaged in fishing", "under way sailing",
"reserved (HSC)", "reserved (WIG)", "towing astern", "pushing ahead or towing alongside",
"reserved", "AIS-SART, MOB or EPIRB active", None,
]
def decode(p: dict) -> dict:
"""A position in knots and degrees, with every not-available value as None."""
return {
"mmsi": p["vessel"],
"time": p["time"],
"lat": p["lat"],
"lon": p["lon"],
"speed_kn": p["sog"] / 10 if p["sog"] < 1023 else None,
"course_deg": p["cog"] / 10 if p["cog"] < 3600 else None,
"heading_deg": p["heading"] if p["heading"] < 360 else None,
"status": STATUS[p["status"]] if p["status"] < len(STATUS) else None,
}const STATUS = [
"under way using engine", "at anchor", "not under command", "restricted manoeuvrability",
"constrained by her draught", "moored", "aground", "engaged in fishing", "under way sailing",
"reserved (HSC)", "reserved (WIG)", "towing astern", "pushing ahead or towing alongside",
"reserved", "AIS-SART, MOB or EPIRB active", null,
];
interface Position { vessel: number; time: number; lat: number; lon: number; sog: number; cog: number; heading: number; status: number }
/** A position in knots and degrees, with every not-available value as null. */
function decode(p: Position) {
return {
mmsi: p.vessel,
time: p.time,
lat: p.lat,
lon: p.lon,
speedKn: p.sog < 1023 ? p.sog / 10 : null,
courseDeg: p.cog < 3600 ? p.cog / 10 : null,
headingDeg: p.heading < 360 ? p.heading : null,
status: STATUS[p.status] ?? null,
};
}Who was in an area
curl -G "https://api.oslew.com/v1/vessels" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'at=32.70,-117.20' \
--data-urlencode 'level=8' \
--data-urlencode 'from=1735603200' \
--data-urlencode 'to=1735606800' \
--data-urlencode 'limit=5'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.vessels(
"32.70,-117.20",
level=8,
from_=1735603200,
to=1735606800,
limit=5,
)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.vessels("32.70,-117.20", { level: 8, from: 1735603200, to: 1735606800, limit: 5 });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 293
ratelimit-reset: 1
{
"at": [
32.7,
-117.2
],
"cell": 9286052995731030016,
"level": 8,
"from": 1735603200,
"to": 1735606800,
"results": [
{
"vessel": 338049016,
"time": 1735606800,
"lat": 32.71115,
"lon": -117.23313,
"sog": 0,
"cog": 2342,
"heading": 511,
"status": 15
},
{
"vessel": 366675760,
"time": 1735606800,
"lat": 32.71775,
"lon": -117.22619,
"sog": 0,
"cog": 2316,
"heading": 511,
"status": 0
},
{
"vessel": 368115570,
"time": 1735606800,
"lat": 32.71403,
"lon": -117.22998,
"sog": 0,
"cog": 3600,
"heading": 511,
"status": 15
},
{
"vessel": 338012437,
"time": 1735606799,
"lat": 32.72632,
"lon": -117.19059,
"sog": 0,
"cog": 3600,
"heading": 511,
"status": 15
},
{
"vessel": 368235810,
"time": 1735606799,
"lat": 32.727,
"lon": -117.2022,
"sog": 0,
"cog": 419,
"heading": 275,
"status": 15
}
],
"provenance": {
"name": "noaa-ais",
"release": "2024-12-31",
"license": "public domain (US Government work)"
},
"took_us": 1362
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
| Parameter | Default | Is |
|---|---|---|
at | required | lat,lon: a point in the area. |
level | 8 | The size of the area, as a cell level, clamped to 2–16. Level 8 is about 40 km across; each level up halves it. |
from, to | the layer's span | Unix seconds, both inclusive. |
limit | 100 | Vessels to return, clamped to 1–5,000. |
The area is the cell that contains the point, not a circle around it. The point can be anywhere in that cell, including near its edge, so a ship a kilometre away across the edge is not in the answer. The answer'scell names the cell it searched; cells and levels explains how to draw it. For an area that straddles an edge, ask a coarser level, or ask from a point in each neighbouring cell.
Each vessel appears once, at its latest position inside the cell during the window — for a ship that passed through, where it was when it was last in the cell, not where it is now. Results are newest first, and limit keeps the newest. Above, five vessels off San Diego in the first hour of 31 December 2024, each last heard within a second of the window's end and all at 0.0 kn; four of them with no heading, two with no course.
Because each vessel appears once, the length of results is the exact number of distinct vessels in that cell and window, up to 5,000. That is the count traffic density can only bound, and the way to get it exactly for one cell.
Where one vessel went
curl -G "https://api.oslew.com/v1/track" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'mmsi=366749490' \
--data-urlencode 'from=1735637400' \
--data-urlencode 'to=1735641000'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.track(366749490, from_=1735637400, to=1735641000)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.track(366749490, { from: 1735637400, to: 1735641000 });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 292
ratelimit-reset: 1
{
"mmsi": 366749490,
"from": 1735637400,
"to": 1735641000,
"positions": [
{
"vessel": 366749490,
"time": 1735637483,
"lat": 32.48491,
"lon": -117.2007,
"sog": 98,
"cog": 3482,
"heading": 353,
"status": 15
},
{
"vessel": 366749490,
"time": 1735637603,
"lat": 32.49052,
"lon": -117.20172,
"sog": 101,
"cog": 3535,
"heading": 355,
"status": 15
},
{
"vessel": 366749490,
"time": 1735637694,
"lat": 32.49476,
"lon": -117.20255,
"sog": 100,
"cog": 3497,
"heading": 353,
"status": 15
},
{
"vessel": 366749490,
"time": 1735637814,
"lat": 32.50033,
"lon": -117.20354,
"sog": 103,
"cog": 3514,
"heading": 351,
"status": 15
},
{
"vessel": 366749490,
"time": 1735637902,
"lat": 32.50443,
"lon": -117.20425,
"sog": 102,
"cog": 3507,
"heading": 352,
"status": 15
}
],
"provenance": {
"name": "noaa-ais",
"release": "2024-12-31",
"license": "public domain (US Government work)"
},
"took_us": 472
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call. Shortened for the page: positions shows 5 of 35.
mmsi is required; from and to default to the layer's whole span and are inclusive. The answer is every position in the window, in time order, wherever the vessel was — a track is not limited to any area. There is no limit: the window is the only bound, so ask for the window you mean. Above, the vessel reported 35 times between 09:30 and 10:30 UTC, about every two minutes; the five shown are its first eight minutes, heading a little west of north at 10 kn, a few kilometres south of the boundary between Mexican and US waters. It crosses it at 09:47; zone crossings reads that from the same track.
A track has gaps wherever no receiver heard the ship, and nothing is interpolated across them. A straight line drawn between two fixes an hour apart is a guess about where the ship went, not a report of it.
Where it was last
curl -G "https://api.oslew.com/v1/vessel" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'mmsi=366749490'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.vessel(366749490)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.vessel(366749490);HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 292
ratelimit-reset: 1
{
"mmsi": 366749490,
"latest": {
"vessel": 366749490,
"time": 1735689548,
"lat": 32.72266,
"lon": -117.22707,
"sog": 0,
"cog": 2678,
"heading": 125,
"status": 15
},
"provenance": {
"name": "noaa-ais",
"release": "2024-12-31",
"license": "public domain (US Government work)"
},
"took_us": 243
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
The latest position the layer holds for that MMSI, or latest: null — a 200, not a404 — for a vessel it never saw, including when no AIS is loaded at all. Above, the vessel from the track is stopped in San Diego Bay at 23:59 UTC, the last it was heard that day. Compare time with the clock before you call it "now".
Putting them together
Who passed through an area in an hour, and the path each took — as GeoJSON, which wants [lon, lat]:
from oslew import Client
client = Client(base_url="https://api.oslew.com")
start, end = 1_735_603_200, 1_735_606_800
seen = client.vessels("32.70,-117.20", level=8, from_=start, to=end, limit=5_000)
features = []
for p in seen["results"]:
track = client.track(p["vessel"], from_=start, to=end)["positions"]
if len(track) < 2:
continue # a line needs two points
features.append({
"type": "Feature",
"properties": {"mmsi": p["vessel"], "positions": len(track)},
"geometry": {"type": "LineString", "coordinates": [[q["lon"], q["lat"]] for q in track]},
})
geojson = {"type": "FeatureCollection", "features": features}import { Client } from "@oslew/client";
const client = new Client({ baseUrl: "https://api.oslew.com" });
const [start, end] = [1_735_603_200, 1_735_606_800];
const seen = await client.vessels("32.70,-117.20", { level: 8, from: start, to: end, limit: 5_000 });
const features = [];
for (const p of seen.results) {
const { positions } = await client.track(p.vessel, { from: start, to: end });
if (positions.length < 2) continue; // a line needs two points
features.push({
type: "Feature",
properties: { mmsi: p.vessel, positions: positions.length },
geometry: { type: "LineString", coordinates: positions.map((q) => [q.lon, q.lat]) },
});
}
const geojson = { type: "FeatureCollection", features };Each track is its own request, and each request takes one token from the key's platform bucket — a busy cell is hundreds of them. Pace the loop to your rate rather than meeting it as 429s; seerate limits.
Refusals
- Times are unsigned 32-bit unix seconds. A negative time, or one with a fraction, does not parse, and the refusal is the framework's plain-text
400rather than JSON — see errors. fromaftertois a400,from is after to.- With no AIS layer loaded,
/v1/vesselsand/v1/trackanswer400,no trajectories layer loaded;/v1/vesselanswerslatest: null.
Endpoints
/v1/vesselsplatformEach vessel's latest AIS position in a cell around a point during a time range.