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

v1.0.0

Published

TypeScript SDK for the Factus Colombian e-invoicing API

Readme

factus-js

npm version license npm downloads

TypeScript/JavaScript SDK for the Factus API for Colombian e-invoicing.

Full documentation: https://factusjs.vercel.app

Features

  • Full coverage of Factus API domains: bills, credit notes, support documents, adjustment notes, RADIAN reception, numbering ranges, catalogs, and more.
  • Automatic OAuth2 authentication with refresh and one-time retry on expired token.
  • Strong TypeScript typing for payloads and responses.
  • Typed DIAN constants (PaymentFormCode, IdentityDocumentTypeId, and more) as direct value maps.
  • Automatic pagination iterator with listAll() for paginated modules.
  • AbortSignal support and client-level timeout.
  • Runtime compatibility with Node.js >= 18, Deno, and Bun.
  • Zero runtime dependencies.

Installation

# npm
npm install factus-js

# yarn
yarn add factus-js

# pnpm
pnpm add factus-js

# bun
bun add factus-js

Basic usage

import {
  FactusClient,
  PaymentFormCode,
  PaymentMethodCode,
  IdentityDocumentTypeId,
  OrganizationTypeId,
  CustomerTributeId,
  ProductStandardId,
} 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", // use "production" for live usage
});

const invoice = await factus.bills.create({
  numbering_range_id: 8,
  reference_code: "INV-001",
  payment_form: PaymentFormCode.CreditPayment,
  payment_due_date: "2026-12-31",
  payment_method_code: PaymentMethodCode.Cash,
  customer: {
    identification_document_id: IdentityDocumentTypeId.CitizenshipId,
    identification: "123456789",
    names: "Alan Turing",
    address: "Calle 1 # 2-68",
    email: "[email protected]",
    phone: "1234567890",
    legal_organization_id: OrganizationTypeId.NaturalPerson,
    tribute_id: CustomerTributeId.NotApplicable,
    municipality_id: 980,
  },
  items: [
    {
      code_reference: "PROD-001",
      name: "Test product",
      quantity: 1,
      discount_rate: 0,
      price: 50000,
      tax_rate: "19.00",
      unit_measure_id: 70,
      standard_code_id: ProductStandardId.TaxpayerAdoption,
      is_excluded: 0,
      tribute_id: 1,
    },
  ],
});

console.log(invoice.data);

Available modules

| Module | Description | | ------------------------- | ----------------------------------------------- | | factus.bills | Electronic sales invoices | | factus.creditNotes | Credit notes | | factus.supportDocuments | Support documents | | factus.adjustmentNotes | Adjustment notes for support documents | | factus.reception | RADIAN reception and invoice events | | factus.company | Company data | | factus.numberingRanges | DIAN numbering ranges | | factus.subscription | Subscription and quota status | | factus.catalog | Municipalities, countries, tributes, and others |

DIAN constants

Constants are direct typed values. Use them directly in payloads, without .value.

import {
  PaymentFormCode,
  PaymentMethodCode,
  IdentityDocumentTypeId,
  OrganizationTypeId,
  CustomerTributeId,
  ProductStandardId,
  EventCode,
  PaymentFormCodeInfo,
  IdentityDocumentTypeIdInfo,
} from "factus-js";

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

Error handling

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);
  }
}

Exports

import {
  FactusClient,
  FactusError,
  PaymentMethodCode,
  PaymentFormCode,
  IdentityDocumentTypeId,
  PaymentFormCodeInfo,
  IdentityDocumentTypeIdInfo,
  type RequestOptions,
  type FactusClientConfig,
} from "factus-js";

License

MIT