smartbill-ts-sdk
v1.1.8
Published
SmartBill TypeScript SDK
Downloads
23
Maintainers
Readme
SmartBill TypeScript SDK
SmartBill API Documentation GitHub: https://github.com/florin-szilagyi/smartbill-ts-sdk
English
Overview
This SDK provides a convenient way to interact with the SmartBill API from Node.js/TypeScript projects. It supports operations for invoices, proforma invoices (estimates), payments, configuration, and stock management.
Features
- Create, view, and manage invoices and proforma invoices
- Send documents by email
- Download PDFs
- Manage payments and stock
- Full TypeScript support and validation
Installation
pnpm add smartbill-ts-sdkUsage
Initialization
import { SmartBillSDK } from 'smartbill-ts-sdk';
const sdk = new SmartBillSDK({
email: process.env.SMARTBILL_EMAIL!,
token: process.env.SMARTBILL_TOKEN!,
verbose: true,
});Create a Simple Invoice
const invoicePayload = {
companyVatCode: 'RO12345678',
client: {
name: 'Test Client',
vatCode: 'RO12345678',
isTaxPayer: true,
address: 'Str. Test nr. 1',
city: 'Bucharest',
country: 'Romania',
email: '[email protected]',
saveToDb: false,
},
seriesName: 'FCT',
issueDate: '2025-04-19',
products: [
{
name: 'Product 1',
measuringUnitName: 'buc',
currency: 'RON',
quantity: 1,
price: 100,
taxName: 'Normala',
taxPercentage: 19,
saveToDb: false,
isService: false,
},
],
};
const response = await sdk.invoices.create(invoicePayload);Download Invoice PDF
const pdfBuffer = await sdk.invoices.getPdf({
cif: 'RO12345678',
seriesname: 'FCT',
number: '123',
});
// Save pdfBuffer to file if neededCreate a Proforma Invoice (Estimate)
const estimatePayload = {
companyVatCode: 'RO12345678',
client: { ... }, // same as above
seriesName: 'PFA',
issueDate: '2025-04-19',
dueDate: '2025-05-19',
products: [ ... ],
};
const response = await sdk.estimates.create(estimatePayload);Send Document by Email
await sdk.invoices.sendEmail({
companyVatCode: 'RO12345678',
seriesName: 'FCT',
number: '123',
type: 'invoice',
to: '[email protected]',
});Romanian / Română
Prezentare generală
Acest SDK oferă o modalitate simplă de a interacționa cu API-ul SmartBill din proiecte Node.js/TypeScript. Permite operațiuni pentru facturi, proforme, plăți, configurare și gestiune stocuri.
Funcționalități
- Creare, vizualizare și gestionare facturi și proforme
- Trimitere documente pe email
- Descărcare PDF-uri
- Administrare plăți și stocuri
- Validare și suport complet TypeScript
Instalare
pnpm add smartbill-ts-sdkUtilizare
Inițializare
import { SmartBillSDK } from 'smartbill-ts-sdk';
const sdk = new SmartBillSDK({
email: process.env.SMARTBILL_EMAIL!,
token: process.env.SMARTBILL_TOKEN!,
verbose: true,
});Emitere Factură Simplă
const payloadFactura = {
companyVatCode: 'RO12345678',
client: {
name: 'Client Test',
vatCode: 'RO12345678',
isTaxPayer: true,
address: 'Str. Test nr. 1',
city: 'București',
country: 'România',
email: '[email protected]',
saveToDb: false,
},
seriesName: 'FCT',
issueDate: '2025-04-19',
products: [
{
name: 'Produs 1',
measuringUnitName: 'buc',
currency: 'RON',
quantity: 1,
price: 100,
taxName: 'Normala',
taxPercentage: 19,
saveToDb: false,
isService: false,
},
],
};
const response = await sdk.invoices.create(payloadFactura);Descărcare PDF Factură
const pdfBuffer = await sdk.invoices.getPdf({
cif: 'RO12345678',
seriesname: 'FCT',
number: '123',
});
// Salvează pdfBuffer într-un fișier dacă este nevoieEmitere Proformă
const payloadProforma = {
companyVatCode: 'RO12345678',
client: { ... }, // la fel ca mai sus
seriesName: 'PFA',
issueDate: '2025-04-19',
dueDate: '2025-05-19',
products: [ ... ],
};
const response = await sdk.estimates.create(payloadProforma);Trimitere Document pe Email
await sdk.invoices.sendEmail({
companyVatCode: 'RO12345678',
seriesName: 'FCT',
number: '123',
type: 'invoice',
to: '[email protected]',
});References
- Official SmartBill API Docs
- See
tests/for more advanced usage and edge cases.
