Port API Examples

  1. Information about a port
  2. List all the ports
  3. Ports in area
  4. Search for ports by their partial name

Get the information about a port via its ID or by its LOCODE

Example getting information about a port by querying by its LOCODE DEHAM:

// initialisation with your API KEY
$MY_API_KEY_HERE = 'YOUR-API-KEY-HERE';
// base url for the subsequent requests
$base_url = "https://api.searoutes.com/ps/port";
// send the API key in the request
$curl_headers = array(
    'accept: application/json ',
    'x-Api-key: '.$MY_API_KEY_HERE,
);
// initialize curl and pass the Api key in the header
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $curl_headers);
// curl has been initialised and ready to be used

// define our search parameter
$requestParameters = array (
    'locode' => "DEHAM"
);
// create the new url with the specific parameter
$url = $base_url . "?" . http_build_query($requestParameters, '', "&");
curl_setopt($curl, CURLOPT_URL, $url);
$response = curl_exec($curl);
curl_close($curl);
print ($response);
     

// initialisation with your API KEY
final String MY_API_KEY_HERE = "YOUR-API-KEY-HERE";
// base url for the subsequent requests
final String base_url = "https://api.searoutes.com/ps/port";
// provide a search query
final String url = base_url +  "?locode=DEHAM";
HttpsURLConnection con = (HttpsURLConnection) new URL(url).openConnection();
// send the API key in the request
con.setRequestProperty("x-api-key", MY_API_KEY_HERE);
con.setRequestProperty("accept", "application/json");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
InputStream is = con.getInputStream();
for (int nRead = is.read(buffer); nRead != -1; nRead = is.read(buffer)) {
    baos.write(buffer, 0, nRead);
}
is.close();
System.out.println(new String(baos.toByteArray(), "UTF8"));
}
     

# Python 3
import requests

# initialisation with your API KEY
MY_API_KEY_HERE = 'YOUR-API-KEY-HERE'

# base url for the subsequent requests
base_url = "https://api.searoutes.com/ps/port"

# custom headers with our API key
request_headers = {
    'accept': 'application/json',
    'x-api-key': MY_API_KEY_HERE
}

# search term
request_params = {'locode': 'DEHAM'}

# create the new url with the specific parameter
url = base_url
response = requests.get(url, headers=request_headers, params=request_params)
print (response.text)

     

The returned object will be a JSON object that contains the information about the requested port. For example the request above will return:

  {
    "port_id": 2,
    "port_name": "Hamburg",
    "locode": "DEHAM",
    "name_wp": "Hamburg",
    "lon": 9.93855,
    "lat": 53.519272,
    "polygon": "POLYGON((9.75156223886518 53.5698851252,9.74487847233002 53.5284258866033,9.89575695186285 53.4976908259806,9.97768146783856 53.4513480942925,10.0969069645568 53.458914057774,10.0891753616896 53.5514955142918,9.75156223886518 53.5698851252))",
    "name_mt": "HAMBURG",
    "country": "Germany ",
    "timezone": "[UTC +1]",
    "vname": "HAMBURG",
    "port_size": "BIG",
    "_0800_number": "",
    "web_site": "www.hafen-hamburg.de",
    "port_type": "Seaport",
    "fax": "+49-40/37 709-109",
    "port_location": "Hamburg",
    "phone": "+49-40 / 37 709 -0",
    "adress": "Mattentwiete 2 Hamburg D - 20457 Germany",
    "email": "info@hafen-hamburg.de",
    "port_authority": "Port Authority of Hamburg",
    "world_port_index_number": 30780,
    "main_port_name": "Hamburg",
    "wpi_country_code": "DE",
    "country_name": "GERMANY",
    "region_index": "30650",
    "area_name": "GERMANY",
    "harbor_type_description": "Lake or Canal",
    "entrance_restriction_tide": "Y",
    "entrance_restriction_swell": "N",
    "entrance_restriction_ice": "Y",
    "entrance_restriction_other": "Y",
    "overhead_limits": "Y",
    "channel_depth": "K",
    "anchorage_depth": "",
    "cargo_pier_depth": "M",
    "oil_terminal_depth": "O",
    "tide": 3,
    "maximum_size_vessel_description": "Up to 500 feet in length",
    "pilotage_compulsory": "Y",
    "pilotage_available": "Y",
    "pilotage_local_assist": "",
    "pilotage_advisable": "Y",
    "tugs_salvage": "",
    "tugs_assist": "Y",
    "cranes_fixed": "Y",
    "cranes_mobile": "Y",
    "cranes_floating": "Y",
    "lifts_100_tons_plus": "Y",
    "lifts_50_100_tons": "Y",
    "lifts_25_49_tons": "Y",
    "lifts_0_24_tons": "Y",
    "services_longshore": "Y",
    "services_elect": "Y",
    "services_steam": "Y",
    "services_navig_equip": "Y",
    "services_elect_repair": "Y",
    "supplies_provisions": "Y",
    "supplies_water": "Y",
    "supplies_fuel_oil": "Y",
    "supplies_diesel_oil": "Y",
    "supplies_deck": "Y",
    "supplies_engine": "Y",
    "drydock": "M",
    "railway": "L",
    "country_short": "y ",
    "container": true,
    "containershipspermonth": "427"
  }

