APIs
Vessel tracking API
A vessel tracking API turns AIS — the position reports ships broadcast by radio — into answers about who was where and when. oslew reads a loaded AIS layer five ways: every vessel seen in a cell during a time window, one vessel’s full track, its last known position, its entries into and exits from maritime zones, and traffic density by cell and hour. Report counts are exact; distinct-vessel counts over a larger area come back as a [min, max] bound, because the summed data cannot honestly say more.
Last reviewed
AIS was designed so ships could see each other, not so analysts could count them. Every report is a nine-digit identity, a position, a speed and a course, sent more often under way than at anchor, and heard only where a receiver is listening. These routes keep that raw material intact and add the reductions most questions need, while being explicit about what a gap in reception or a sum of cells can and cannot tell you.
Five questions, five routes
| Route | Answers | Bounded by |
|---|---|---|
GET /v1/vessels |
Who was in this cell during this window, one row per vessel at its latest position there | limit, up to 5,000 vessels |
GET /v1/track |
Every position one vessel reported in a window, in time order | The window only |
GET /v1/vessel |
The latest position the layer holds for one vessel | — |
GET /v1/crossings |
When one vessel entered and left each zone, and how long it stayed | The window |
GET /v1/aggregate |
How busy each cell was in each time bucket | limit, up to 10,000 rows |
All five read the same loaded layer and answer with the same position record, so a vessel found in one route can be followed into the others by its MMSI.
Reading a position
Positions keep AIS’s own encoding. Speed over ground, sog, is in tenths of a knot; course over ground, cog, is in tenths of a degree from true north; heading is whole degrees for where the bow points; status is the navigational status the crew set. Latitude and longitude are kept to the source’s own precision.
Two practical points follow. First, not-available is a range, not one value. Some sources map AIS’s unavailable codes to one sentinel and others, NOAA’s files among them, pass the original codes through. Decode by range — a heading beyond a full circle is not a measurement — rather than by checking for a single number. Second, status lags reality. Crews often leave it alone, so a ship reporting “under way using engine” at zero knots may be about to sail or may simply never have been updated. Speed is the better evidence of motion.
Who was in an area
/v1/vessels takes a point and a level, and searches the cell at that level containing the point — a square, not a circle drawn around the coordinate. A point near the cell’s edge will not see a ship just across it; the answer’s cell names the square that was searched, and a coarser level or a second query from the neighbouring cell covers a straddling area.
Each vessel appears once, at the last position it reported inside the cell during the window. For a ship that passed through, that is where it was when it left, not where it is now. Results are newest first, and limit keeps the newest. Because every vessel appears only once, the length of the list is an exact count of distinct ships in that cell and window, which is the figure the density route can only bound.
One vessel’s track and last fix
/v1/track returns every report for an MMSI between from and to, wherever the ship went; it is not confined to any area and has no result limit, so the window you choose is the size of the answer. Gaps appear wherever no receiver heard the vessel, and nothing is drawn across them. A straight line between two fixes an hour apart is a guess, and a map should show it as one.
/v1/vessel answers the last report the layer holds for that MMSI. A vessel the layer never saw returns latest: null with status 200, the same as when no AIS is loaded, so treat null as “unknown here” rather than “does not exist”.
Entries, exits and dwells
/v1/crossings evaluates a vessel’s track against zone polygons and reduces hundreds of fixes to a handful of events. A crossing is a change of membership, with entered true or false and the first fix on the new side; at_start marks a track that began inside a zone, so its arrival time is unknown. A dwell is the stay between, with its first and last fixes inside and open set when the track ended inside.
By default the zones are the maritime divisions, and each one is a country’s whole claim — land plus territorial sea — rather than an exclusive economic zone. The same polygons appear in the administrative chain from the boundaries API. With zones=all, every divisions layer the deployment carries is tested, so one arrival can be a country, a region, a locality and a time zone at once.
Membership is judged only at fixes. A ship that dipped into a zone and out again between two reports shows neither event, and a ship running along a boundary flickers across it at every fix. The time of a crossing is the first fix on the new side, so the true moment lies somewhere in the gap before it. Joining a vessel’s stops to the places they happened is a workflow of its own, set out in port call reporting.
Traffic density
/v1/aggregate answers “how busy”, not “who”. It reads a cube summed in advance by small cell and clock hour. in_level picks the region around a point, level the output cells inside it, and bucket the time step in whole hours. Each row gives exact positions and moving report counts, a mean_sog_kn averaged per report, and vessels_min with vessels_max.
Report counts add up exactly at any level and any bucket. Distinct vessels do not: a ship that spends three hours in one small cell is counted in three cube entries, and the cube records how many ships each entry saw but not which. So the answer states the honest range — at least the busiest single entry, at most the sum of all of them — and leaves the midpoint alone, because it estimates nothing. At the finest level and a one-hour bucket each row is one entry and the bounds are equal.
Rows are sorted by cell and then time, and limit cuts that order, so a truncated answer holds the first cells by id rather than the busiest. If the row count lands on the limit, narrow the region or the window and sort by traffic yourself. Rows exist only where there was traffic, and cell ids are 64-bit integers that JavaScript prints rounded unless converted with BigInt. To draw density, the maps API supplies a basemap to lay the cells over.
Coverage and licence
What these routes can see depends entirely on the AIS data loaded into the deployment: its receivers, its dates and its release, all named in provenance. An empty cell may be quiet water or water no receiver covered, and the answer cannot tell those apart. Positions from NOAA are public domain (US Government work), so they may be stored and republished. The maritime zones are ODbL-1.0, because Overture publishes its Divisions theme under the ODbL: the zones may be stored beside your crossing log, but a database derived from them that you share must stay under the ODbL and name its source. The licensing page lists every layer.
What it costs
The five routes are in the Platform product: $699 a month for 20 requests a second sustained, burst 100, with no monthly quota. Each track is its own request, so walking every vessel in a busy cell is many requests; pace that loop to the rate rather than meeting it as HTTP 429 responses. The pricing page compares the plans that include Platform.
Limits worth knowing
- No live feed is implied. Answers are as current as the loaded AIS, and “latest” means the latest report the layer holds.
- Vessel identity is the MMSI alone; names, call signs, dimensions and flags are not part of the answer.
- Zones for crossings are the loaded divisions only; custom polygons are tested in your own code.
- Distinct vessels in density rows are a bound except at the finest cell and a one-hour bucket.
- Times are unsigned 32-bit unix seconds, and a malformed time is refused before it reaches the service’s own validation.
Bottom line
Use /v1/vessels to find ships in a cell, /v1/track and /v1/vessel to follow one, /v1/crossings to turn a track into entry and exit events, and /v1/aggregate for traffic volume. Trust report counts as exact, draw vessel counts as a range, read provenance before calling anything current, and remember that an absence of ships is only as meaningful as the receivers behind the data.
Questions
Where does the AIS data come from?
From whatever AIS the deployment has loaded, and each answer’s provenance names that source and its release. The layer behind the documentation’s examples is NOAA’s MarineCadastre AIS, which is public domain (US Government work) and reflects what US coastal receivers heard. A sea that no loaded receiver covered has no ships in the answers, however busy it really is.
Can I get the current position of any ship?
You get the latest position the loaded layer holds for that MMSI, with the time it was reported. That is only the present if the deployment loads a current feed, so compare the time with the clock before calling it where the ship is now. A vessel never seen answers latest as null, with status 200.
Why is the number of vessels in a density row a range?
Density rows are summed from small cells and single hours, each of which records how many vessels it saw but not which. One ship lingering for three hours and three ships passing once look the same once summed, so the answer gives the smallest and largest counts consistent with the data rather than guessing between them.
Can I check crossings against my own zones?
Not as an API input. The crossings route evaluates the maritime zones, or every divisions layer the deployment has loaded when zones=all. For your own port or terminal polygons, pull the track and test its positions against your shapes in your own code.
How do I get an exact count of distinct ships in an area?
Ask /v1/vessels for the cell and time window you care about. It returns each vessel once, so the number of results is the exact distinct count, up to its limit of 5,000 vessels. The density route is exact only at its finest cell and a one-hour bucket.