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

wi-api

v0.1.2

Published

Official Node.js SDK for the wi-api WhatsApp platform

Readme

wi-api Node.js SDK

npm npm bundle size license

Node.js and TypeScript SDK for wi-api. Send and receive WhatsApp messages in a few lines of code.

Works on Node 18+, Bun, Deno, and Cloudflare Workers. No runtime dependencies.

Install

npm install wi-api
bun add wi-api
pnpm add wi-api

Quick start

import { Wi } from "wi-api"

const wi = new Wi({ apiKey: process.env.WI_API_KEY! })

const msg = await wi.session("my-instance").sendText({
  to: "5511999999999",
  text: "Hello from wi-api",
})

console.log(msg.messageId)

Sessions

const session = wi.session("my-instance")

// Start the connection flow
await session.connect()

// Poll for QR code (base64 PNG)
const { qr } = await session.qr()

// Or pair by phone number
const { pairCode } = await session.pairPhone("5511999999999")

// Check status
const { connected, phone } = await session.status()

await session.disconnect() // keeps session keys
await session.logout()     // removes session keys

Sending messages

// Text
await session.sendText({ to: "5511999999999", text: "Hello!" })

// Reply
await session.sendText({ to: "5511999999999", text: "Got it", quoted: messageId })

// Image
await session.sendImage({ to: "5511999999999", url: "https://example.com/photo.jpg", caption: "Look" })

// Voice note
await session.sendAudio({ to: "5511999999999", url: "https://example.com/audio.ogg", ptt: true })

// Document
await session.sendDocument({ to: "5511999999999", url: "https://example.com/file.pdf", filename: "report.pdf" })

// Location
await session.sendLocation({ to: "5511999999999", latitude: -23.5505, longitude: -46.6333 })

// Poll
await session.sendPoll({ to: "5511999999999", question: "Best stack?", options: ["Bun", "Node", "Deno"] })

// Reaction
await session.react({ to: "5511999999999", messageId, emoji: "" })

Webhooks

wi-api signs every webhook payload with x-wi-signature: sha256=<hex>.

import { createWebhookHandler } from "wi-api"

// Next.js App Router
export const POST = createWebhookHandler({
  secret: process.env.WI_WEBHOOK_SECRET!,
  async onMessage({ data }) {
    console.log(data.from, data.text)
  },
  async onConnected({ data }) {
    console.log("connected:", data.phone)
  },
})
// Hono / Elysia / any Web API runtime
const handler = createWebhookHandler({ secret: "...", onMessage: ... })
app.post("/webhook", (c) => handler(c.req.raw))

Verify manually:

import { verifyWebhookSignature, parseWebhookEvent } from "wi-api"

const valid = await verifyWebhookSignature(rawBody, req.headers["x-wi-signature"], secret)
if (!valid) return new Response(null, { status: 401 })

const event = parseWebhookEvent(rawBody)

Error handling

import { WiError } from "wi-api"

try {
  await session.sendText({ to: "5511999999999", text: "Hello" })
} catch (err) {
  if (err instanceof WiError) {
    console.error(err.status, err.message)
  }
}

Configuration

const wi = new Wi({
  apiKey:  process.env.WI_API_KEY!,
  baseUrl: "https://endpoint.wi.api.br", // default
  timeout: 30_000,                        // ms, default 30s
})

Resources