FacturAPI

This is the official HTTP client for https://www.facturapi.io
FacturAPI makes it easy for developers to generate valid Invoices in Mexico (known as Factura Electrónica or CFDI).
If you've ever used Stripe or Conekta, you'll find FacturAPI very straightforward to understand and integrate in your server app.
Compatibility
- Node.js 12.x or higher
- Browsers with Fetch API support
- React Native
Install
npm install --save facturapi
Getting started
Authenticate with your API Key
Make sure you have created your free account on FacturAPI and that you have your API Keys.
import Facturapi from 'facturapi';
const Facturapi = require('facturapi').default;
const facturapi = new Facturapi('YOUR_API_KEY', {
apiVersion: 'v2',
});
Create a customer
facturapi.customers
.create({
legal_name: 'Walter White',
tax_id: 'WIWA761018',
email: 'walterwhite@gmail.com',
address: {
street: 'Av. de los Rosales',
exterior: '123',
neighborhood: 'Tepito',
zip: '06800',
},
})
.then((customer) => {
})
.catch((err) => console.log(err));
Create a product
facturapi.products
.create({
product_key: '4319150114',
description: 'Apple iPhone 8',
price: 20000,
})
.then((product) => {
})
.catch((err) => console.log(err));
Create an invoice
facturapi.invoices.create({
customer: 'YOUR_CUSTOMER_ID',
payment_form: Facturapi.PaymentForm.TRANSFERENCIA_ELECTRONICA,
items: [{
quantity: 1,
product: 'YOUR_PRODUCT_ID'
}]
}).then(invoice => { ... });
Download your invoice
const fs = require('fs');
facturapi.invoices.downloadZip(invoice.id)
.then(zipStream => {
const myZipFile = fs.createWriteStream('/path/to/destination/folder');
zipStream.pipe(myZipFile);
myZipFile.on('finish', () => {
});
Send your invoice by email
facturapi.invoices
.sendByEmail(invioce.id)
.then(() => {
})
.catch((err) => console.log(err));
Documentation
There's more you can do with this library: List, retrieve, update, and remove Customers, Products and Invoices.
Visit the full documentation at http://docs.facturapi.io.
Help
Found a bug?
Please report it on the Issue Tracker
Want to contribute?
Send us your PR! We appreciate your help :)
Contact us!
contacto@facturapi.io