Client libraries
There is no official SDK for the Dockflow API (v3). The API is JSON over HTTPS with a single
Authorization header, so any HTTP client works and a wrapper adds little.
The examples below send a tradeflow and read it back. They need a key with the downstream and upstream scopes and run against the
UAT sandbox; switch the host to api.dockflow.com and use a prod_ key for production.
Pythonโ
import os
import time
import requests
BASE = "https://uat.dockflow.com/v3"
HEADERS = {"Authorization": os.environ["DOCKFLOW_KEY"]}
resp = requests.post(
f"{BASE}/downstream/tradeflows",
headers=HEADERS,
json={
"tradeflow_reference": "PO4564268",
"port_of_loading": "BEANR",
"port_of_discharge": "USLAX",
"mock_tracking": {"scenario": "ocean_basic"},
},
)
resp.raise_for_status() # 202 Accepted, {"status": "queued", ...}
# Processing finishes a few seconds after the 202, so retry until the record appears.
for _ in range(10):
data = requests.get(f"{BASE}/upstream", headers=HEADERS, params={"tradeflow": "PO4564268"}).json()["data"]
if data:
break
time.sleep(3)
print(data)
TypeScriptโ
const BASE = "https://uat.dockflow.com/v3";
const headers = {
Authorization: process.env.DOCKFLOW_KEY!,
"Content-Type": "application/json",
};
const sent = await fetch(`${BASE}/downstream/tradeflows`, {
method: "POST",
headers,
body: JSON.stringify({
tradeflow_reference: "PO4564268",
port_of_loading: "BEANR",
port_of_discharge: "USLAX",
mock_tracking: { scenario: "ocean_basic" },
}),
});
if (sent.status !== 202) throw new Error(await sent.text());
// Processing finishes a few seconds after the 202, so retry until the record appears.
let data: unknown[] = [];
for (let i = 0; i < 10 && data.length === 0; i++) {
if (i > 0) await new Promise((r) => setTimeout(r, 3000));
const page = await fetch(`${BASE}/upstream?tradeflow=PO4564268`, { headers });
data = (await page.json()).data;
}
console.log(data);
Continuous syncโ
For a production feed, poll GET /v3/upstream with failsafe=1 or receive webhooks. The polling
loop, cursor handling and webhook setup are described in the Upstream guide.
Working with an AI coding assistantโ
Give the assistant docs.dockflow.com/llms-full.txt, the
complete Dockflow API documentation as one text file. Every page is also served as markdown at its
URL plus .md.
Was this page helpful?