npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

factus-js

v2.4.0

Published

TypeScript SDK for the Factus Colombian e-invoicing API

Readme

factus-js

npm version license npm downloads

SDK TypeScript/JavaScript para la API de Factus.

Documentación completa: https://factusjs.vercel.app

Características

  • Cobertura completa de la API Factus v2: facturas, notas crédito, notas débito, nóminas, notas de ajuste de nómina, documentos soporte, notas de ajuste, recepción RADIAN, rangos de numeración, suscripciones y más.
  • Autenticación OAuth2 automática con refresh y un reintento ante token expirado.
  • Tipado fuerte en TypeScript para payloads y respuestas.
  • Constantes DIAN tipadas como PaymentFormCode, IdentityDocumentCode, EventCode, etc.
  • Iterador de paginación automática con listAll() en módulos paginados.
  • Soporte de AbortSignal y timeout a nivel de cliente.
  • Compatibilidad en runtime con Node.js >= 18, Deno y Bun.
  • Cero dependencias en runtime.

Instalación

# npm
npm install factus-js

# yarn
yarn add factus-js

# pnpm
pnpm add factus-js

# bun
bun add factus-js

Uso básico

import {
  FactusClient,
  CustomerTributeCode,
  IdentityDocumentCode,
  OrganizationTypeCode,
  PaymentFormCode,
  PaymentMethodCode,
  ProductStandardCode,
} from "factus-js";

const factus = new FactusClient({
  clientId: process.env.FACTUS_CLIENT_ID!,
  clientSecret: process.env.FACTUS_CLIENT_SECRET!,
  username: process.env.FACTUS_USERNAME!,
  password: process.env.FACTUS_PASSWORD!,
  environment: "sandbox", // usa "production" en producción
});

const bill = await factus.bills.create({
  numbering_range_id: 8,
  reference_code: "INV-001",
  payment_details: [
    {
      payment_form: PaymentFormCode.CreditPayment,
      payment_method_code: PaymentMethodCode.Transfer,
      amount: "50000.00",
      due_date: "2026-12-31",
    },
  ],
  customer: {
    identification_document_code: IdentityDocumentCode.CitizenshipCard,
    identification: "123456789",
    names: "Alan Turing",
    address: "Calle 1 # 2-68",
    email: "[email protected]",
    phone: "1234567890",
    legal_organization_code: OrganizationTypeCode.NaturalPerson,
    tribute_code: CustomerTributeCode.NotApplicable,
    country_code: "CO",
    municipality_code: "68679",
  },
  items: [
    {
      code_reference: "PROD-001",
      name: "Test product",
      quantity: 1,
      discount_rate: 0,
      price: 50000,
      unit_measure_code: "94",
      standard_code: ProductStandardCode.TaxpayerAdoption,
      taxes: [{ code: "01", rate: "19.00" }],
    },
  ],
});

console.log(bill.data.number);

Módulos disponibles

| Módulo | Descripción | | --------------------------- | --------------------------------------------------------- | | factus.bills | Facturas electrónicas de venta | | factus.creditNotes | Notas crédito | | factus.debitNotes | Notas débito | | factus.supportDocuments | Documentos soporte | | factus.adjustmentNotes | Notas de ajuste de documentos soporte | | factus.payrolls | Nóminas electrónicas | | factus.adjustmentPayrolls | Notas de ajuste de nómina | | factus.reception | Recepción RADIAN y eventos de facturas recibidas | | factus.acquirer | Consulta de adquiriente por identificación | | factus.company | Datos de la empresa y carga de logo | | factus.numberingRanges | Rangos de numeración DIAN | | factus.subscription | Suscripción y estado de cupo | | factus.documents | Descarga genérica de XML por identificador de seguimiento |

Constantes DIAN

Las constantes son valores tipados directos. Úsalas tal cual en los payloads, sin .value.

import {
  EventCode,
  IdentityDocumentCode,
  IdentityDocumentCodeInfo,
  PaymentFormCode,
  PaymentFormCodeInfo,
} from "factus-js";

const documentCode = IdentityDocumentCode.CitizenshipCard;
const abbreviation = IdentityDocumentCodeInfo[documentCode].abbreviation;

const paymentForm = PaymentFormCode.CreditPayment;
const paymentLabel = PaymentFormCodeInfo[paymentForm].description;

Manejo de errores

import { FactusClient, FactusError } from "factus-js";

try {
  await factus.bills.create({
    // ...
  });
} catch (error) {
  if (error instanceof FactusError) {
    console.error(error.statusCode);
    console.error(error.message);
    console.error(error.validationErrors);
  }
}

Exportaciones

import {
  FactusClient,
  FactusError,
  EventCode,
  IdentityDocumentCode,
  PaymentFormCode,
  PaymentMethodCode,
  type FactusClientConfig,
  type RequestOptions,
} from "factus-js";

Licencia

MIT