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

@ziffr/feed-kit

v0.14.0

Published

Write a Ziffr Feed: bring values from a CRM, a data warehouse or any other system into Ziffr Metrics, on a schedule.

Readme

@ziffr/feed-kit

Write a Ziffr Feed: a program that brings values for some Metrics from another system (a CRM, a data warehouse, a help desk) into Ziffr on a schedule. You say how to fetch one period's value; the kit asks Ziffr which periods are current or still missing, fetches them, and records them. MIT licensed, Node 20 or later. Publish your Feed however you like: free, paid or closed.

A first Feed

  1. In Ziffr, an Owner or Admin opens Settings, Feeds, creates a Feed and a Feed Key for it, and copies the key (shown once).
  2. On each Metric the Feed should fill, its owner opens Settings, "Who submits", and adds the Feed.
  3. Write the Feed:
npm install @ziffr/feed-kit
// crm.feed.mjs
import { defineFeed } from "@ziffr/feed-kit";

export default defineFeed({
  name: "CRM",
  metrics: {
    // The Metric's slug, as Ziffr shows it in the Metric's address.
    "deals-won": {
      // period: the period's first day (YYYY-MM-DD); periodEnd: the day after its last; current: still running.
      fetch: async ({ period, periodEnd }) => {
        const res = await fetch(`https://crm.example.com/api/deals?won_from=${period}&won_to=${periodEnd}`, { headers: { authorization: `Bearer ${process.env.CRM_TOKEN}` } });
        const deals = await res.json();
        // A number, { value, breakdown: [{ label, value }] }, or null when there is no value yet.
        return { value: deals.length, breakdown: countBy(deals, "region") };
      },
    },
  },
});
  1. Run it, from cron, a GitHub Action, a container or anywhere else:
export ZIFFR_URL=https://ziffr.example.com ZIFFR_FEED_KEY=zk_...
npx ziffr-feed run crm.feed.mjs --dry-run       # shows what it would send
npx ziffr-feed run crm.feed.mjs --backfill 24   # also fills the 24 periods before this one where they are empty

What a run does

  • It fetches the current period of each Metric every time, since its value may still change, and each earlier period that is still empty, up to --backfill N periods back. Ziffr says which period is current, so the Feed fetches the periods Ziffr counts wherever it runs.
  • Quarterly and yearly Metrics get one fetch per quarter or year, from its first day to the day after its last. Quarters and years start from the workspace's year start, which GET /feed names as year_start_month; periodStart(day, period, yearStartMonth) gives the period a day falls in.
  • It keeps no state. The periods Ziffr already has are the state, so you can run it as often as you like.
  • It records nothing twice. Each batch carries an idempotency key made from the Feed and its values, so a repeated run with the same values replays Ziffr's first answer.
  • Imports skip the Unusual Value check. A value for a past period that had none is an Import: Ziffr records it without asking for Approval and marks it as imported. The current period is checked as usual.
  • One failure stops nothing else. A fetch that throws is reported and the rest are sent. The command exits with 1 when a fetch failed or Ziffr refused a value, so your scheduler notices.
  • Your secrets stay with you. Only values and Breakdowns go to Ziffr. Keep the other system's credentials in the environment where the Feed runs.

From code

import { runFeed, summary } from "@ziffr/feed-kit";
import feed from "./crm.feed.mjs";

const report = await runFeed(feed, { backfill: 3, log: console.error });
console.log(summary(report)); // "CRM: sent 4 values: 1 recorded, 3 imported, 0 awaiting Approval, 0 locked, 0 refused."

The report lists the items sent, Ziffr's result for each, the periods that had no value yet, failed fetches, and slugs Ziffr does not list for the Feed: either the Feed is not a Submitter of that Metric yet, or its API Source is off.

Limits

A Feed may make about 60 calls a minute and record 10,000 values a day, counted over all its keys. The runner sends at most 500 values per call and waits out a 429.

More, including n8n and the SQL Feed: Feeds guide.