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

@homelotto168/lotto-agent-sdk

v0.1.0

Published

Node SDK for the Home168 Lotto Feed API — pull winning numbers & blocked numbers, report sales, verify webhooks.

Readme

@homelotto168/lotto-agent-sdk

Node client for the Home168 Lotto Feed API. Pull Khong's winning numbers and blocked numbers, report your sales, verify webhook signatures.

Requires Node 18+.

Install

npm i @homelotto168/lotto-agent-sdk

Quick start

import { LottoAgent } from '@homelotto168/lotto-agent-sdk';

const agent = new LottoAgent({ apiKey: process.env.LOTTO_API_KEY! });

// Sanity-check your key
const me = await agent.ping();
console.log('allowed templates:', me.allowed_templates);

// Pull winning numbers for a template
const results = await agent.results({ template: 'khong-gov', from: '2026-04-01' });
for (const r of results.results) {
  console.log(r.close, r.top, r.bottom);
}

// Pull blocked numbers
const blocked = await agent.blocked({ template: 'khong-gov' });
console.log('ignore_2:', blocked.ignore_2);

// Report your sales for one round (idempotent on round_date + round_seq)
await agent.reportSale({
  templateSlug: 'khong-gov',
  roundDate: '2026-04-22',
  roundSeq: 1,
  handle: 125_000,
  payout: 82_500,
  betCount: 147,
  agentRoundId: 'my-round-abc',
});

Webhook signatures

When we push you an event (result.announced, blocked.updated), we sign the body with your webhook secret using HMAC-SHA256. Verify on the receiving side:

import express from 'express';
import { LottoAgent } from '@homelotto168/lotto-agent-sdk';

app.post('/webhooks/home168', express.text({ type: '*/*' }), (req, res) => {
  const ok = LottoAgent.verifyWebhook(
    req.body,                          // raw string body
    req.headers['x-h168-signature'] as string,
    process.env.H168_WEBHOOK_SECRET!,
  );
  if (!ok) return res.status(401).end();

  const payload = JSON.parse(req.body);
  // payload.event, payload.timestamp, payload.data
  res.status(204).end();
});

Retries, timeouts, errors

The client retries 429 and 5xx responses up to maxRetries (default 3) with exponential backoff. 4xx responses are thrown as LottoApiError:

import { LottoApiError } from '@homelotto168/lotto-agent-sdk';

try {
  await agent.reportSale(/* ... */);
} catch (err) {
  if (err instanceof LottoApiError && err.status === 409) {
    // Round already reported with different values. Contact admin for adjustment.
  }
  throw err;
}

Sandbox mode

Ask your Home168 rep to flag your agent account as sandbox_mode. Rollups you post are accepted but excluded from weekly billing. Flip to live when you're confident.