Node.js SDK quickstart
5 min read Updated February 10, 2026
Installation
bash
npm install @compliancegrid/sdk
Configuration
javascript
import { ComplianceGrid } from '@compliancegrid/sdk';
const cg = new ComplianceGrid({
apiKey: process.env.CG_API_KEY, // cg_sk_ or cg_pk_
environment: 'sandbox', // 'sandbox' or 'production'
});The SDK automatically handles OAuth token exchange, token caching, and token refresh. You never need to manage Bearer tokens manually.
Screening Example
javascript
const result = await cg.compliance.screenParties({
parties: [{
name: 'Acme Global Trading',
country: 'DE',
type: 'CONSIGNEE'
}]
});
console.log(result.overallResult); // 'CLEAR'
console.log(result.listsScreened); // ['SDN', 'Entity List', ...]HS Code Lookup
javascript
const codes = await cg.hs.search({ query: 'laptop' });
console.log(codes[0].htsNumber, codes[0].description);Error Handling
javascript
try {
const result = await cg.compliance.screenParties({ parties });
} catch (err) {
if (err.status === 429) {
// Rate limited — SDK retries automatically with backoff
} else if (err.status === 401) {
// Token expired — SDK refreshes automatically
}
console.error(err.message, err.code);
}The SDK includes automatic retry with exponential backoff for 429 and 5xx errors (up to 3 retries). Token refresh happens transparently.
TypeScript Support
The SDK ships with full TypeScript type definitions. All request and response types are exported from the package.
Was this article helpful?