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

@x402-tools/sdk

v0.1.1

Published

Define a pay-per-call x402 service with a single handler. The platform injects the x402 paywall, validation, telemetry, and discovery.

Downloads

51

Readme

@x402-tools/sdk

Define a pay-per-call x402 service with a single handler. The x402tools platform takes your define() export, injects the x402 paywall, input validation, timeout enforcement, telemetry, and discovery (/.well-known/x402, /openapi.json, /health), then hosts it and settles USDC to your wallet.

Status: Slice 0 of the platform build (PRD §4.1 / §4.4). The author-facing define() API and the runtime wrapper are implemented and tested. The CLI, control-plane API, and managed deploy land in later slices.

Install

npm install @x402-tools/sdk

Define a service

import { define } from "@x402-tools/sdk";

export default define({
  name: "sentiment-analysis",            // kebab-case, globally unique
  description: "Analyze text sentiment (-1 to 1).",
  price: "$0.002",                        // USDC per call
  input: {
    text: { type: "string", required: true, maxLength: 5000 },
  },
  output: { type: "json" },
  async handler(input, ctx) {
    ctx.logger.info("scoring", { len: input.text.length });
    return { score: score(input.text) };
  },
});

handler(input, ctx) receives validated input (defaults applied) and a Context with fetch, env, logger, requestId, callerAddress, and a cache. Return a JSON-serializable value, a Buffer, or { body, contentType } for binary responses.

Run it locally

For local iteration, run your handler with the built-in dev server — no paywall, no payments, no platform dependencies (only express):

import { startDevServer } from "@x402-tools/sdk/dev";
import def from "./handler.js";

startDevServer(def, { port: 8787 }); // POST / with your input, /health, /openapi.json

This is what x402tools dev runs. On the platform, a generated wrapper calls the production runtime entry point instead:

import { serve } from "@x402-tools/sdk/runtime";
import def from "./handler.js";

serve(def);                 // paywall on, payTo from WALLET_ADDRESS

Subpath exports

  • @x402-tools/sdk — author API (define, validateInput, types). Zero server deps.
  • @x402-tools/sdk/devcreateDevServer() / startDevServer(). Express-only, no paywall. Safe for external developers to install and run.
  • @x402-tools/sdk/runtimeserve() / createServiceApp(). Builds the paywalled Express app on top of @x402-tools/core; used platform-side only (its dependencies are injected by the platform build, never pulled by npm install). Emits a usage event per call to ${USAGE_COLLECTOR_URL}/v1/ingest/usage (with USAGE_INGEST_TOKEN) for platform analytics; no-op when those are unset.

Deploy to the platform

Install the CLI and ship your handler — the platform builds it, hosts it behind the x402 paywall, and settles USDC to your wallet:

npm install -g @x402-tools/cli
x402tools init                 # or drop this handler.ts into a project
npm install
x402tools login <github-token>
npm run deploy                 # build + deploy
x402tools payout 0xYourWallet  # where your 70% revenue share is paid
x402tools status               # URL, calls, revenue, trust score

See @x402-tools/cli for the full command reference.

Develop & test

npm run build
npm test            # unit/e2e tests for define + runtime
npm run test:consumer  # packs the SDK and installs it as an external dev would,
                       # proving /dev works without @x402-tools/core