cbamsdk
v1.0.0
Published
Official Node.js SDK for the CBAM Platform API. Integrate EU Carbon Border Adjustment Mechanism (CBAM) reporting, validation, and AI-powered document extraction.
Maintainers
Readme
cbamsdk
Official Node.js SDK for the CBAM Platform API. Integrate EU Carbon Border Adjustment Mechanism (CBAM) reporting, validation, and AI-powered document extraction into your Node.js or TypeScript applications with ease.
Installation
```bash npm install cbamsdk ```
Quick Start
```javascript const { CBAMClient } = require('cbamsdk');
// Initialize the client // Set sandbox: true to use the testing environment const client = new CBAMClient('cbam_sk_sandbox_YOUR_KEY', { sandbox: true });
async function run() { try { // 1. Get Default Emission Values const defaults = await client.getDefaultValues(); console.log("Default Values:", defaults);
// 2. Perform AI Intake from a Commercial Invoice
const intakeOptions = {
payloadFormat: 'json',
language: 'en',
requestedOutputs: 'official_xml,zip'
};
// Provide the absolute or relative path to the PDF invoice
const result = await client.directIntake('./invoice.pdf', intakeOptions);
console.log("Intake Request ID:", result.data.request_id);
// 3. Download a completed report
// const stream = await client.downloadReport('req-sandbox-12345');
// stream.pipe(fs.createWriteStream('report.zip'));} catch (error) { console.error(error.message); } }
run(); ```
Advanced Usage (ERP Integration)
For high-security environments like ERP gateways, use the `submitIntegration` method which supports HMAC signatures and custom Idempotency Keys.
```javascript const result = await client.submitIntegration( './fatura.pdf', { external_reference: 'ERP-INV-001', requested_outputs: ['official_xml'] }, { schema_version: 'cbam-intake-v1', target_country: 'DE' }, // optional payload { 'X-CBAM-Timestamp': '1778064000', 'X-CBAM-Nonce': 'ERP-INV-001-01', 'X-CBAM-Signature': 'a1b2c3d4...', 'Idempotency-Key': 'ERP-INV-001' } ); ```
Features
- Full API Wrapper for `/api/v1/cbam/*`
- Automatic `multipart/form-data` handling for file uploads
- Clean error handling wrapping HTTP responses
- Production and Sandbox ready
License
MIT
