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

@pagci/node

v0.1.1

Published

Official PAGCI Node.js SDK — PIX payments, withdrawals, refunds, and webhooks

Downloads

18

Readme

Documentação · Webhooks · Errors · Issues

      

npm install @pagci/node
import { Pagci } from '@pagci/node';

const pagci = new Pagci('sua_api_key');

const payment = await pagci.payments.create({
  owner: { wallet_id: 'wallet_main' },
  customer: { id: 'cust_1', document: '12345678900' },
  items: [{ name: 'Assinatura mensal', id: 'sub_1', value: 4990 }],
  recipients: [{ wallet_id: 'wallet_main', amount: 4990 }],
});

console.log(payment.liquidator.pix_qr); // PIX copia e cola

Todos os valores são number em centavos. 4990 = R$ 49,90.


Paginar resultados

for await (const p of pagci.payments.list({ status: 'confirmed' })) {
  console.log(p.id, p.pix_total);
}

// ou colete com limite
const batch = await pagci.payments.list().autoPagingToArray({ limit: 100 });

Saques

const w = await pagci.withdrawals.create({
  wallet_id: 'wallet_main',
  amount: 10000,
  pix_key: '[email protected]',
  pix_key_type: 'email',
});

Testar webhooks localmente

npx @pagci/node listen --port 3000
  ⚡ PAGCI  Webhook Listener
  ────────────────────────────────────────────────────
  Tunnel    https://xyz.trycloudflare.com
  Forward   http://localhost:3000
  Provider  cloudflared
  Status    ● Ready
  ────────────────────────────────────────────────────

  14:32:01  →  payment.confirmed       pay_01jx...  200  23ms
  14:32:05  →  withdrawal.settled      wdrl_01jx... 200  12ms

O SDK detecta automaticamente qual tunnel usar. Instale um:

1. localtunnel — mais fácil, só npm

npm install localtunnel

2. cloudflared — mais estável, sem conta

# macOS
brew install cloudflared

# Windows
choco install cloudflared

# Linux (Debian/Ubuntu)
sudo apt install cloudflared

3. ngrok — requer conta gratuita

# macOS
brew install ngrok

# Windows
choco install ngrok

# Linux
snap install ngrok

# Setup (uma vez)
ngrok config add-authtoken <seu_token>  # pegar em dashboard.ngrok.com

Use a URL do tunnel como overwrite_webhook_url ao criar pagamentos:

const session = await listen('sua_api_key', { port: 3000 });

await pagci.payments.create({
  // ...
  config: { overwrite_webhook_url: session.url },
});

Verificar assinatura de webhooks

app.post('/webhooks', express.raw({ type: 'application/json' }), (req, res) => {
  const event = pagci.webhooks.constructEvent(
    req.body.toString(),
    req.headers['x-webhook-signature'],
    'whsec_...',
  );

  if (event.payload.event === 'payment.confirmed') {
    const payment = event.payload.data;
    // payment é tipado como Payment
  }

  res.sendStatus(200);
});

payment.confirmed · payment.failed · payment.cancelled · payment.expired · withdrawal.settled · withdrawal.failed · refund.completed


Erros tipados

import { ValidationError, InsufficientBalanceError } from '@pagci/node';

try {
  await pagci.payments.create({ /* ... */ });
} catch (err) {
  if (err instanceof ValidationError) {
    console.log(err.code, err.field);
  }
}

AuthenticationError · ForbiddenError · NotFoundError · ValidationError · ConflictError · InsufficientBalanceError · RateLimitError · ApiError · ConnectionError · TimeoutError · SignatureVerificationError

Todos seguem RFC 9457type, title, status, code, detail, field.


Configuração

const pagci = new Pagci('sua_api_key', {
  maxRetries: 2,    // backoff exponencial + jitter
  timeout: 30_000,  // ms
});

Retry automático em erros de rede, 429 e 5xx. POST financeiro só faz retry com Idempotency-Key — gerada automaticamente em payments.create() e withdrawals.create().


Node.js 18+ · Zero dependências · 86 testes · TCP keep-alive

Documentação →