Home → Blog

When a shipment depends on Ningbo, a developer needs a repeatable way to check whether port activity differs from its usual level without mistaking a delayed indicator for a live vessel queue. This guide shows how to request Ningbo data, read the returned fields, and integrate the result while preserving its date and limitations.

What the Ningbo indicator measures

The port-congestion endpoint accepts Ningbo’s code, CNNBO, in the port query parameter. The returned data comes from IMF PortWatch and is generally lagged by approximately six to seven days; it is not a live AIS feed or a current estimate of vessel waiting time.

Illustration: API to Get Port Congestion at Ningbo

The underlying measure compares the last seven days’ average port calls per day with a 90-day baseline for the same port. The response describes activity as port-call volume and congestion as a deprecated alias of that activity. A low activity value can reflect fewer calls than usual, but it does not by itself explain whether the cause is a closure, ships waiting offshore, or something else.

That distinction matters when presenting the data. A label such as “Ningbo port-call activity versus baseline” is more precise than “current waiting time.” The endpoint does not establish how many vessels are waiting or how long a particular vessel will wait.

Make the request

Send a GET request to the port-congestion endpoint with port=CNNBO. The documented authentication header is X-API-Key; substitute your own key for YOUR_API_KEY before running the command.

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

Guest access without a key is limited to 100 requests per day per IP. For an integration that uses a key, keep it in your deployment’s secret storage rather than committing it to source control or exposing it in browser code.

The request code is CNNBO. In the sample response, the returned locode is formatted as CN NBO; use the documented request value in the URL rather than assuming the display format is interchangeable with the query value.

Read the response

The following is the supplied Ningbo response example. Treat its values as a dated sample, not as a current reading.

{
"success": true,
"data": {
"results": [
{
"port": "Ningbo",
"locode": "CN NBO",
"country": "China",
"activity": "moderate",
"congestion": "moderate",
"as_of": "2026-11-20",
"metrics": {
"recent_avg_portcalls_per_day": 47.4,
"baseline_avg_portcalls_per_day": 46.7,
"ratio_vs_baseline": 1.02
}
}
],
"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": "b8580870-9f9c-49e5-ba5c-fa852c4895ba"
}
}

Check success, then read the Ningbo entry in data.results. For a port-specific display, the useful fields are activity, the legacy congestion label, as_of, and metrics.ratio_vs_baseline. The two averages in metrics provide the underlying context, in port calls per day.

In this sample, the recent average is 47.4 calls per day and the baseline is 46.7. The reported ratio of 1.02 means the recent average is approximately 2% above the baseline, subject to rounding. It is a relative activity comparison, not a count of waiting vessels, a duration, or a freight rate.

The sample’s as_of value is a date, not a timestamp with a timezone. Display it as the source date rather than adding a time or timezone that the response does not supply. The sample metadata describes a possible lag of four to eleven days because PortWatch republishes the daily series weekly; the usual six-to-seven-day description is an approximation, so check as_of on each response.

The global_summary and both meta objects provide context, but they do not replace the individual Ningbo result. The top-level request ID can help identify a response when investigating a problem. Consult the Documentation for current API details before relying on behavior beyond the fields shown here.

Call the endpoint from Python

This example uses Python’s standard library, calls the same URL as the curl request, and reads the fields needed for a dated Ningbo activity display. Replace YOUR_API_KEY locally; in a deployed application, load the key from secret storage instead.

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=CNNBO"
api_key = "YOUR_API_KEY"

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

try:
with urlopen(request) as response:
payload = json.load(response)
except HTTPError as exc:
print("HTTP request failed:", exc.code, file=sys.stderr)
sys.exit(1)
except (URLError, OSError, ValueError) as exc:
print("Could not retrieve or parse the response:", exc, file=sys.stderr)
sys.exit(1)

if not isinstance(payload, dict) or payload.get("success") is not True:
print("API response did not indicate success", file=sys.stderr)
sys.exit(1)

data = payload.get("data")
if not isinstance(data, dict):
print("API response has no data object", file=sys.stderr)
sys.exit(1)

results = data.get("results")
if not isinstance(results, list) or not results:
print("No port result was returned", file=sys.stderr)
sys.exit(1)

ningbo = results[0]
if not isinstance(ningbo, dict):
print("Port result is not an object", file=sys.stderr)
sys.exit(1)

metrics = ningbo.get("metrics")
if not isinstance(metrics, dict):
metrics = {}

print("Port:", ningbo.get("port"))
print("Activity:", ningbo.get("activity"))
print("Congestion alias:", ningbo.get("congestion"))
print("As of:", ningbo.get("as_of"))
print("Ratio vs baseline:", metrics.get("ratio_vs_baseline"))
print("Recent calls per day:", metrics.get("recent_avg_portcalls_per_day"))
print("Baseline calls per day:", metrics.get("baseline_avg_portcalls_per_day"))

The example checks the success envelope and avoids assuming that a nonempty result or metrics object is always present. It prints missing individual values as None; a production display should instead mark them unavailable and avoid interpreting a missing ratio as zero.

The code uses the first result for the single-port request shown. If your integration receives a different result shape, inspect it rather than silently assigning another result to Ningbo. For production, add an explicit request timeout and decide how your application will surface retrieval failures; the example does not define an automatic retry policy.

Use the indicator safely in an integration

Store the source date alongside the values you display or process. Also record when your application fetched the response: that is a separate event from as_of, and a recent fetch does not make the underlying port observation current.

Because the upstream series is republished weekly, repeated requests may return the same observation. A cache can reduce unnecessary requests, but its refresh policy should reflect the lag your users can tolerate and should retain as_of in the cached record. Do not reset the apparent age of the observation merely because the cache was refreshed.

Preserve the ratio as a dimensionless number and the two averages as port calls per day. If you calculate a percentage difference for presentation, use the returned ratio and label the result as relative to the baseline; rounding can make a recalculation from the displayed averages differ slightly.

Prefer activity for new displays because the response methodology identifies congestion as a deprecated alias. If an existing consumer requires the alias, pass it through with the same explanatory context rather than treating the two labels as independent measurements.

Finally, keep operational decisions proportional to what the data can support. A change in port-call activity can be a reason to investigate Ningbo operations, but it cannot establish a vessel’s anchorage time, a current queue, or a shipment’s delay. The sample does not specify classification thresholds, so an application should not infer numerical cutoffs for the activity labels from this one response.

FAQ

Is the Ningbo response live?

No. The indicator uses lagged IMF PortWatch data, not live AIS wait times. Lag is generally around six to seven days, and the sample metadata gives a wider possible range; use the returned as_of date to assess the observation.

What does ratio_vs_baseline mean?

It compares recent average port calls per day with Ningbo’s 90-day baseline. A ratio above one indicates more calls than the baseline, while a ratio below one indicates fewer; neither value directly measures congestion or waiting time.

Can I call the endpoint without an API key?

Yes. Guest access without a key is limited to 100 requests per day per IP. The authenticated examples above send the key in the X-API-Key header.

Should I use activity or congestion?

Use activity for a new integration. The response methodology identifies congestion as a deprecated alias, and neither field should be presented as a live queue or vessel-wait measurement.

Register to obtain an API key, then run the Ningbo request and check the returned source date before adding the indicator to your application.