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

@eziocm/uazapi

v1.0.0

Published

TypeScript SDK for the UAZAPI WhatsApp API - instances, messages, contacts, groups, chats, webhooks, labels, campaigns, and AI chatbot

Readme

@eziocm/uazapi

TypeScript SDK completo para a API UAZAPI WhatsApp. Cobre todos os endpoints: instancias, mensagens, contatos, grupos, chats, webhooks, labels, campanhas e chatbot IA.

Instalacao

npm install @eziocm/uazapi

Quick Start

import { UazapiClient } from '@eziocm/uazapi'

const client = new UazapiClient({
  baseUrl: 'https://sua-instancia.uazapi.com',
  adminToken: 'seu-admin-token',
})

// Enviar mensagem de texto
await client.send.text('instance-token', {
  number: '5511999999999',
  text: 'Ola!',
})

// Verificar status da instancia
const status = await client.instance.getStatus('instance-token')

Configuracao

interface UazapiClientConfig {
  baseUrl: string                    // URL base da API (obrigatorio)
  adminToken?: string                // Token admin (header: admintoken)
  openaiApiKey?: string              // Chave OpenAI para transcricao
  timeout?: number                   // Timeout em ms (padrao: 30000)
  headers?: Record<string, string>   // Headers adicionais
}

Variaveis de Ambiente

O SDK usa estas variaveis como fallback quando nenhuma configuracao e fornecida:

| Variavel | Descricao | |----------|-----------| | UAZAPI_URL | URL base da API | | UAZAPI_ADMIN_TOKEN | Token de administrador | | OPENAI_API_KEY | Chave da API OpenAI |

// Usando variaveis de ambiente (sem config explicita)
import { uazapiClient } from '@eziocm/uazapi'

await uazapiClient.instance.getStatus('token')

Modulos

| Modulo | Descricao | |--------|-----------| | client.instance | Criar, conectar, status, presenca, perfil | | client.send | Texto, midia, contato, localizacao, interativos | | client.message | Download, transcricao, edicao, exclusao | | client.contact | Verificacao, listagem, bloqueio | | client.group | Criar, gerenciar participantes, convite | | client.chat | Listar, arquivar, fixar, silenciar | | client.webhook | Configurar, consultar, remover | | client.label | Listar, atribuir, editar etiquetas | | client.campaign | Envio em massa, controle de campanhas | | client.chatbot | Configuracao IA, agentes, base de conhecimento |

Exemplos

Gerenciamento de Instancias

// Listar todas as instancias (requer admin token)
const instances = await client.instance.listAll()

// Criar nova instancia
const newInstance = await client.instance.create({
  name: 'minha-instancia',
})

// Conectar instancia (gera QR Code)
const qr = await client.instance.connect('instance-token')

// Verificar status
const status = await client.instance.getStatus('instance-token')

Envio de Mensagens

// Texto
await client.send.text('token', {
  number: '5511999999999',
  text: 'Ola!',
})

// Imagem
await client.send.image('token', {
  number: '5511999999999',
  url: 'https://exemplo.com/foto.jpg',
  caption: 'Minha foto',
})

// Audio
await client.send.audio('token', {
  number: '5511999999999',
  url: 'https://exemplo.com/audio.mp3',
})

// Documento
await client.send.document('token', {
  number: '5511999999999',
  url: 'https://exemplo.com/doc.pdf',
  fileName: 'documento.pdf',
})

// Localizacao
await client.send.location('token', {
  number: '5511999999999',
  latitude: -23.5505,
  longitude: -46.6333,
  name: 'Sao Paulo',
})

// Enquete
await client.send.poll('token', {
  number: '5511999999999',
  name: 'Qual sua cor favorita?',
  options: [{ optionName: 'Azul' }, { optionName: 'Vermelho' }],
})

Contatos

// Verificar se numero tem WhatsApp
const check = await client.contact.checkNumber('token', {
  phone: '5511999999999',
})

// Bloquear contato
await client.contact.block('token', { number: '5511999999999' })

Grupos

// Criar grupo
const group = await client.group.create('token', {
  name: 'Meu Grupo',
  participants: ['5511999999999', '5511888888888'],
})

// Obter info do grupo
const info = await client.group.getInfo('token', { groupJid: 'grupo-id' })

Webhooks

// Configurar webhook
await client.webhook.set('token', {
  url: 'https://meusite.com/webhook',
  events: ['messages', 'connection'],
})

// Consultar webhook
const webhook = await client.webhook.get('token')

Campanhas

// Criar campanha
const campaign = await client.campaign.create('token', {
  name: 'Promocao',
  numbers: ['5511999999999'],
  message: 'Aproveite nossa oferta!',
})

// Pausar campanha
await client.campaign.pause('token', { campaignId: 'id' })

Chatbot IA

// Configurar chatbot
await client.chatbot.setConfig('token', { enabled: true })

// Criar agente
await client.chatbot.createAgent('token', {
  name: 'Assistente',
  instructions: 'Voce e um assistente de vendas.',
})

Tratamento de Erros

import { UazapiClient, UazapiError } from '@eziocm/uazapi'

try {
  await client.send.text('token', { number: '...', text: '...' })
} catch (error) {
  if (error instanceof UazapiError) {
    console.error('Status:', error.statusCode)  // 401, 404, etc.
    console.error('Path:', error.path)           // '/send/text'
    console.error('Method:', error.method)       // 'POST'
    console.error('Response:', error.response)   // corpo da resposta
  }
}

TypeScript

O SDK inclui tipagem completa para todos os endpoints:

import type {
  UazapiClientConfig,
  SendTextRequest,
  SendMessageResponse,
  InstanceData,
  WebhookPayload,
} from '@eziocm/uazapi'

Factory e Singleton

import { createUazapiClient, uazapiClient } from '@eziocm/uazapi'

// Singleton pre-configurado com variaveis de ambiente
await uazapiClient.send.text('token', { number: '...', text: '...' })

// Criar instancia customizada
const custom = createUazapiClient({
  baseUrl: 'https://outro.uazapi.com',
  timeout: 60000,
})

Licenca

MIT