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

@viniciuskrausche/asaas-sdk

v0.1.0

Published

Base de SDK em Node.js com TypeScript

Readme

@vinikrausche/asaas-sdk

SDK Node.js + TypeScript para integrar com a API do Asaas com foco em simplicidade:

  • inicializacao unica com token
  • selecao de ambiente (sandbox ou production)
  • recursos por dominio (customers e subscriptions)
  • validacao de entrada e saida com Zod

Requisitos

  • Node.js 20+
  • npm 10+

Instalacao

npm install @vinikrausche/asaas-sdk

Inicializacao da SDK

import { createAsaasSdk } from "@vinikrausche/asaas-sdk";

const sdk = createAsaasSdk({
  apiKey: process.env.ASAAS_API_KEY!,
  environment: "sandbox"
});

Configuracao disponivel

  • apiKey (obrigatorio): chave da API Asaas
  • environment (opcional): "sandbox" (padrao) ou "production"
  • baseUrl (opcional): sobrescreve a URL base (somente https)
  • timeoutMs (opcional): timeout HTTP em ms (padrao 30000)

Ambientes

  • sandbox -> https://api-sandbox.asaas.com
  • production -> https://api.asaas.com

Auth

O token e enviado no header access_token.

Voce pode trocar o token em runtime:

sdk.setApiKey("nova-chave");

O retorno de sdk.getConfig() mascara o apiKey para reduzir risco de vazamento em logs.

Recursos implementados

  • sdk.customers.create(...)
  • sdk.subscriptions.create(...)

Customers

Endpoint: POST /v3/customers

Referencia oficial:

  • https://docs.asaas.com/reference/criar-novo-cliente

Exemplo

const customer = await sdk.customers.create({
  name: "John Doe",
  cpfCnpj: "24971563792",
  email: "[email protected]",
  phone: "4738010919",
  mobilePhone: "4799376637"
});

console.log(customer.id);

Subscriptions

Endpoint: POST /v3/subscriptions

Referencia oficial:

  • https://docs.asaas.com/reference/criar-nova-assinatura

Exemplo minimo

const subscription = await sdk.subscriptions.create({
  customer: "cus_000005401844",
  billingType: "BOLETO",
  value: 19.9,
  nextDueDate: "2026-03-10",
  cycle: "MONTHLY"
});

console.log(subscription.id);

Exemplo completo

const subscription = await sdk.subscriptions.create({
  customer: "cus_000005401844",
  billingType: "PIX",
  value: 29.9,
  nextDueDate: "2026-03-10",
  cycle: "MONTHLY",
  description: "Plano Pro",
  endDate: "2026-12-10",
  maxPayments: 12,
  externalReference: "SUB-1001",
  discount: {
    value: 10,
    dueDateLimitDays: 0,
    type: "PERCENTAGE"
  },
  interest: {
    value: 2
  },
  fine: {
    value: 1,
    type: "PERCENTAGE"
  },
  split: [
    {
      walletId: "wallet_123",
      percentualValue: 20
    }
  ],
  callback: {
    successUrl: "https://app.exemplo.com/pagamento/sucesso",
    autoRedirect: true
  }
});

console.log(subscription.status);

Tratamento de erro

Erros HTTP da API sao normalizados em AsaasRequestError.

import { AsaasRequestError } from "@vinikrausche/asaas-sdk";

try {
  await sdk.customers.create({
    name: "Nome sem documento",
    cpfCnpj: ""
  });
} catch (error) {
  if (error instanceof AsaasRequestError) {
    console.log(error.status);
    console.log(error.errors);
    console.log(error.data);
  }
}

Estrutura do projeto

src
├── core
│   └── http
│       └── asaas-http-client.ts
├── modules
│   ├── customer
│   │   ├── dto
│   │   │   └── customer.dto.ts
│   │   └── resource
│   │       └── customer.resource.ts
│   └── subscription
│       ├── dto
│       │   └── subscription.dto.ts
│       └── resource
│           └── subscription.resource.ts
├── sdk.ts
└── index.ts

Scripts

  • npm run check: validacao de tipos sem gerar arquivos
  • npm run build: compilacao TypeScript para dist/
  • npm run dev: compilacao em watch mode
  • npm test: executa testes automatizados (build + node:test)
  • npm run clean: remove dist/

Publicacao no npm

npm login
npm publish --access public