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

@capitoltrace/congress-api

v0.2.0

Published

Typed, zero-dependency TypeScript client for the Congress.gov API — bills, members, votes, and more.

Readme


Status: v0.2.0 — full endpoint coverage: bills, members, votes, committees, nominations, treaties, amendments, the Congressional Record, and congress sessions, all verified against the live API.


Why this exists

The Congress.gov API is powerful but raw — no official SDK, inconsistent response shapes, pagination quirks, and rate limiting that'll bite you. This client handles all of that so you can focus on building.

Quick start

import { Congress } from '@capitoltrace/congress-api';

const congress = new Congress({ apiKey: process.env.CONGRESS_API_KEY! });

// Get a bill
const bill = await congress.bill(118, 'hr', 1);
console.log(bill.title); // "Lower Energy Costs Act"

// Search members
for await (const member of congress.members.list({ state: 'CA' })) {
  console.log(member.name);
}

// House roll call votes
const vote = await congress.vote(119, 1, 17);
console.log(vote.result); // "Passed"

// How every member voted
const positions = await congress.votes.memberVotes(119, 1, 17);
console.log(positions.results?.length); // 434

// Auto-paginate — no manual offset management
for await (const bill of congress.bills.list({ congress: 118, billType: 'hr' })) {
  console.log(bill.title);
}

// Committees, nominations, treaties, amendments too
const committee = await congress.committee('house', 'hspw00');
for await (const b of congress.committees.bills('house', 'hspw00')) {
  console.log(`${b.type} ${b.number} — ${b.relationshipType}`);
}

const current = await congress.congresses.current();
console.log(current.name); // "119th Congress"

What you get

  • Full type safety — Every endpoint returns typed responses, no any
  • Auto-pagination — Async iterators follow pagination.next for you
  • Rate limit handling — Built-in retry with exponential backoff for 429s and 5xx, honors Retry-After — but fails fast with RateLimitError if the server asks you to wait longer than maxRetryDelayMs (api.data.gov sends Retry-After: 84868 when a daily quota runs out; sleeping a day inside a request helps no one)
  • Zero dependencies — Uses native fetch() (Node 18+, Deno, Bun, browsers)
  • Tree-shakeable — ESM + CJS dual build, sideEffects: false

Error handling

import { CongressApiError, RateLimitError } from '@capitoltrace/congress-api';

try {
  await congress.bill(118, 'hr', 999999);
} catch (err) {
  if (err instanceof RateLimitError) {
    console.log(`Rate limited — retry after ${err.retryAfterSeconds}s`);
  } else if (err instanceof CongressApiError) {
    console.log(`API error ${err.status}: ${err.message}`);
  }
}

Endpoints

| Resource | Methods | Status | |:---------|:--------|:-------| | 📜 Bills | list, get, actions, cosponsors, subjects, summaries, text, titles | ✅ v0.1 | | 👥 Members | list, get, sponsoredLegislation, cosponsoredLegislation | ✅ v0.1 | | 🗳️ Votes | list, get, memberVotes — House roll calls¹ | ✅ v0.1 | | 🏛️ Committees | list, get, bills, reports, nominations | ✅ v0.2 | | 📋 Nominations | list, get, actions, committees, hearings, nominees | ✅ v0.2 | | 🤝 Treaties | list, get, actions, committees | ✅ v0.2 | | ✏️ Amendments | list, get, actions, cosponsors, amendments, text | ✅ v0.2 | | 📰 Congressional Record | issues (classic), daily (modern) | ✅ v0.2 | | 📅 Congress | list, get, current | ✅ v0.2 |

¹ Via Congress.gov's beta house-vote endpoints. Senate roll call votes are not yet published by the Congress.gov API — they'll be added here the day upstream ships them.

Installation

# npm
npm install @capitoltrace/congress-api

# yarn
yarn add @capitoltrace/congress-api

# pnpm
pnpm add @capitoltrace/congress-api

Works in Deno and Supabase Edge Functions too:

import { Congress } from 'npm:@capitoltrace/congress-api';

Get your API key

Congress.gov API keys are freesign up here (takes 30 seconds).

Need enriched data?

This client gives you raw Congress.gov data with your own key. If you want cross-referenced intelligence — congressional stock trades, FEC filings, FARA registrations, AI-detected correlations, webhooks — that's the Capitol Trace API.

Contributing

This is an open-source project by Capitol Trace. PRs welcome — especially for:

  • Additional endpoint coverage (see the planned rows above)
  • Better TypeScript types from real API responses
  • Deno / Bun compatibility testing
  • Documentation improvements
npm install
npm test         # vitest, no API key needed — tests run against recorded fixtures
npm run build    # tsup → dist/

License

MIT