Bulk container tracking: a spreadsheet of containers through the batch API
There are two ways to follow many containers at once:
| When to use it | How | |
|---|---|---|
| Batch lookups | A one-off answer for a list: an audit, a morning report, a backfill | GET /v1/track?numbers=a,b,c, 100 numbers per call |
| Watches | Containers you need to follow until the empty is returned | POST /v1/watches with up to 100 numbers, then a webhook on every change. See Watches and webhooks |
On paid plans a container counts once per billing period however often you look it up, so re-running a batch over the same list costs nothing extra. See Plans.
The batch route
GET /v1/track?numbers= takes up to 100 numbers per call, at most 35 for any one line. Containers from different lines can be mixed; duplicates are removed. Every number gets its own result or error, so one bad row never fails the rest.
curl "https://api.containerfeed.com/v1/track?numbers=MSKU7812341,MEDU1234562,EGHU9123457" \
-H "Authorization: Bearer $OPENCONTAINER_API_KEY"carrier applies to every number in the call. Send leased containers and bills of lading in their own calls, grouped by line, with carrier set for each group.
Enrich a CSV
The script below reads containers.csv (a container column, and an optional carrier column for bills of lading and leased boxes), tracks every row in batches, and writes containers-tracked.csv with the status, latest move and ETA.
import csv, os, requests
from collections import defaultdict
from itertools import islice
API = "https://api.containerfeed.com/v1/track"
HEADERS = {"Authorization": f"Bearer {os.environ['OPENCONTAINER_API_KEY']}"}
BATCH = 35 # stays under the per-line limit whatever the mix of lines
def chunks(items, n):
it = iter(items)
while chunk := list(islice(it, n)):
yield chunk
with open("containers.csv") as f:
rows = list(csv.DictReader(f))
# Group by the line named in the sheet ("" means detect it from the prefix).
groups = defaultdict(list)
for row in rows:
groups[(row.get("carrier") or "").strip().lower()].append(row["container"].strip().upper())
answers = {}
for carrier, numbers in groups.items():
for chunk in chunks(sorted(set(numbers)), BATCH):
params = {"numbers": ",".join(chunk)}
if carrier:
params["carrier"] = carrier
res = requests.get(API, params=params, headers=HEADERS, timeout=120)
res.raise_for_status()
for entry in res.json()["results"]:
answers[entry["trackingNumber"]] = entry
with open("containers-tracked.csv", "w", newline="") as f:
out = csv.writer(f)
out.writerow(["container", "carrier", "status", "latest_move", "latest_location", "latest_time", "eta", "error"])
for row in rows:
entry = answers.get(row["container"].strip().upper(), {})
r = entry.get("result") or {}
latest = (r.get("events") or [{}])[0]
out.writerow([
row["container"], r.get("carrier"), r.get("status"),
latest.get("description"), latest.get("location"),
latest.get("timestamp") or latest.get("localTime"),
r.get("estimatedDelivery"), (entry.get("error") or {}).get("code"),
])Batches of 35 keep each call under the per-line limit even when a sheet is all one line. If your list is well mixed, raise BATCH toward 100.
Reading the errors column
error | What to do |
|---|---|
unknown_carrier | The check digit is wrong (a typo), or it is a leased container or bill of lading: add the line in the carrier column. |
not_found | The line has no record of it. Check the number, or try again later: a new booking can take a while to appear. |
carrier_error, carrier_unavailable | The line failed or isn't answering right now. Run those rows again later; they weren't billed. |
rate_limited | The Free plan's allowance ran out part-way. Upgrade, or run the rest later. |
From a batch to watches
A batch tells you where containers are now. To be told when they move, create watches for the ones still in transit, 100 per request, and set a webhook once:
curl -X POST https://api.containerfeed.com/v1/watches \
-H "Authorization: Bearer $OPENCONTAINER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"trackingNumbers": ["MEDU1234562", "ONEU1234566"], "metadata": {"po": "PO-1042"}}'The response has each watch with its current result. After that, OpenContainer re-checks every container on a schedule and POSTs a signed event when its status, latest move or ETA changes. You can also paste up to 100 numbers on the dashboard's Watches page. See Watches and webhooks.
Tracking
Track one container or bill of lading, or up to 100 at once. Line detection from ISO 6346 owner prefixes, statuses and milestones, and every response field.
Container tracking webhooks: watches and signed events
Watch containers and bills of lading, and get a signed tracking.updated webhook when a milestone, the vessel or voyage, the POL/POD or the ETA changes. No carrier EDI or webhook setup. Optional Terminal49-compatible payload.