You’re building transportation software that needs to find a general cargo ship fast, see where it is right now, plot its recent track, and discover what’s nearby to avoid conflicts at anchorage or plan pilotage. By the end of this post, you’ll be able to search general cargo vessels, stream live AIS track data (with route and last port calls), and query vessels within a radius — all via a single, consistent REST API.
Why developers use Vessels API for general cargo ship tracking
Vessels API exposes 18 REST endpoints under one base URL and one API key. Every response has the same JSON envelope structure {status, success, message, data}, which makes error handling and client libraries straightforward. Coverage is global AIS with near-real-time refresh. You can prototype free for seven days and scale the same integration from a single general cargo vessel to an enterprise fleet without rewriting auth or response parsing.
- Base URL: https://vessels-api.com/api/V1
- Authentication: X-API-Key header (no OAuth)
- Response envelope: {status, success, message, data}
- Key endpoints in this article: /vessels/search, /vessels/track, /vessels/nearby, /vessels/analytics (plus a note on /vessels/green)
Core flow for general cargo ships
Most transportation integrations for general cargo vessels follow a simple pattern:
- Resolve the vessel via /vessels/search using IMO or MMSI (or fuzzy name).
- Pull live tracking, voyage route, and recent port calls from /vessels/track.
- Show situational context by listing /vessels/nearby around the last position.
- Summarize operations with /vessels/analytics for total distance, average speed, and port calls.
Let’s walk through each step with copy-pasteable requests and practical details for general cargo ships.
Search: resolve a general cargo vessel quickly
Use /vessels/search to find a general cargo ship by name, IMO, or MMSI. This endpoint is fuzzy by default when you pass a query string, and it supports filters like ship_type, flag, and deadweight tonnage bands. For general cargo, filter by ship_type if you want to exclude tankers or bulkers from the results.
cURL
curl -H "X-API-Key: YOUR_API_KEY" "https://vessels-api.com/api/V1/vessels/track?mmsi=258785000&hours=48"
Notes for production:
- Pagination: per_page max is 100; check data.pagination for current_page, total, and last_page.
- Tonnage filters: min_dwt/max_dwt help you separate coaster-size from Handy and above if needed.
- Year filters: year_built_from/year_built_to can help operational screening (e.g., older breakbulk tonnage).
Track: live position, route, and port calls for a general cargo ship
/vessels/track is the main workhorse for dashboards and logistics workflows. You’ll receive the current AIS position, optional 24–168 hours of position history, route metadata, and last port visits. For transportation use cases, this is where you drop a pin on the map and annotate with speed/course, destination, ETA, and previous ports.
Official cURL sample
The following request and JSON are an official sample for a documented MMSI. Copy exactly to validate your client and parsing logic:
{
"status": 200,
"success": true,
"message": "OK",
"data": {
"vessel": {
"imo": "9122556",
"mmsi": "258785000",
"name": null
},
"current_position": {
"latitude": 53.33708,
"longitude": 7.17993,
"position_precision": "precise",
"position_accuracy_nm": null,
"speed_knots": 0,
"course_degrees": 212,
"heading_degrees": null,
"navigational_status": 5,
"timestamp_utc": "2017-01-24T04:07:25+00:00",
"age_minutes": 5170400,
"destination": null,
"eta": null
},
"predicted_eta": null,
"position_history": [],
"route": {
"departure_port": "HERACLIO",
"departure_time": "2026-04-27T21:35:36+00:00",
"destination_port": "HERACLIO",
"eta": null,
"distance_nm": null,
"avg_speed_knots": 17.1
},
"last_port_visits": [
{
"port_id": "156",
"port_name": "EMDEN",
"arrival_time": "2026-07-30T13:00:10+00:00",
"departure_time": null,
"duration_hours": null
},
{
"port_id": "10",
"port_name": "HERACLIO",
"arrival_time": "2026-04-20T12:00:00+00:00",
"departure_time": "2026-04-23T08:00:00+00:00",
"duration_hours": 68
}
],
"weather": null
}
}
Field notes you will actually use:
- data.current_position.latitude/longitude are decimal degrees. Speed is knots, course is degrees true. Timestamps are UTC (ISO 8601).
- data.route provides operational context: departure_port, destination_port, and avg_speed_knots help you estimate schedules even if predicted_eta is null.
- data.last_port_visits lets port community systems confirm the chain of recent logistics events for a general cargo ship (arrival_time, departure_time).
- When you need history for a heatmap, set hours up to 168 for one-week tracks. If include_route or include_predicted_eta is supported in your use case, pass them as query params.
Python example: parse live AIS and last ports
import requests
API_KEY = "YOUR_API_KEY"
url = "https://vessels-api.com/api/V1/vessels/track"
params = {
"mmsi": "258785000",
"hours": "48"
}
headers = {"X-API-Key": API_KEY}
resp = requests.get(url, headers=headers, params=params, timeout=20)
resp.raise_for_status()
payload = resp.json()
if not payload.get("success"):
raise RuntimeError(f"API error: {payload.get('message')}")
data = payload["data"]
vessel = data["vessel"]
pos = data["current_position"]
print(f"MMSI: {vessel.get('mmsi')}, IMO: {vessel.get('imo')}")
print(f"Lat/Lon: {pos.get('latitude')}, {pos.get('longitude')}")
print(f"Speed (kn): {pos.get('speed_knots')}, Course (deg): {pos.get('course_degrees')}")
print(f"Timestamp (UTC): {pos.get('timestamp_utc')}")
route = data.get("route") or {}
print(f"Route: {route.get('departure_port')} → {route.get('destination_port')}")
print(f"Avg speed (kn): {route.get('avg_speed_knots')}")
last_ports = data.get("last_port_visits") or []
for visit in last_ports:
print(f"Visited {visit['port_name']} (port_id={visit['port_id']}), arrival={visit['arrival_time']}, departure={visit['departure_time']}")
Nearby: proximity checks around a port or pilot station
General cargo operations often require checking for nearby traffic before shifting berth or calling a pilot. /vessels/nearby returns all vessels within a radius of a lat/lon coordinate, optionally filtered by ship_type. The radius is in nautical miles and defaults to 50 NM (max 200 NM).
cURL
Implementation tips:
- Use the vessel position from /vessels/track to seed a /vessels/nearby request and render a context ring on the map.
- data.vessels[n].distance_nm tells you how far each contact is from the center point — useful for sorting and alerts.
- Throttle client-side refresh by caching for 15–30 seconds per coordinate cell to reduce redundant hits for stationary ships in port.
Analytics: voyage summaries for performance and planning
/vessels/analytics aggregates operational metrics over a period: total distance sailed, average and max speed, number of port calls, and total time in port. For general cargo lines and freight forwarders, these summaries drive on-time performance dashboards and estimate idle time at anchorage or berth.
cURL
Notes:
- type can be vessel, port, or fleet. For general cargo ship retrospectives, use type=vessel with IMO or MMSI.
- period supports 24h, 7d, 30d, 90d. Use 7d for weekly ops reviews and 30d for monthly scorecards.
- Key fields: statistics.total_distance_nm, statistics.avg_speed_knots, statistics.port_calls_count, statistics.total_time_in_port_hours.
Optional: ESG checkpoints via IMO CII
If your transportation stack needs sustainability indicators for general cargo vessels, /vessels/green provides an estimated CO2 footprint and a CII rating per IMO MEPC.339(76) over a selectable period.
cURL
Use cases:
- Show a monthly CII rating (A–E) alongside voyage metrics in a unified vessel profile.
- Trigger alerts when a general cargo ship’s rolling rating degrades below a policy threshold.
Error handling, units, and production guardrails
Every endpoint returns a consistent envelope so you can centralize error handling:
- 200 OK — proceed to data
- 400 Missing/invalid parameter — check query/body
- 401 Invalid or missing X-API-Key — confirm header propagation across environments
- 404 Not found — vessel or port doesn’t exist or lacks data
- 422 Parameter out of range — e.g., hours > 168, per_page > 100, radius > 200
- 429 Rate limit exceeded — back off and add caching
- 500 Server error — implement retry with jitter
Operational details for transportation systems:
- Coordinates are decimal degrees (WGS84). Speed is knots. Distances are nautical miles. Timestamps are UTC.
- Pagination fields live under data.pagination for list endpoints like /vessels/search.
- Use age_minutes on current_position to judge freshness. For port environments where AIS can be sporadic, degrade gracefully and annotate staleness in the UI.
- Batch fleet scenarios can use the fleet endpoint to consolidate network calls, but for this article we emphasize single-ship tracking typical of general cargo workflows.
Practical workflow patterns for general cargo
Fleet dashboard for a breakbulk operator
- Resolve vessels once via /vessels/search by name or IMO and store MMSI/IMO pairs in your DB.
- On dashboard refresh, call /vessels/track per active vessel, map the pin, and render route summary.
- When a captain or agent requests a situational picture before arrival, call /vessels/nearby centered on pilot boarding position with radius=15–30 NM; filter ship_type to General Cargo and Tug if you want a focused layer.
- For weekly ops, call /vessels/analytics with period=7d to populate activity and idle-time charts.
Logistics ETA assist
- If predicted_eta is available, display it alongside route.destination_port. If null, compute a heuristic ETA using route.avg_speed_knots and remaining distance (from your routing layer) as a backup.
- When current_position.speed_knots = 0 near destination and navigational_status indicates moored/anchored, notify your TOS or agent automatically.
Port operations safety
- Before shifting berth, query /vessels/nearby with radius=5–10 NM and filter to General Cargo to scan for same-type conflicts at basin entrances and fairways.
- Log data.last_port_visits to reconcile berth occupancy timelines.
Security and deployment tips
- Store X-API-Key server-side. Never embed it in frontend code or mobile apps.
- Wrap calls with a service class that validates the envelope and normalizes nulls for optional fields (e.g., predicted_eta, weather).
- Cache search results and static particulars locally; refresh tracks on a schedule aligned to your UI (e.g., 15–60 seconds in port, 2–5 minutes at sea).
Quick links to ship faster
FAQ
Which identifier should I use for a general cargo vessel — IMO or MMSI?
Use either; /vessels/track accepts imo or mmsi. MMSI is more dynamic (can change with flag/ownership), while IMO is persistent. Many teams store both after an initial /vessels/search.
How fresh is the live AIS data?
The API provides global AIS with near-real-time refresh. Check current_position.age_minutes to gate UI refresh and warn if data is stale.
How do I limit results to general cargo ships only?
Use ship_type=General Cargo in /vessels/search and /vessels/nearby. Keep casing and spacing URL-encoded.
Can I get a week of historical track points?
Yes. Pass hours up to 168 to /vessels/track. If you don’t need history, omit hours or keep it low to reduce payload size.
What should I do on 429 errors?
Implement exponential backoff with jitter and add client-side caching for track and nearby endpoints to avoid duplicate refreshes.
Build your general cargo tracking workflow with one stable base URL, one API key, and consistent responses. Start with the official track sample above, then wire up search, nearby, and analytics to complete your transportation stack. When you’re ready, create your key and ship your first integration: Register, browse the Documentation, and explore the MCP to accelerate development.