Get a list of all the ports

Example getting on how getting the list of all ports:

// initialisation with your API KEY
$MY_API_KEY_HERE = 'YOUR-API-KEY-HERE';
// base url for the subsequent requests
$base_url = "https://api.searoutes.com/ps/ports";
// send the API key in the request
$curl_headers = array(
    'accept: application/json ',
    'x-Api-key: '.$MY_API_KEY_HERE,
);
// initialize curl and pass the Api key in the header
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $curl_headers);
// curl has been initialised and ready to be used

// define our search parameter
$requestParameters = array (
    'locode' => "DEHAM"
);
// create the new url with the specific parameter
$url = $base_url . "?" . http_build_query($requestParameters, '', "&");
curl_setopt($curl, CURLOPT_URL, $url);
$response = curl_exec($curl);
curl_close($curl);
print ($response);
     

// initialisation with your API KEY
final String MY_API_KEY_HERE = "YOUR-API-KEY-HERE";
// base url for the subsequent requests
  final String base_url = "https://api.searoutes.com/ps/ports-in-area";
// provide a search query
final String url = base_url +  "?ullat=45.73&ullon=4.24&lrlat=35.81&lrlon=19.05&size=3";
HttpsURLConnection con = (HttpsURLConnection) new URL(url).openConnection();
// send the API key in the request
con.setRequestProperty("x-api-key", MY_API_KEY_HERE);
con.setRequestProperty("accept", "application/json");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
InputStream is = con.getInputStream();
for (int nRead = is.read(buffer); nRead != -1; nRead = is.read(buffer)) {
    baos.write(buffer, 0, nRead);
}
is.close();
System.out.println(new String(baos.toByteArray(), "UTF8"));
}
     

# Python 3
import requests

# initialisation with your API KEY
MY_API_KEY_HERE = 'YOUR-API-KEY-HERE'

# base url for the subsequent requests
base_url = "https://api.searoutes.com/ps/ports"

# custom headers with our API key
request_headers = {
    'accept': 'application/json',
    'x-api-key': MY_API_KEY_HERE
}

# search term
request_params = {'size': 3}

# create the new url with the specific parameter
url = base_url
response = requests.get(url, headers=request_headers, params=request_params)
print (response.text)

     

