› compliance_grid.aiCOMPLIANCEGRIDGOV · COMPLIANCE · INTELLIGENCE
Help Center/SDKs & Libraries

Node.js quickstart

4 min read Updated October 21, 2026

SDK status

The Node.js SDK is a source preview at github.com/compliancegrid-ai/compliancegrid-node. It is not yet published to npm, so npm install @compliancegrid/sdk does not work. Node 18 and later has fetch built in, which is all you need.

Calling the API

javascript
const key = process.env.CG_API_KEY; // cg_sk_ (sandbox) or cg_pk_ (production)
const host = key.startsWith('cg_sk_') ? 'https://sandbox.api.compliancegrid.ai' : 'https://api.compliancegrid.ai';
const headers = { 'x-api-key': key, 'Content-Type': 'application/json' };

const res = await fetch(host + '/v1/compliance/restricted-party-screening', {
  method: 'POST',
  headers,
  body: JSON.stringify({ parties: [{ name: 'Acme Global Trading', country: 'DE' }] }),
});
const { data } = await res.json();

console.log(data.overallResult); // 'CLEAR' or 'POTENTIAL_MATCH'
console.log(data.totalMatches);

HS code search

javascript
const res = await fetch(host + '/v1/hs/search?q=laptop&limit=5', { headers });
const { data } = await res.json();
console.log(data.results[0].htsNumber, data.results[0].description);

Error handling

javascript
if (res.status === 429) {
  const wait = Number(res.headers.get('retry-after') ?? 1);
  // wait, then retry with exponential backoff
} else if (!res.ok) {
  const body = await res.json();
  // authentication errors: { error: 'invalid_api_key', message }
  // other errors: { success: false, error: { code, message, details } }
  console.error(body.error);
}

Nothing retries for you: add your own backoff for 429 and 5xx responses. Log the X-Compliance-Grid-Request-Id response header and quote it if you contact support.

Was this article helpful?