# Sea Route Distance & Transit Time – Port to Port (`glidepath/sea-route-distance`) Actor

Sea distance calculator for shipping routes: port-to-port distance in nautical miles and km, transit days at your vessel's speed, canals and straits crossed. Input: UN/LOCODEs, port names or coordinates. Output: one row per route. $14.94/1k routes.

- **URL**: https://apify.com/glidepath/sea-route-distance.md
- **Developed by:** [Glidepath](https://apify.com/glidepath) (community)
- **Categories:** Business, Developer tools, Agents
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $9.10 / 1,000 route calculateds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Sea Route Distance & Transit Time – Port to Port

**Get the sea distance between two ports, how many days the voyage takes at your speed, and which canals and straits the route uses,** for one route or ten thousand in a single run. Write routes as `CNSHA > NLRTM`, `Shanghai > Rotterdam`, `Portland, US > Yokohama` or `31.23,121.47 > 51.95,4.14`. You get one row per route with the distance in nautical miles and kilometres, transit hours and days, the passages crossed (Suez, Panama, Malacca, Cape of Good Hope…), and optionally the route as a GeoJSON line.

Everything is calculated inside the Actor on an open maritime network, with no calls to outside services, so there is no website that can block it or change under it.

### Who it is for

- **Freight forwarders, logistics and chartering teams:** quick distance and sailing-time estimates for quotes, lane comparisons and CO₂ or fuel estimates, without a per-call API subscription.
- **Planners looking at disruptions:** compare the Suez and the Cape of Good Hope route, or Panama and Cape Horn, with **Avoid canals and straits**.
- **Developers and data teams:** enrich shipment tables with port-to-port distances in bulk (JSON, CSV, Excel, API).
- **AI agents:** answer "how many days from Shanghai to Rotterdam at 14 knots?" through the Apify MCP server.

### How to use it

1. Put your routes in **Routes**, one per line, as `FROM > TO`. Each end can be a UN/LOCODE (`NLRTM`), a port name (`Rotterdam`), a name with a country (`Portland, US`) or `latitude,longitude`.
2. Optionally set the **Speed (knots)** (default 14), passages to avoid, the unit for the `distance` field, and whether to include the route line.
3. Run it and download the rows, or call it from the API, Make, Zapier, n8n or an AI agent.

### Input fields

| Field | Type | Default | Description |
|---|---|---|---|
| **Routes** | | | |
| `routes` (required) | array | `["CNSHA > NLRTM", "Singapore > Los Angeles", "Santos, BR …` (prefilled) | **Routes (FROM > TO).** One route per line as 'FROM > TO'. Each end is a UN/LOCODE (CNSHA), a port name (Rotterdam), a name with a country (Portland, US) or 'latitude,longitude' (31.23,121.47). |
| **Voyage** | | | |
| `speedKnots` | number | `14` | **Speed (knots).** Average speed over the whole route, used for transitHours and transitDays (distance ÷ speed). Use your vessel's average service speed; it applies to every route in the run. |
| `avoidPassages` | array | – | **Avoid canals and straits.** Find the shortest route that does not use these passages, e.g. Suez to get the route round Africa. Applies to every route in the run; routes with no other way are reported in ERRORS (NO_PATH) and not charged. |
| `allowArcticRoutes` | boolean | `false` | **Allow Arctic routes.** Off: the Northwest Passage and the Northern Sea Route are never used. On: they may be used when shorter (seasonal, ice-dependent, permits needed); such rows get a note. |
| **Output** | | | |
| `distanceUnit` | string (one of `nm`, `km`, `mi`) | `nm` | **Unit for the 'distance' field.** Nautical miles, kilometres or statute miles. distanceNm and distanceKm are always in the output as well. |
| `includeGeometry` | boolean | `false` | **Include the route line (GeoJSON).** Add 'geometry': a GeoJSON LineString of the route (longitude, latitude) for maps and GIS tools. Longitudes can go past ±180 so a line across the Pacific stays unbroken. Makes each row larger. |

### Input example

```json
{
  "routes": [
    "CNSHA > NLRTM",
    "Singapore > Los Angeles",
    "Santos, BR > Hamburg, DE",
    "31.23,121.47 > 51.95,4.14"
  ],
  "speedKnots": 14,
  "avoidPassages": [],
  "allowArcticRoutes": false,
  "distanceUnit": "nm",
  "includeGeometry": false
}
```

Through the API an item of `routes` can also be an object, which lets you pass your own reference along: `{"from": "CNSHA", "to": {"lat": 51.95, "lon": 4.14}, "id": "PO-4711"}`.

**How a port is found:** first as a UN/LOCODE (the codes listed in the World Port Index, plus our own list of standard codes it writes differently, such as `CNSHA` or `IEDUB`), then by name, ignoring case and accents (`Montréal` = `Montreal`), generic words such as "Port of" or "Harbour" (`Colon` also finds `Puerto Colon`), and the port's alternate names (`St Petersburg` finds `Sankt-Peterburg`). A country after a comma or in brackets narrows the search (`Lagos, NG`, `Felixstowe, UK`, `Portland (US)`). If a name matches several ports, the one with the largest World Port Index harbour-size class is used and the row gets a note naming the others; the class describes the harbour, not its cargo volume. If two or more share the largest class, the row fails with the candidates listed (for example, the World Port Index lists `Lagos` as a large harbour in both Nigeria and Portugal). You can also write `WPI 31140` to pick an exact World Port Index entry.

### Output example

```json
{
  "routeIndex": 1,
  "routeId": null,
  "from": {"input": "CNSHA", "name": "Shanghai", "locode": "CNSHA", "country": "CN", "lat": 31.216667, "lon": 121.5, "matchedBy": "locode"},
  "to": {"input": "NLRTM", "name": "Rotterdam", "locode": "NLRTM", "country": "NL", "lat": 51.9, "lon": 4.483333, "matchedBy": "locode"},
  "distanceNm": 10580.8,
  "distanceKm": 19595.7,
  "distance": 10580.8,
  "distanceUnit": "nm",
  "speedKnots": 14.0,
  "transitHours": 755.8,
  "transitDays": 31.49,
  "passages": ["malacca", "bab-el-mandeb", "suez", "gibraltar"],
  "avoidedPassages": ["arctic"],
  "snapDistanceNm": {"from": 17.6, "to": 1.0},
  "notes": [],
  "geometry": null,
  "calculatedAt": "2026-11-21T16:31:27Z"
}
```

| Field | Type | Description |
|---|---|---|
| `routeIndex` | integer | Position of the route in your input (1 = first); `ERRORS` uses the same number |
| `routeId` | string / null | The `id` you gave the route (object input via the API), else null |
| `from` | object | Origin: `input`, `name`, `locode`, `country` (ISO 3166 alpha-2), `lat`, `lon`, `matchedBy` (`locode`, `name`, `alias`, `wpi` or `coordinates`) |
| `to` | object | Destination, same fields as `from` |
| `distanceNm` | number | Sea distance in nautical miles (1 nm = 1.852 km), including the straight legs from each end to the network |
| `distanceKm` | number | The same distance in kilometres |
| `distance` | number | The same distance in the unit you chose (`distanceUnit`) |
| `distanceUnit` | string | `nm`, `km` or `mi` |
| `speedKnots` | number | Speed used for the transit time |
| `transitHours` | number | `distanceNm` ÷ `speedKnots`, in hours (sailing time only) |
| `transitDays` | number | `transitHours` ÷ 24 |
| `passages` | array | Canals, straits and capes on the route, in order: `suez`, `panama`, `malacca`, `gibraltar`, `bab-el-mandeb`, `hormuz`, `bosphorus`, `dardanelles`, `sunda`, `cape-horn`, `cape-of-good-hope`, `bering`, `arctic` |
| `avoidedPassages` | array | Passages the route was not allowed to use (`arctic` unless Arctic routes are allowed) |
| `snapDistanceNm` | object | `{from, to}`: how far each end was from the nearest point of the sea-lane network, in nautical miles |
| `notes` | array | Plain-language notes: which port was chosen for an ambiguous name, ends far from the network, Arctic routes |
| `geometry` | object / null | GeoJSON LineString of the route (only with **Include the route line**), else null. Longitudes can go past ±180 so that a line across the Pacific stays unbroken; tools that need -180 to 180 (for example BigQuery or Snowflake GEOGRAPHY) need the line split at the antimeridian first |
| `calculatedAt` | string | ISO 8601 UTC |

Routes that could not be calculated are listed in the run's key-value store as `ERRORS` with their `routeIndex`, the reason (`UNKNOWN_PORT`, `AMBIGUOUS_PORT`, `UNKNOWN_COUNTRY`, `BAD_COORDINATES`, `BAD_INPUT`, `SAME_PLACE`, `NO_PATH`, `NOT_NEAR_SEA`, or `ERROR` for an unexpected problem with that row) and what to change; they are never charged and the run's status message counts them. If no route at all can be calculated, the run fails with the first reasons in its status message. `SUMMARY` holds the totals and the engine version.

### Use it with

- **Spreadsheets and BI:** export CSV or Excel, or read the dataset from Google Sheets through the Integrations tab.
- **Make, Zapier, n8n:** call the Actor with a list of routes and use the rows in your flow.
- **API and code:** the Apify API or the JavaScript and Python clients; send `{"from", "to", "id"}` objects to keep your own shipment IDs.
- **AI agents:** through the Apify MCP server this Actor is a tool that takes a list of routes and returns distances and days.

### Pricing

Pay per route: **$14.94 per 1,000 routes** on the Apify Free plan; on paid plans **$12.99** (Starter), **$11.04** (Scale) and **$9.10** (Business and higher) (the price for your plan is shown on the Pricing tab). The examples below use the Free-plan price. Only routes that are calculated and saved are charged; rows with an unknown or ambiguous port, no sea path or a point far from the sea are free. The route line is included in the price.

- A lane table of 1,000 port pairs → about **$14.94**.
- 5,000 routes → about **$74.70**.
- 10,000 routes, the most one run takes → about **$149.40**.

A small start fee of $0.00005 per run applies. Set a **maximum cost per run** in the run options and the Actor stops cleanly when it is reached.

### How accurate is it?

These are **planning estimates, not navigation**. The routes follow a coarse network of main shipping lanes, not a ship's actual track, and transit time is distance ÷ speed only: no port time, canal queues, weather, currents or speed changes.

We compared the Actor with 24 lanes from NOAA's *Distances Between United States Ports* (2026, 15th edition), including routes through the Panama Canal and to Hawaii: the median difference was 1.3%, 21 of the 24 lanes were within 5%, and the largest difference was 9.8% on short coastal legs on the US West Coast (San Francisco–Seattle 886 nm against NOAA's 807). The Actor's distances tend to be slightly longer than NOAA's. Short coastal routes are where the coarse network shows most.