The returned object will be a JSON array that contains the list with all the ports. For example the request above will return [truncated for brevity ]:

  {
    "port_id": 2,
    "port_name": "Hamburg",
    "locode": "DEHAM",
    "name_wp": "Hamburg",
    "lon": 9.93855,
    "lat": 53.519272,
    "polygon": "POLYGON((9.75156223886518 53.5698851252,9.74487847233002 53.5284258866033,9.89575695186285 53.4976908259806,9.97768146783856 53.4513480942925,10.0969069645568 53.458914057774,10.0891753616896 53.5514955142918,9.75156223886518 53.5698851252))",
    "name_mt": "HAMBURG",
    "country": "Germany ",
    "timezone": "[UTC +1]",
    "vname": "HAMBURG",
    "port_size": "BIG",
    "_0800_number": "",
    "web_site": "www.hafen-hamburg.de",
    "port_type": "Seaport",
    "fax": "+49-40/37 709-109",
    "port_location": "Hamburg",
    "phone": "+49-40 / 37 709 -0",
    "adress": "Mattentwiete 2 Hamburg D - 20457 Germany",
    "email": "info@hafen-hamburg.de",
    "port_authority": "Port Authority of Hamburg",
    "world_port_index_number": 30780,
    "main_port_name": "Hamburg",
    "wpi_country_code": "DE",
    "country_name": "GERMANY",
    "region_index": "30650",
    "area_name": "GERMANY",
    "harbor_type_description": "Lake or Canal",
    "entrance_restriction_tide": "Y",
    "entrance_restriction_swell": "N",
    "entrance_restriction_ice": "Y",
    "entrance_restriction_other": "Y",
    "overhead_limits": "Y",
    "channel_depth": "K",
    "anchorage_depth": "",
    "cargo_pier_depth": "M",
    "oil_terminal_depth": "O",
    "tide": 3,
    "maximum_size_vessel_description": "Up to 500 feet in length",
    "pilotage_compulsory": "Y",
    "pilotage_available": "Y",
    "pilotage_local_assist": "",
    "pilotage_advisable": "Y",
    "tugs_salvage": "",
    "tugs_assist": "Y",
    "cranes_fixed": "Y",
    "cranes_mobile": "Y",
    "cranes_floating": "Y",
    "lifts_100_tons_plus": "Y",
    "lifts_50_100_tons": "Y",
    "lifts_25_49_tons": "Y",
    "lifts_0_24_tons": "Y",
    "services_longshore": "Y",
    "services_elect": "Y",
    "services_steam": "Y",
    "services_navig_equip": "Y",
    "services_elect_repair": "Y",
    "supplies_provisions": "Y",
    "supplies_water": "Y",
    "supplies_fuel_oil": "Y",
    "supplies_diesel_oil": "Y",
    "supplies_deck": "Y",
    "supplies_engine": "Y",
    "drydock": "M",
    "railway": "L",
    "country_short": "y ",
    "container": true,
    "containershipspermonth": "427"
  }

Get a list of all the ports within a given area by its coordinate

Example getting on how getting the list of all ports within a given area:

// initialisation with your API KEY
$MY_API_KEY_HERE = 'YOUR-API-KEY-HERE';
// base url for the subsequent requests
  $base_url = "https://api.searoutes.com/ps/ports-in-area";
// send the API key in the request
$curl_headers = array(
    'accept: application/json ',
    'x-Api-key: '.$MY_API_KEY_HERE,
);
// initialize curl and pass the Api key in the header
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $curl_headers);
// curl has been initialised and ready to be used

// define our search parameters
$requestParameters = array(
    'ullat' => 45.73,
    'ullon' => 4.24,
    'lrlat' => 35.81,
    'lrlon' => 19.05,
    'size' => 3,
);
// create the new url with the specific parameter
$url = $base_url . "?" . http_build_query($requestParameters, '', "&");
curl_setopt($curl, CURLOPT_URL, $url);
$response = curl_exec($curl);
curl_close($curl);
print ($response);
     

// initialisation with your API KEY
final String MY_API_KEY_HERE = "YOUR-API-KEY-HERE";
// base url for the subsequent requests
final String base_url = "https://api.searoutes.com/ps/ports-in-area";
// provide a search query
final String url = base_url +  "?ullat=45.73&ullon=4.24&lrlat=35.81&lrlon=19.05&size=3";
HttpsURLConnection con = (HttpsURLConnection) new URL(url).openConnection();
// send the API key in the request
con.setRequestProperty("x-api-key", MY_API_KEY_HERE);
con.setRequestProperty("accept", "application/json");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
InputStream is = con.getInputStream();
for (int nRead = is.read(buffer); nRead != -1; nRead = is.read(buffer)) {
    baos.write(buffer, 0, nRead);
}
is.close();
System.out.println(new String(baos.toByteArray(), "UTF8"));
}
     

# Python 3
import requests

# initialisation with your API KEY
MY_API_KEY_HERE = 'YOUR-API-KEY-HERE'

# base url for the subsequent requests
base_url = "https://api.searoutes.com/ps/ports-in-area"

# custom headers with our API key
request_headers = {
    'accept': 'application/json',
    'x-api-key': MY_API_KEY_HERE
}

# search terms
request_params = {
    'ullat': 45.73,
    'ullon': 4.24,
    'lrlat': 35.81,
    'lrlon': 19.05,
    'size': 3,
}

# create the new url with the specific parameter
url = base_url
response = requests.get(url, headers=request_headers, params=request_params)
print (response.text)

     

