Home → Blog

Hamburg congestion monitoring is difficult when a port-call activity indicator is mistaken for a live vessel queue or an estimated wait. This guide shows how to request the DEHAM record, read its source date and baseline comparison, and integrate the result without presenting it as real-time AIS data.

What the Hamburg indicator measures

FreightPulse’s port-congestion endpoint uses IMF PortWatch data derived from AIS port-call activity. For Hamburg, the indicator compares the average daily port-call count over the most recent 7-day window with a 90-day baseline for the same port. The data is typically lagged by about 6–7 days; the sample metadata notes a 4–11 day lag because PortWatch republishes its daily series once a week.

Illustration: Hamburg (DEHAM) Congestion

The response’s activity is a port-call volume classification. Its congestion field is a deprecated alias of that classification, not a direct measurement of congestion. A low activity reading can reflect a closure or ships waiting offshore, but it does not establish either cause. Neither field measures vessel wait time or anchorage time.

Use as_of to show the source date alongside the indicator. A successful request tells you that the API returned a response; it does not mean the underlying observations are current AIS positions or that the indicator describes conditions at the moment of the request.

Request the DEHAM record

Send a GET request to the port-congestion endpoint with port=DEHAM. The authenticated request uses the X-API-Key header:

curl -H "X-API-Key: YOUR_API_KEY" "https://freightpulsehq.com/api/v1/port-congestion?port=DEHAM"

Replace YOUR_API_KEY with your own key when making an authenticated request. Guests without a key can make 100 requests per day per IP. The request code is DEHAM; the sample result represents the same location as DE HAM in its locode field.

The following is the supplied official sample response. It is a snapshot, so its date and values should not be treated as the current Hamburg reading.

{
    "success": true,
    "data": {
        "results": [
            {
                "port": "Hamburg",
                "locode": "DE HAM",
                "country": "Germany",
                "activity": "moderate",
                "congestion": "moderate",
                "as_of": "2026-11-20",
                "metrics": {
                    "recent_avg_portcalls_per_day": 18.3,
                    "baseline_avg_portcalls_per_day": 16.5,
                    "ratio_vs_baseline": 1.11
                }
            }
        ],
        "global_summary": {
            "ports_high_activity": 0,
            "ports_moderate_activity": 1,
            "ports_low_activity": 0,
            "ports_high_congestion": 0,
            "ports_moderate": 1,
            "ports_low": 0
        },
        "meta": {
            "source": "IMF PortWatch (portwatch.imf.org) - UN Global Platform AIS data",
            "data_lag_days": "4-11 (PortWatch republishes the daily series once a week; check as_of)",
            "methodology": "activity is port-call volume, not congestion: last 7 days' avg calls vs a 90-day baseline for the same port. low means fewer calls than usual, which can be a closure or ships waiting offshore. It does not measure vessel wait or anchorage time. congestion is a deprecated alias of activity."
        }
    },
    "meta": {
        "request_id": "23dca7dc-b0ba-4e93-9f2f-910942c22054"
    }
}

Read the Hamburg record from data.results, rather than treating the aggregate counts in global_summary as its measurements. In the sample, activity and its deprecated congestion alias are both moderate. The as_of value is the date attached to that observation, not a request timestamp.

Under metrics, the two averages are measured in port calls per day. ratio_vs_baseline is a unitless comparison of recent activity with the baseline. In this sample, the recent average is above the baseline; that comparison does not quantify the number of ships waiting or the duration of a delay.

Read the response in Python

This example uses Python’s standard library to call the same endpoint and select Hamburg from the results. It checks the response envelope, tolerates missing measurements, and prints the source date with the activity fields. Set the API key before running it.

import json
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen

url = "https://freightpulsehq.com/api/v1/port-congestion?port=DEHAM"
api_key = "YOUR_API_KEY"

request = Request(url, headers={"X-API-Key": api_key})

try:
with urlopen(request) as response:
payload = json.load(response)
except HTTPError as exc:
sys.exit("HTTP request failed: " + str(exc.code))
except URLError as exc:
sys.exit("Could not reach the API: " + str(exc.reason))
except (ValueError, UnicodeDecodeError):
sys.exit("The response was not readable JSON.")