- **The network:** the maritime network shipped with the open-source searoute-py package 1.6.0 (about 9,700 points), which credits Eurostat's SeaRoute. SeaRoute's documentation says its network is based on Oak Ridge National Laboratory's *Global Shipping Lane Network, World, 2000*, with lines added around European coasts from AIS data; searoute-py has adjusted it since (more passages, the Baltic Sea in 2024, fixes in 2026).
- **Port to network:** each end is joined to the nearest network point by a straight line, and that line is counted in the distance. `snapDistanceNm` shows how long it is; across the World Port Index, half of all ports are within 14 nm. Rows where it is over 50 nm get a note; ends more than 300 nm from any sea lane (inland river ports such as Manaus) are not calculated.
- **Not in the network:** the Kiel and Corinth canals (Baltic routes go round Skagen), inland waterways, and ice, piracy or war-risk areas. Avoiding Suez usually gives the Cape of Good Hope route, but where Panama is shorter the network uses Panama; avoid both to force the Cape.
- **Arctic routes** (Northwest Passage, Northern Sea Route) are off by default because they are seasonal and need permits and ice-class ships.

### Limits

- Up to 10,000 routes per run; about 3,800 ports from the NGA World Port Index plus any point you give as coordinates.
- UN/LOCODEs are matched against the codes the World Port Index lists plus our own list of standard codes for big ports. A code that is in neither (often a new terminal) fails that row for free; use the port name or coordinates instead.
- Speed between 1 and 50 knots; one speed and one set of avoided passages per run (run again for other settings).
- Measured on one CPU core: 1,000 routes between random medium and large ports in 7 to 9 s; 10,000 routes with the route line in about 70 s. On Apify a run's CPU share grows with its memory, so expect longer at the default 1 GB; give the run more memory (up to 4 GB) for large batches.
- No web requests, no proxies, no logins: the network and the port list are part of the Actor.

