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

treasurydirect

v1.1.0

Published

Typed, zero-dependency client for the US Treasury's free public APIs — auction results, upcoming auctions, security lookups by CUSIP, and Debt to the Penny. No API key required.

Readme

treasurydirect

Typed, zero-dependency client for the US Treasury's free public APIs at treasurydirect.gov — auction results, upcoming and announced auctions, security lookups by CUSIP, and Debt to the Penny. No API key required.

npm install treasurydirect

Why

The Treasury publishes remarkably rich data for free — every auction's high yield, bid-to-cover, price per 100, accrued interest, dealer allocations, plus the national debt to the literal penny — and npm had no client for it. If you're building a bond ladder tool, a rates dashboard, or a debt-ceiling story, this is the data source.

import { auctionedSecurities, currentDebt, dateOnly, getSecurity, num } from "treasurydirect";

const notes = await auctionedSecurities({ type: "Note", days: 30 });
num(notes[0].highYield);       // 4.58
num(notes[0].bidToCoverRatio); // 2.59

const note = await getSecurity("91282CQQ7", "2026-07-15");
num(note.accruedInterestPer1000); // 7.25204
dateOnly(note.maturityDate);      // "2036-05-15"

const debt = await currentDebt();
debt.totalDebt; // 39_414_179_016_130.09

API

All functions take an optional final options argument: { fetch?, baseUrl?, timeoutMs?, signal? } (inject fetch for tests/proxies; timeoutMs/signal abort the request — no timeout by default).

  • auctionedSecurities({ type?, days?, pagesize?, pagenum? }) — recent auction results, newest first. type: "Bill" | "Note" | "Bond" | "CMB" | "TIPS" | "FRN"; days: look-back window in calendar days. With neither days nor pagesize, the API returns its latest 250 records.
  • upcomingAuctions() — scheduled auctions.
  • announcedSecurities({ type?, days?, pagesize?, pagenum? }) — announced auction terms.
  • getSecurity(cusip, issueDate) — one security; issueDate as "YYYY-MM-DD" or Date (UTC calendar date). No match throws TreasuryDirectError with status: 404 (the API itself replies HTTP 200 with the text No data).
  • searchSecurities(params) — pass-through search, e.g. { cusip } returns the original issue and every reopening. Typed params: cusip, type, reopening, dateFieldName + startDate/endDate, pagesize/pagenum (0-based; pagenum defaults to 0 because the API ignores pagesize alone). A broad search with no pagesize is large — every Bill ever is ~28 MB.
  • currentDebt() / searchDebt({ startDate, endDate }) — Debt to the Penny, latest or historical (newest first, business days only, data from 1993-01-04). Each entry gets a date ("YYYY-MM-DD") parsed from the published effectiveDate ("July 9, 2026 EDT"). publicDebt and governmentHoldings are null before 2005-03-31, when only the total was published.
  • num(field) — the TA_WS API returns every security field as a string ("" = not applicable); num converts to number | null.
  • dateOnly(field) — "2026-07-15T00:00:00" → "2026-07-15" (null if empty).
  • yesNo(field) — "Yes"/"No" flags (reopening, floatingRate, callable, …) → true/false (null if empty).

Failures throw TreasuryDirectError with status and url — for non-2xx responses (an unknown type is an HTTP 400) and for bodies that aren't JSON. Invalid arguments (bad CUSIP, impossible dates, reversed ranges, negative days) throw RangeError before any request. Security records are typed for the ~30 most useful fields with an index signature for the rest.

The mocked test suite runs offline; npm run smoke exercises the live API.

Related

Part of a small fixed-income toolkit: 32nds (format those auction prices as Treasury quotes) · accrued-interest (reproduce accruedInterestPer1000 yourself) · day-count · sifma-holidays (bond-market calendar).

Author

Built by Moshe Malka — engineering leader in New York City. Studio work at Quentin.Code.

MIT © Moshe Malka