Intelligence API code examples
Copy-paste examples for the Intelligence API in curl, JavaScript (fetch) and Python (requests): screen a deposit address, label a batch, check a spender before approval, and handle every response state.
All examples read the key from TRIPORT_API_KEY. The key needs the intelligence:read scope on a Business or Enterprise plan; see the Intelligence API overview for limits and states.
Screen a deposit address (curl)
curl -X POST "https://triport.io/v1/intelligence/address-risk" \
-H "x-token: $TRIPORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"chain":"eth","address":"0x28c6c06298d514db089934071355e5743bf21d60"}'The answer carries data.assessment.risk.value (a string, or null when unknown) and data.assessment.risk.level. See Address risk score.
Screen an address and decide (JavaScript)
The decision function treats an unknown score as "needs review", never as "clean". It keeps partial and stale answers instead of discarding them.
const BASE = "https://triport.io/v1/intelligence";
async function intel(path, body) {
const res = await fetch(`${BASE}/${path}`, {
method: "POST",
headers: { "x-token": process.env.TRIPORT_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify(body),
signal: AbortSignal.timeout(60_000),
});
if (res.status === 429) {
const wait = Number(res.headers.get("Retry-After") ?? "1");
throw Object.assign(new Error("rate_limited"), { retryAfter: wait });
}
return { status: res.status, ...(await res.json()) };
}
// Your policy. Levels seen on 2026-11-06 include "none" and "high"; treat any
// level you have not mapped yet as "review".
const POLICY = { none: "allow", high: "block" };
async function screen(address) {
const r = await intel("address-risk", { chain: "eth", address });
if (r.state === "unsupported" || r.state === "unavailable") return { decision: "review", reason: r.error?.code };
const risk = r.data?.assessment?.risk;
if (!risk || risk.value === null || risk.level === "unknown") return { decision: "review", reason: "unknown_risk" };
return { decision: POLICY[risk.level] ?? "review", level: risk.level, value: risk.value, state: r.state };
}
console.log(await screen("0x28c6c06298d514db089934071355e5743bf21d60"));Which levels you allow or block is your compliance decision; log the full assessment so a reviewer can see what the score was based on.
Label a batch of counterparties (Python)
import os
import requests
r = requests.post(
"https://triport.io/v1/intelligence/labels/batch",
headers={"x-token": os.environ["TRIPORT_API_KEY"]},
json={
"chain": "eth",
"addresses": [
"0xdac17f958d2ee523a2206206994597c13d831ec7",
"0x7a250d5630b4cf539739df2c5dacd4c659f2488d",
],
},
timeout=60,
)
body = r.json()
for item in body.get("data", {}).get("items", []):
label = (item.get("identity") or {}).get("label")
print(item["inputAddress"], item["state"], label or "(no label found)")Each address is one request against the per-second limit, so a batch of 200 on Business (30 rps, burst 60) needs to be spread over several seconds. See Address labels (batch).
Check a spender before approval (curl)
curl -X POST "https://triport.io/v1/intelligence/approval-risk" \
-H "x-token: $TRIPORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"spenders":[{"chain":"eth","address":"0x7a250d5630b4cf539739df2c5dacd4c659f2488d"}]}'Read data.items[i].state and data.items[i].assessment for each spender. See Token approval risk.
GET routes
Block, fee and creation lookups are GET requests with the chain (and address) in the path:
curl "https://triport.io/v1/intelligence/eth/0xdac17f958d2ee523a2206206994597c13d831ec7/creation" \
-H "x-token: $TRIPORT_API_KEY"
curl "https://triport.io/v1/intelligence/eth/base-fee?fresh=1" \
-H "x-token: $TRIPORT_API_KEY"fresh=1 is the only query parameter accepted on GET routes.
Handling states and errors
- Branch on
statefirst, then on the HTTP status. A200withpartialorstaleis useful data; it may also carry anerror. 422 unsupportedmeans the method does not cover that chain or contract: do not retry it.429 rate_limited: waitRetry-Afterseconds (also inerror.retryAfterSeconds).503 unavailableand504 timeout: retry later with backoff; a later call may be answered from cache.- Keep scores, amounts, block numbers and
paramsJSONas strings, or parse them with arbitrary precision.