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

tatua-sdk

v1.1.0

Published

Listen to M-Pesa payments without Daraja credentials. Just your till or paybill number.

Readme

Tatua SDK

Listen to M-Pesa payments without Daraja credentials. Just give us your till or paybill number.

Installation

npm install tatua-sdk

Quick Start

import { TatuaClient } from 'tatua-sdk';

const tatua = new TatuaClient({
  apiKey: 'tatua_your_api_key_here',
});

// List your recent payments
const { data, pagination } = await tatua.transactions.list({ limit: 20 });

data.forEach(txn => {
  console.log(`KES ${txn.amount} from ${txn.phone} — ref: ${txn.billRef}`);
});

// Get a specific payment by M-Pesa TransID
const txn = await tatua.transactions.get('OEI2AK4Q16');
console.log(txn.customer.firstName, txn.amount);

// Get your business profile
const profile = await tatua.getProfile();
console.log(profile.name, profile.shortcode);

Listening to Payments (Webhooks)

If you want real-time notifications when a payment arrives, register a webhookUrl when signing up with Tatua. We will POST the following JSON to your URL immediately after each payment:

{
  "event": "payment.received",
  "transId": "OEI2AK4Q16",
  "shortcode": "123456",
  "phone": "254712345678",
  "amount": 1500,
  "billRef": "INV-001",
  "firstName": "John",
  "middleName": null,
  "lastName": "Doe",
  "transactionType": "Pay Bill",
  "timestamp": "2024-04-26T10:30:00.000Z"
}

Express webhook handler

import express from 'express';
import { parseWebhookPayload } from 'tatua-sdk';

const app = express();
app.use(express.json());

app.post('/payments/webhook', (req, res) => {
  // Always respond 200 immediately — process async
  res.sendStatus(200);

  const payment = parseWebhookPayload(req.body);
  if (!payment) return;

  console.log(`New payment: KES ${payment.amount} from ${payment.phone}`);
  // Save to your DB, send WhatsApp alert, etc.
});

app.listen(4000);

Fastify webhook handler

import Fastify from 'fastify';
import { parseWebhookPayload } from 'tatua-sdk';

const fastify = Fastify();

fastify.post('/payments/webhook', async (req, reply) => {
  reply.code(200).send(); // respond immediately

  const payment = parseWebhookPayload(req.body);
  if (!payment) return;

  console.log(`KES ${payment.amount} from ${payment.phone}`);
});

fastify.listen({ port: 4000 });

API Reference

TatuaClient

const tatua = new TatuaClient({
  apiKey: string,       // required — from Tatua dashboard
  gatewayUrl?: string,  // optional — defaults to https://gateway.tatua.co.ke
});

tatua.transactions.list(options?)

| Option | Type | Default | Description | |----------|----------|---------|--------------------------------------| | limit | number | 50 | Results per page (max 200) | | offset | number | 0 | Pagination offset | | from | string | — | ISO date string filter start | | to | string | — | ISO date string filter end |

Returns { data: TatuaTransaction[], pagination: { total, limit, offset, hasMore } }

tatua.transactions.get(transId)

Get a single transaction by its M-Pesa TransID (e.g. "OEI2AK4Q16").

tatua.getProfile()

Returns your business profile: { id, name, shortcode, shortcodeType, createdAt }.

parseWebhookPayload(body)

Validates and parses an incoming webhook body. Returns TatuaWebhookPayload | null.

Types

interface TatuaTransaction {
  id: string;
  transId: string;        // M-Pesa TransID
  shortcode: string;
  phone: string;          // 254XXXXXXXXX
  amount: number;         // KES
  billRef: string | null; // account ref customer typed
  customer: {
    firstName: string;
    middleName: string | null;
    lastName: string;
  };
  transactionType: string;
  orgBalance: string | null;
  webhookDelivered: boolean;
  timestamp: string;      // ISO 8601
}