Examples
Minimal receivers that discover links, stream SSE, validate events, and recover via snapshot plus events.
Environment
Set TRADEE_OUTPUT_FEED_URL to the secret metadata URL from Connections. Never log that URL.
Discover links (Python)
import json, os
from urllib.request import Request, urlopen
FEED_URL = os.environ["TRADEE_OUTPUT_FEED_URL"]
def discover():
if "/api/v1/output/feeds/" not in FEED_URL:
raise ValueError("TRADEE_OUTPUT_FEED_URL must be a generated metadata URL")
request = Request(FEED_URL, headers={"Accept": "application/json"})
with urlopen(request, timeout=30) as response:
metadata = json.load(response)
if metadata["schema_version"] != 1:
raise ValueError("unsupported feed schema")
return metadata["links"]Discover links (Node)
const FEED_URL = process.env.TRADEE_OUTPUT_FEED_URL;
async function discover() {
if (!FEED_URL.includes("/api/v1/output/feeds/")) {
throw new Error("TRADEE_OUTPUT_FEED_URL must be a generated metadata URL");
}
const response = await fetch(FEED_URL, {
headers: { Accept: "application/json" },
});
const metadata = await response.json();
if (metadata.schema_version !== 1) throw new Error("unsupported feed schema");
return metadata.links;
}Recovery sketch (Python)
from urllib.parse import urlencode
def recover(links, replace_snapshot, apply_page):
snapshot = get_json(links["snapshot"])
replace_snapshot(snapshot["positions"], snapshot["cursor"])
cursor = snapshot["cursor"]
while True:
page = get_json(
f"{links['events']}?{urlencode({'after': cursor, 'limit': 100})}"
)
apply_page(page["events"], page["cursor"])
cursor = page["cursor"]
if not page["has_more"]:
return cursorSSE reconnect header
headers = {"Accept": "text/event-stream", "Cache-Control": "no-cache"}
if committed_cursor:
headers["Last-Event-ID"] = committed_cursorFull reference receivers
Complete standard-library examples live in the Tradee repository under .docs/api-outputs/examples/:
receiver.py- Pythonreceiver.mjs- Nodefetch
Both discover links from TRADEE_OUTPUT_FEED_URL, parse ready and modeled SSE events, reconnect with Last-Event-ID, enforce decimal strings and revisions, and show snapshot-plus-events recovery. They intentionally contain no exchange client or order-placement code. Production receivers must add a durable store: commit the event projection, dedupe record, and SSE id in one transaction.
Machine-readable paths and schemas: openapi.json.