The returned object will be a JSON array that contains the list with all the ports. For example the request above will return:

{
  "ports": [
    {
      "port_id": 5331,
      "port_name": "Alghero",
      "locode": "ITAHO",
      "lon": 8.3110705,
      "lat": 40.56264,
      "country": "Italy ",
      "timezone": "[UTC +1]",
      "vname": "ALGHER",
      "port_size": "Small",
      "_0800_number": "",
      "port_type": "Harbor",
      "port_location": "Alghero",
      "main_port_name": "ALGHER",
      "osmzoomlevel": "9"
    },
    {
      "port_id": 557,
      "port_name": "Antibes",
      "locode": "FRANT",
      "lon": 7.12910223007202,
      "lat": 43.5870094299316,
      "country": "France ",
      "timezone": "[UTC +1]",
      "vname": "ANTIBES",
      "port_size": "Small",
      "_0800_number": "",
      "port_type": "Harbor",
      "port_location": "Antibes",
      "main_port_name": "Antibes",
      "country_name": "France",
      "overhead_limits": "",
      "channel_depth": "M",
      "osmzoomlevel": "9"
    },
    {
      "port_id": 2735,
      "port_name": "Anzio",
      "locode": "ITANZ",
      "lon": 12.6338547756997,
      "lat": 41.4457746840472,
      "country": "Italy ",
      "timezone": "[UTC +1]",
      "vname": "ANZIO",
      "port_size": "Small",
      "_0800_number": "",
      "port_type": "Harbor",
      "port_location": "Anzio",
      "main_port_name": "Anzio",
      "osmzoomlevel": "9"
    }
  ],
  "size": 3
}

Get a list of ports by partial query on their name

Example getting on how getting the list of ports with the search string hamburg

// initialisation with your API KEY
$MY_API_KEY_HERE = 'YOUR-API-KEY-HERE';
// base url for the subsequent requests
  $base_url = "https://api.searoutes.com/ps/ports-suggest";
// send the API key in the request
$curl_headers = array(
    'accept: application/json ',
    'x-Api-key: '.$MY_API_KEY_HERE,
);
// initialize curl and pass the Api key in the header
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $curl_headers);
// curl has been initialised and ready to be used

// define our search parameters
$requestParameters = array(
  'name' => 'hamburg'
);
// create the new url with the specific parameter
$url = $base_url . "?" . http_build_query($requestParameters, '', "&");
curl_setopt($curl, CURLOPT_URL, $url);
$response = curl_exec($curl);
curl_close($curl);
print ($response);
     

// initialisation with your API KEY
final String MY_API_KEY_HERE = "YOUR-API-KEY-HERE";
// base url for the subsequent requests
final String base_url = "https://api.searoutes.com/ps/ports-suggest";
// provide a search query
final String url = base_url +  "?name=hamburg";
HttpsURLConnection con = (HttpsURLConnection) new URL(url).openConnection();
// send the API key in the request
con.setRequestProperty("x-api-key", MY_API_KEY_HERE);
con.setRequestProperty("accept", "application/json");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
InputStream is = con.getInputStream();
for (int nRead = is.read(buffer); nRead != -1; nRead = is.read(buffer)) {
    baos.write(buffer, 0, nRead);
}
is.close();
System.out.println(new String(baos.toByteArray(), "UTF8"));
}
     

# Python 3
import requests

# initialisation with your API KEY
MY_API_KEY_HERE = 'YOUR-API-KEY-HERE'

# base url for the subsequent requests
base_url = "https://api.searoutes.com/ps/ports-suggest"

# custom headers with our API key
request_headers = {
    'accept': 'application/json',
    'x-api-key': MY_API_KEY_HERE
}

# search terms
request_params = {
    'name': 'hamburg'
}

# create the new url with the specific parameter
url = base_url
response = requests.get(url, headers=request_headers, params=request_params)
print (response.text)

     

The returned object will be a JSON array that contains the list with all the ports. For example the request above will return:

{
  "ports": [
    {
      "port_id": 2,
      "port_name": "Hamburg",
      "locode": "DEHAM",
      "lon": 9.93855,
      "lat": 53.519272,
      "country": "Germany "
    },
    {
      "port_id": 7040,
      "port_name": "HAMBURGON",
      "locode": "SEHBO",
      "lon": 11.268235,
      "lat": 58.551845,
      "country": "Sweden "
    }
  ],
  "size": 2
}