if not isinstance(payload, dict) or payload.get("success") is not True:
sys.exit("The API did not return a successful response.")

data = payload.get("data")
if not isinstance(data, dict):
sys.exit("The response did not contain a data object.")

results = data.get("results")
if not isinstance(results, list):
sys.exit("The response did not contain a results list.")

hamburg = None
for result in results:
if not isinstance(result, dict):
continue
locode = result.get("locode")
if isinstance(locode, str) and locode.replace(" ", "").upper() == "DEHAM":
hamburg = result
break

if hamburg is None:
sys.exit("No Hamburg record was found in the response.")

metrics = hamburg.get("metrics")
if not isinstance(metrics, dict):
metrics = dict()

def display(label, value):
if value is None:
value = "unavailable"
print(label + ": " + str(value))

display("Port", hamburg.get("port"))
display("LOCODE", hamburg.get("locode"))
display("Source date", hamburg.get("as_of"))
display("Activity", hamburg.get("activity"))
display("Congestion alias", hamburg.get("congestion"))
display("Recent average calls per day",
metrics.get("recent_avg_portcalls_per_day"))
display("Baseline average calls per day",
metrics.get("baseline_avg_portcalls_per_day"))
display("Ratio vs baseline", metrics.get("ratio_vs_baseline"))

The selection normalizes the space in the returned LOCODE so the sample’s DE HAM matches the requested DEHAM. It does not assume that the first element in results is always the desired port. If Hamburg or a measurement is absent, the code reports that condition instead of substituting a baseline, ratio, or activity level.

In a deployed service, keep the key out of source control and supply it through your application’s secret-management process. Handle request failures separately from missing data: a network or HTTP failure is not evidence that Hamburg activity is low.

Make the indicator usable in operations

Label the value as Hamburg port-call activity relative to its baseline. If an existing interface displays congestion, explain that it is the deprecated activity alias rather than a measured waiting time. Retaining the distinction prevents a dashboard or downstream alert from turning a volume change into an unsupported delay estimate.

Show as_of next to the classification and ratio. The sample supplies a date without a time or timezone, so do not manufacture a time of day or claim that the date represents an exact observation timestamp. Store the source date separately from the time your system fetched the response; those are different concepts.

Cache a successful response according to your application’s freshness needs, while displaying its original as_of date. Frequent polling cannot turn a lagged PortWatch series into live AIS. If a cached response is used after a request fails, distinguish it from a fresh retrieval and keep the original source date visible.

For alerting, compare observations only with an explicit understanding of the 7-day average and 90-day baseline. A change in the ratio describes port-call volume relative to Hamburg’s own baseline; it does not identify the cause. Avoid deriving vessel-specific ETAs, queue lengths, or wait hours from the classification alone.

The response also includes source and methodology information under data.meta, plus a request identifier under the top-level meta. Preserve the request identifier when available for troubleshooting, and check the returned methodology and lag description when presenting the data. Consult the Documentation for integration details beyond the fields shown here.

FAQ

Is the DEHAM result a live congestion or vessel-wait feed?

No. The endpoint returns a lagged IMF PortWatch port-call activity indicator. It does not measure live vessel waits or anchorage time, even though the endpoint and deprecated alias use the word congestion.

Why does the request use DEHAM while the response says DE HAM?

The sample returns the LOCODE with a space. The Python example removes spaces before comparing it with the request code, while preserving the original returned value for display.

What does a ratio above the baseline mean?

It means the recent average port-call volume is above the baseline average in the returned comparison. It does not by itself establish whether ships are delayed, how long they wait, or why activity changed.

How current is the sample date?

The date in the JSON is the as_of value for that sample, not a promise about a later request. PortWatch data is typically lagged by about 6–7 days, and the sample metadata describes a 4–11 day range. Check the returned date each time you use or display the result.

Can I test without an API key?

Yes. Guest access without a key is limited to 100 requests per day per IP. The curl and Python examples above demonstrate the authenticated request using the documented header.

Register to obtain access for an authenticated integration, then request DEHAM and display the returned activity, baseline comparison, and source date together.