Examples

Below are basic examples of calling POST /calculate-route in different languages. Replace YOUR_ACCESS_TOKEN with the bearer token from /auth/login. Origins and destinations are given as { "port_id": ... } or { "coordinates": [lon, lat] }.

cURL Example

curl --request POST \ --url https://api.searoutesnav.com/calculate-route \ --header "Authorization: Bearer YOUR_ACCESS_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "origin": { "port_id": 101 }, "destination": { "coordinates": [-0.13, 51.5] }, "vessel": { "type": "container" } }'

JavaScript (fetch)

fetch("https://api.searoutesnav.com/calculate-route", { method: "POST", headers: { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json" }, body: JSON.stringify({ origin: { port_id: 101 }, destination: { coordinates: [-0.13, 51.5] }, vessel: { type: "container" } }) }) .then(res => res.json()) .then(data => console.log(data)) .catch(err => console.error(err));

Python (requests)

import requests url = "https://api.searoutesnav.com/calculate-route" headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"} payload = { "origin": {"port_id": 101}, "destination": {"coordinates": [-0.13, 51.5]}, "vessel": {"type": "container"}, } response = requests.post(url, headers=headers, json=payload) print(response.json())

Node.js (axios)

const axios = require("axios"); axios.post("https://api.searoutesnav.com/calculate-route", { origin: { port_id: 101 }, destination: { coordinates: [-0.13, 51.5] }, vessel: { type: "container" } }, { headers: { Authorization: "Bearer YOUR_ACCESS_TOKEN" } }) .then(res => console.log(res.data)) .catch(err => console.error(err));

CO₂ Emissions (cURL)

Estimate GLEC-aligned emissions for a route with POST /v1/emissions/sea. Route endpoints use { "port_id": ... } or { "lat": ..., "lon": ... }.

curl --request POST \ --url https://api.searoutesnav.com/v1/emissions/sea \ --header "Authorization: Bearer YOUR_ACCESS_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "route": { "origin": { "port_id": 2451 }, "destination": { "lat": 1.29, "lon": 103.85 } }, "cargo": { "teu": 1200 }, "vessel": { "type": "container" }, "calculation": { "boundary": "WTW" } }'