Examples
Below are some basic examples of how to use the Searoutesnav API with different programming languages. Replace YOUR_API_KEY with your actual key.
cURL Example
curl --request GET \
--url https://api.searoutesnav.com/calculate-route?origin=NYC&destination=LON \
--header "x-api-key: YOUR_API_KEY"
JavaScript (fetch)
fetch("https://api.searoutesnav.com/calculate-route?origin=NYC&destination=LON", {
headers: { "x-api-key": "YOUR_API_KEY" }
})
.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"
params = {"origin": "NYC", "destination": "LON"}
headers = {"x-api-key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers, params=params)
print(response.json())
Node.js (axios)
const axios = require("axios");
axios.get("https://api.searoutesnav.com/calculate-route", {
params: { origin: "NYC", destination: "LON" },
headers: { "x-api-key": "YOUR_API_KEY" }
})
.then(res => console.log(res.data))
.catch(err => console.error(err));