Track Vessel MMSI Changes With an API in Python
A vessel can appear in your tracking system under one MMSI and later return under another. If your database uses MMSI as its only identifier, that update can split one ship into two records. Your dashboard may show a new vessel while the original record stops receiving updates.
To track vessel MMSI changes, compare repeated vessel lookups using the IMO number as your reference. This lets you detect a different MMSI against the same IMO and keep the change available for review.
This post walks through that approach with Datalastic’s vessel info. It is useful for fleet monitoring, maintaining internal vessel records, and investigating changes in the identifiers returned by the API.
The basic workflow is simple: save a dated snapshot, look up the same IMO again, and compare the MMSI values. A difference is an observed identifier update. It does not explain why that update happened.
What the vessel info endpoint actually returns?
The vessel_info endpoint returns a vessel’s reference information. Its documented fields include IMO, MMSI, name, callsign, dimensions, tonnage, and year built. To identify vessel MMSI changes, the important pair is imo and mmsi.
Request the vessel by IMO so the lookup does not depend on the identifier you are monitoring:
GET https://api.datalastic.com/api/v0/vessel_info?api-key={API_KEY}&imo=9139270 The vessel Info API response:
The response places vessel fields directly inside data. This example shows only the fields needed here:
uuid "f0803370-a78e-f0b5-725e-b436de1dcc32"
name "OCEAN MOLICA"
name_ais "OCEAN MOLICA"
mmsi "374348000"
imo "9139270"
country_iso "PA"
country_name "Panama"
callsign "3EWC4"Save the IMO, MMSI, name, callsign, and lookup time. The name and callsign provide supporting context, while the MMSI is the field you compare.
These are observations of what the API returned at each lookup. The lookup time is not the official date on which the identifier changed.
How to track MMSI changes across repeated snapshots?
Run the same lookup again a week, or a month, later. Compare it to what you stored. The IMO number is your join key precisely because it isn’t supposed to move
import os
from datetime import datetime, timezone
import requests
BASE_URL = "https://api.datalastic.com/api/v0" def api_get(endpoint, api_key, **params):
response = requests.get(
f"{BASE_URL}/{endpoint}",
headers={"x-api-key": api_key},
params=params,
timeout=30,
)
response.raise_for_status()
payload = response.json()
if payload.get("meta", {}).get("success") is False:
raise RuntimeError("Datalastic reported an unsuccessful request")
data = payload.get("data")
if not isinstance(data, dict):
raise ValueError("Expected a vessel object in data")
return data def identifier(value):
if value is None:
return None
return str(value).strip() or None def snapshot(imo, api_key):
vessel = api_get("vessel_info", api_key, imo=str(imo))
if identifier(vessel.get("imo")) != str(imo):
raise ValueError("Returned IMO does not match the requested vessel")
return {
"observed_at": datetime.now(timezone.utc).isoformat(),
"imo": str(imo),
"mmsi": identifier(vessel.get("mmsi")),
"name": vessel.get("name"),
"callsign": vessel.get("callsign"),
} def mmsi_changed(previous, current):
if previous["imo"] != current["imo"]:
raise ValueError("Cannot compare different vessels")
old = previous.get("mmsi")
new = current.get("mmsi")
return bool(old and new and old != new) # Set DATALASTIC_API_KEY in your environment before running.
api_key = os.environ["DATALASTIC_API_KEY"]
current = snapshot("9525338", api_key)
print(current)Install requests with pip install requests. Save each successful snapshot in your own database or file before the next scheduled run.
When a previous snapshot exists, call mmsi_changed(previous, current). If it returns True, record the old and new MMSI alongside both observation times. Handle missing values separately as incomplete data.
For a small watchlist, a scheduled script and SQLite table can be enough. Choose the lookup frequency around your monitoring needs and subscription limits. A weekly comparison only tells you that the API value changed between those two observations.
Why the IMO matters for vessel MMSI changes detection?
If you query only by the old MMSI, you risk losing continuity when the identifier changes. Looking up the same IMO gives your comparison a consistent reference for vessels with an IMO number.
Imagine these fictional snapshots:
| Observation | IMO | MMSI |
|---|---|---|
| First lookup | Same IMO | 111111111 |
| Later lookup | Same IMO | 222222222 |
Pairing an MMSI check with a position history gap
Once you detect an update, position history can provide additional context. You might want to see whether the available track contains a long interval without recorded positions near the observation window.
Datalastic’s vessel_history response includes a positions array. The following function measures the largest interval between distinct returned position timestamps:
def largest_recorded_gap_hours(imo, api_key, days=7):
vessel = api_get(
"vessel_history", api_key, imo=str(imo), days=days
)
positions = vessel.get("positions", [])
timestamps = sorted({
float(point["last_position_epoch"])
for point in positions
if point.get("last_position_epoch") is not None
})
if len(timestamps) < 2:
return None
return max(
later - earlier
for earlier, later in zip(timestamps, timestamps[1:])) / 3600Sorting the timestamps makes the calculation independent of response order. Removing duplicates avoids counting repeated timestamps twice.
A None result means there are too few recorded points to calculate an interval. It does not mean the vessel was unobserved for the entire requested period. This function also excludes time before the first point and after the last point.
Treat a gap as missing observations in the returned dataset. Datalastic uses terrestrial AIS, so coverage and reception affect the available track. A gap does not establish that a vessel switched off its transmitter or that an MMSI update happened during that interval.
Ready to try this against a real watchlist?
Pull the vessel info endpoint for a handful of IMO numbers you care about, or check the pricing page for a plan sized to your fleet.
Read Other Maritime Articles
Vessel Flag Type VS Country Name
At 07:04 UTC on 2 November 2026, the tanker GREAT FORTUNE was making 11.3 knots northeast through the Singapore Strait. Pull her record and you get a small geography lesson. The country name says Marshall Islands. Her home port field still says Bari, Italy, and the...
Monitor Vessel Transits With an API: A Hormuz Playbook
Every ops team watching the Strait of Hormuz right now is asking some version of the same question. How many tankers actually went through today, and did any of them go quiet on the way? Monitor vessel transits with an API and you can answer both, without waiting for...
Why Do Some Vessels Share the Same MMSI? (It’s Not a Bug)
Look up Symphony of the Seas in a vessel tracking database and you might notice something odd. There's the ship itself, all 228,000 gross tons of it, and then there are a handful of much smaller entries nearby carrying the exact same nine-digit MMSI. Same number,...
Maritime Weather API: Current and Hourly Data
If you've ever tried to bolt weather data onto a shipping or logistics tool, you know the annoying part isn't the weather data itself. It's that marine conditions and atmospheric conditions usually come from two different providers with two different schemas, and...
AIS Spoofing in the Red Sea: What’s Really Happening
A cargo ship off Yanbu suddenly reports a position it couldn’t possibly have reached. Its speed jumps to 45 knots, far beyond what a loaded tanker can realistically do. Minutes later, the signal disappears. Hours after that, the vessel reappears somewhere else...
How To Use ChatGPT To Track Ships in Real Time?
Tracking ships using ChatGPT is possible and an easy process when it is connected to a live maritime data source such as Datalastic. On its own, ChatGPT does not maintain a live database of ship positions. It may know general information about vessels, shipping...
Recent Comments