Calling the API from JavaScript
There is no official IndiTrace SDK yet — these fetch examples call the public and signed-in endpoints directly.
IndiTrace does not publish an SDK package yet. The API is plain JSON over HTTPS, so fetch (or any HTTP client) is all you need. Replace API with the API base URL for your edition.
Look up a batch from its QR code (no sign-in)
const API = 'https://<your-edition-api>/api/v1';
async function traceBatch(batchUid) {
const res = await fetch(`${API}/batches/public/trace/${encodeURIComponent(batchUid)}/`);
if (res.status === 404) return null;
if (!res.ok) throw new Error(`Trace lookup failed (${res.status})`);
return res.json(); // product, origin, timeline, blockchain_proof, blockchain_network, …
}
blockchain_proof holds the transaction hash and explorer link once the batch is anchored; blockchain_network names the chain it was anchored on.
Signed-in requests
async function signIn(email, password) {
const res = await fetch(`${API}/auth/login/`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password }),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error || 'Sign-in failed');
return data; // { access, refresh, user } — or { code: '2fa_required', challenge }
}
async function listBatches(access) {
const res = await fetch(`${API}/batches/`, { headers: { Authorization: `Bearer ${access}` } });
if (res.status === 401) throw new Error('Access token expired — refresh it');
return res.json();
}
Access tokens last 15 minutes; see Authentication for refreshing and signing out.
Integrations
Server-to-server credentials, webhooks and higher limits are arranged per partner. Contact us to discuss an integration.