### FAQ

**Is it legal?** Yes. The Actor visits no website: it calculates routes on open data inside the run. The routing engine searoute-py is Apache-2.0 licensed, its maritime network comes from Eurostat's SeaRoute under the EUPL-1.2, and the port list is the US Government's World Port Index, on which no copyright is claimed. Links to their sources and licences are under [Open data and licences](#open-data-and-licences) below. The output has no personal data.

**Can I use it for navigation?** No. It is for estimates in planning, quoting and analysis. The library's own documentation says it is not for routing ships.

**Why is my port's `locode` different from the one I typed?** Some World Port Index entries carry another code for the same harbour (for example Shanghai is `CNSGH` there); for the big ports we show the standard code you are likely to use. The port's name and coordinates are in `from`/`to` so you can check the match.

**My port name was not found. What now?** The `ERRORS` record suggests close matches. Use the UN/LOCODE, add a country (`Victoria, SC`), or give `latitude,longitude` of the berth.

**How do I compare Suez with the Cape route?** Run your routes twice: once as they are and once with **Avoid canals and straits** set to Suez (add Panama too when the network would otherwise use it). The `passages` field shows which way each route went.

**Is transit time door-to-door?** No, it is sailing time at the speed you set. Add port stays, canal transits and waiting yourself.

### Open data and licences

The Actor calculates on open software and open data. All of it is used unmodified and comes without warranty.

- **Routing engine:** [searoute-py 1.6.0](https://pypi.org/project/searoute/1.6.0/) by Gent Halili, under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). Source: https://github.com/genthalili/searoute-py
- **Maritime network:** shipped in searoute-py, which credits Eurostat's SeaRoute (© European Union) for it, under the European Union Public Licence v. 1.2 ([EUPL-1.2 text](https://interoperable-europe.ec.europa.eu/collection/eupl/eupl-text-eupl-12)). Source: https://github.com/eurostat/searoute and the searoute-py package above, where the network's source is freely available. SeaRoute's documentation says the network is based on Oak Ridge National Laboratory's *Global Shipping Lane Network, World, 2000*.
- **Ports:** the [NGA World Port Index](https://msi.nga.mil/Publications/WPI) (Pub. 150), prepared and published by the US National Geospatial-Intelligence Agency. No copyright claimed under Title 17 U.S.C.; use of the data does not imply endorsement by NGA.

The full notices and the EUPL-1.2 text also ship with the Actor's source (`NOTICE` and `LICENSES/EUPL-1.2.txt`).

### Changelog

See [CHANGELOG.md](CHANGELOG.md).

### Support

Found a problem, a port that is matched wrongly or a route that looks odd? Open an issue on the Actor's Issues tab with the route you used. We read every one and answer it there.

# Changelog

This Actor's version history is a separate document: https://apify.com/glidepath/sea-route-distance/changelog.md

# Actor input Schema

## `routes` (type: `array`):

One route per line as 'FROM > TO'. Each end is a UN/LOCODE (CNSHA), a port name (Rotterdam), a name with a country (Portland, US) or 'latitude,longitude' (31.23,121.47). Via the API an item can also be {"from": ..., "to": ..., "id": ...}. Up to 10,000 routes per run.

## `speedKnots` (type: `number`):

Average speed over the whole route, used for transitHours and transitDays (distance ÷ speed). Use your vessel's average service speed; it applies to every route in the run.

## `avoidPassages` (type: `array`):

Find the shortest route that does not use these passages, e.g. Suez to get the route round Africa. Applies to every route in the run; routes with no other way are reported in ERRORS (NO_PATH) and not charged.

## `allowArcticRoutes` (type: `boolean`):

Off: the Northwest Passage and the Northern Sea Route are never used. On: they may be used when shorter (seasonal, ice-dependent, permits needed); such rows get a note.

## `distanceUnit` (type: `string`):

Nautical miles, kilometres or statute miles. distanceNm and distanceKm are always in the output as well.

## `includeGeometry` (type: `boolean`):

Add 'geometry': a GeoJSON LineString of the route (longitude, latitude) for maps and GIS tools. Longitudes can go past ±180 so a line across the Pacific stays unbroken. Makes each row larger.

## Actor input object example

```json
{
  "routes": [
    "CNSHA > NLRTM",
    "Singapore > Los Angeles",
    "Santos, BR > Hamburg, DE"
  ],
  "speedKnots": 14,
  "allowArcticRoutes": false,
  "distanceUnit": "nm",
  "includeGeometry": false
}
```

# Actor output Schema

## `routes` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `errors` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "routes": [
        "CNSHA > NLRTM",
        "Singapore > Los Angeles",
        "Santos, BR > Hamburg, DE"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("glidepath/sea-route-distance").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "routes": [
        "CNSHA > NLRTM",
        "Singapore > Los Angeles",
        "Santos, BR > Hamburg, DE",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("glidepath/sea-route-distance").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "routes": [
    "CNSHA > NLRTM",
    "Singapore > Los Angeles",
    "Santos, BR > Hamburg, DE"
  ]
}' |
apify call glidepath/sea-route-distance --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,glidepath/sea-route-distance"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/N1UfiQ1f4ZfCJhv9N/builds/XFdbv43PvUmXuAXjC/openapi.json
