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

@goevery/whatsapp-cloud-api-client

v0.2.0

Published

A TypeScript client for WhatsApp Cloud API

Readme

WhatsApp Cloud API Client

npm version License: MIT

A TypeScript client for the WhatsApp Cloud API with full type safety using Zod schemas.

Features

  • 🔒 Type-safe - Built with TypeScript and Zod for runtime validation
  • 📦 Lightweight - Minimal dependencies (only Zod)
  • 🎯 Simple API - Intuitive and easy-to-use interface
  • 🔌 Flexible - Custom HTTP adapter support
  • Comprehensive - Supports messages, templates, media, and more
  • 📝 Well-typed - Full TypeScript definitions included

Installation

npm install @goevery/whatsapp-cloud-api-client
pnpm add @goevery/whatsapp-cloud-api-client
yarn add @goevery/whatsapp-cloud-api-client

Quick Start

import { WhatsAppClient, FetchWhatsAppHttpAdapter } from "@goevery/whatsapp-cloud-api-client";

// Initialize the client
const client = new WhatsAppClient(new FetchWhatsAppHttpAdapter());

// Send a text message
const response = await client.sendMessage({
  phoneNumberId: "YOUR_PHONE_NUMBER_ID",
  accessToken: "YOUR_ACCESS_TOKEN",
  payload: {
    messaging_product: "whatsapp",
    to: "1234567890",
    type: "text",
    text: {
      body: "Hello from WhatsApp Cloud API!",
    },
  },
});

console.log(response);

Usage

Sending Messages

Text Message

await client.sendMessage({
  phoneNumberId: "YOUR_PHONE_NUMBER_ID",
  accessToken: "YOUR_ACCESS_TOKEN",
  payload: {
    messaging_product: "whatsapp",
    to: "1234567890",
    type: "text",
    text: {
      body: "Hello World!",
      preview_url: false,
    },
  },
});

Image Message

await client.sendMessage({
  phoneNumberId: "YOUR_PHONE_NUMBER_ID",
  accessToken: "YOUR_ACCESS_TOKEN",
  payload: {
    messaging_product: "whatsapp",
    to: "1234567890",
    type: "image",
    image: {
      link: "https://example.com/image.jpg",
      caption: "Check out this image!",
    },
  },
});

Template Message

await client.sendMessage({
  phoneNumberId: "YOUR_PHONE_NUMBER_ID",
  accessToken: "YOUR_ACCESS_TOKEN",
  payload: {
    messaging_product: "whatsapp",
    to: "1234567890",
    type: "template",
    template: {
      name: "hello_world",
      language: {
        code: "en_US",
        policy: "deterministic",
      },
    },
  },
});

Managing Templates

List Templates

const templates = await client.listTemplates({
  wabaId: "YOUR_WABA_ID",
  accessToken: "YOUR_ACCESS_TOKEN",
  payload: {
    status: "APPROVED",
  },
});

Create Template

const template = await client.createTemplate({
  wabaId: "YOUR_WABA_ID",
  accessToken: "YOUR_ACCESS_TOKEN",
  payload: {
    name: "my_template",
    language: "en_US",
    category: "MARKETING",
    components: [
      {
        type: "BODY",
        text: "Hello {{1}}, welcome to our service!",
      },
    ],
  },
});

Delete Template

const result = await client.deleteTemplate({
  wabaId: "YOUR_WABA_ID",
  accessToken: "YOUR_ACCESS_TOKEN",
  payload: {
    name: "my_template",
  },
});

Media Operations

Upload Media

const file = new File(["content"], "image.jpg", { type: "image/jpeg" });

const media = await client.uploadMedia({
  phoneNumberId: "YOUR_PHONE_NUMBER_ID",
  accessToken: "YOUR_ACCESS_TOKEN",
  file: file,
  payload: {
    messaging_product: "whatsapp",
    type: "image",
  },
});

console.log(media.id); // Use this ID to send the media

Get Media URL

const mediaUrl = await client.getMediaUrl(
  "MEDIA_ID",
  "YOUR_ACCESS_TOKEN"
);

console.log(mediaUrl.url);

Download Media

const media = await client.downloadMedia(
  "https://lookaside.fbsbx.com/...",
  "YOUR_ACCESS_TOKEN"
);

// media.data is a ReadableStream<Uint8Array>
// media.contentType contains the MIME type

Schema Exports

All Zod schemas are exported and can be imported separately:

import {
  sendMessageRequestSchema,
  sendMessageResponseSchema,
  type SendMessageRequest,
  type SendMessageResponse,
} from "@goevery/whatsapp-cloud-api-client/schemas";

// Validate your own data
const validatedMessage = sendMessageRequestSchema.parse(messageData);

Development

# Install dependencies
pnpm install

# Build the project
pnpm build

# Run tests
pnpm test

# Type check
pnpm typecheck

# Lint
pnpm lint

Example

See the example directory for a complete working example.

# Set up environment variables
cp .env.example .env
# Edit .env with your credentials

# Run the example
pnpm --filter example dev

Requirements

  • Node.js 18 or higher
  • WhatsApp Business Account
  • WhatsApp Business App ID and Phone Number ID
  • Access Token from Meta Developer Platform

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Author

Juan Marín - @goevery

Links