Call Sloe from your backend
A small server-side client with input validation and explicit failures.
This example uses standard Node.js APIs. It is a building block for your own backend, not an official Sloe SDK or a complete authorization layer.
export async function getSloeInstitution(charter) {
if (!/^[0-9]+$/.test(String(charter))) {
throw new TypeError('charter must be a numeric identifier');
}
const key = process.env.SLOE_API_KEY;
if (!key) throw new Error('SLOE_API_KEY is not configured');
const url = new URL('/api/cuwiredata-institution', 'https://sloedata.com');
url.searchParams.set('charter', String(charter));
const response = await fetch(url, {
headers: { Authorization: `Bearer ${key}` },
signal: AbortSignal.timeout(30_000),
cache: 'no-store',
});
const payload = await response.json();
if (!response.ok || payload.ok !== true) {
const error = new Error(`Sloe request failed: HTTP ${response.status}`);
error.status = response.status;
error.traceId = payload.trace_id;
throw error;
}
return payload.data;
}Before exposing it to your users
Authenticate and authorize callers in your own app. Return only the fields they are entitled to see. Do not accept an arbitrary upstream URL from the browser; use fixed endpoint paths and validated parameters.
Use bounded retries for transient failures. Preserve the upstream status and trace ID in safe logs. Never log the Authorization header or a full credential-bearing request object.
Display data honestly
Keep identifiers as strings. Do not round financial values before storing them or replace null with zero. Display each value's reporting period and use its stated unit: _usd fields are dollars, and _pct fields are percentage values rather than fractions.
Financial calculations that require exact decimals should use a decimal-capable database or library. JavaScript floating-point arithmetic is not an independent verification of financial sums.
If a client app cannot hold a secret, call your own backend. This documentation site is not an authenticated API proxy, and browser CORS availability is not an access entitlement.