TypeScript SDK
Official client for the Wapedia public API (/v1): send messages, usage/subscription, media upload, and Meta webhook signature verification helpers.
Package: `@wapedia/sdk` (v0.1) — source in the wapedia-sdk repo.
Install
npm install github:rioaguspermana/wapedia-sdk
# atau
pnpm add github:rioaguspermana/wapedia-sdkUntil published to the npm registry, install from GitHub as above. Local link: pnpm add ../wapedia-sdk.
Send a text message
import { Wapedia } from "@wapedia/sdk";
const client = new Wapedia({
apiKey: process.env.WAPEDIA_API_KEY!,
});
const msg = await client.messages.sendText({
to: "6281234567890",
body: "Halo dari SDK",
phoneNumberId: "YOUR_PHONE_NUMBER_ID",
});
console.log(msg.id, msg.status); // 202 → queuedTemplates & media
await client.messages.sendTemplate({
to: "6281234567890",
phoneNumberId: "YOUR_PHONE_NUMBER_ID",
template: {
name: "hello_world",
language: "id",
},
});
const uploaded = await client.media.upload({
file: new Blob([buffer], { type: "image/jpeg" }),
mimeType: "image/jpeg",
filename: "foto.jpg",
});
await client.messages.send({
to: "6281234567890",
type: "image",
phoneNumberId: "YOUR_PHONE_NUMBER_ID",
media: { id: uploaded.media_id, caption: "Foto" },
});Wallet / usage
Wallet SDK methods still exist, but messaging W-Coin debit is off in the Tech Provider model (MESSAGING_WALLET_ENABLED=false). Use subscription/usage for fair-use quota:
const usage = await client.wallet.usage();
// balance / pricing / top-up: do not rely on these for message billing right nowVerify Meta signature
Matches the Wapedia backend (X-Hub-Signature-256):
import { verifyMetaSignature } from "@wapedia/sdk";
const ok = verifyMetaSignature(
req.headers["x-hub-signature-256"],
rawBody, // Buffer / Uint8Array / string mentah
process.env.META_APP_SECRET!,
);Forward events to your system
Payload POSTed to webhook_forward_url:
import { parseForwardEvent } from "@wapedia/sdk";
const event = parseForwardEvent(await req.json());
// event.event === "message.inbound"See also Webhooks.
Errors
HTTP failures throw WapediaError with status and body (usually { error: string }).
Full reference
Endpoints not yet wrapped as resources can be called via client.request(method, path, …). Machine-readable spec: OpenAPI.