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

klawsearch

v0.1.0

Published

JavaScript/TypeScript SDK for KlawSearch — AI-native search API for agents

Readme

klawsearch

JavaScript / TypeScript SDK for KlawSearch — a search API built for AI agents: one call returns ranked, cleaned results plus a grounded, source-cited answer.

npm install klawsearch

Get a free API key at klawsearch.com — 1,000 requests/month, no card required.

  • Zero dependencies — uses the runtime's native fetch
  • Fully typed — TypeScript definitions included
  • ESM + CommonJSimport and require both work
  • Runs on Node 18+, Deno, Bun, Cloudflare Workers, and browsers

Quick start

import { KlawSearch } from "klawsearch";

const klaw = new KlawSearch("ks-live-..."); // or set KLAWSEARCH_API_KEY

const r = await klaw.search("latest LLM agent benchmarks", { maxResults: 5 });

console.log(r.answer);
for (const hit of r.results) {
  console.log(hit.score, hit.url, hit.title);
}

CommonJS works too:

const { KlawSearch } = require("klawsearch");

SEC / EDGAR filings

Financial filings the general-purpose search APIs don't index:

const r = await klaw.searchFilings("AAPL supply chain risk factors", {
  ticker: "AAPL",
  formTypes: ["10-K"],
  maxResults: 5,
});

for (const f of r.results) {
  console.log(f.form_type, f.filing_date, f.company_name, f.url);
}

Extract page content

const r = await klaw.extract(["https://example.com/article"]);
console.log(r.results[0]?.content); // cleaned, LLM-ready text

Options

await klaw.search("query", {
  maxResults: 5,               // default 5
  searchDepth: "advanced",     // "basic" | "advanced"
  includeDomains: ["arxiv.org"],
  excludeDomains: ["pinterest.com"],
  includeAnswer: true,         // synthesized answer, default true
  includeRawContent: false,    // full page text per result
});

Errors

Typed error classes let you handle each failure mode precisely:

import {
  KlawSearch,
  AuthError,
  QuotaExceededError,
  RateLimitError,
} from "klawsearch";

try {
  await klaw.search("...");
} catch (err) {
  if (err instanceof QuotaExceededError) {
    // monthly quota used up — upgrade the plan
  } else if (err instanceof RateLimitError) {
    // per-minute burst — back off and retry
  } else if (err instanceof AuthError) {
    // bad or missing key
  }
}

Every error carries statusCode. The hierarchy is KlawSearchErrorAuthError (401), QuotaExceededError / RateLimitError (429), ServerError (5xx).

Configuration

| Option | Default | Notes | |---|---|---| | apiKey (1st arg) | KLAWSEARCH_API_KEY env var | required | | baseUrl | https://api.klawsearch.com | or KLAWSEARCH_BASE_URL | | timeout | 60000 ms | per request | | fetch | global fetch | inject your own for tests/proxies |

Self-hosting KlawSearch? Point baseUrl at your own instance:

const klaw = new KlawSearch("...", { baseUrl: "https://klaw.your-domain.com" });

Also available

MIT licensed.