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

@rail402.dev/sdk

v0.1.2

Published

One install for Rail402 on Stellar: discover and pay x402 services (buyer), declare discoverable paid endpoints (seller), and the shared error registry — a thin umbrella over @rail402.dev/agent-helpers, seller-helpers and errors.

Downloads

456

Readme

@rail402.dev/sdk

The SDK for building x402 payments and discovery on Stellar. One install gives you both sides of the flow: a buyer/agent that can find and pay for Stellar services, and a seller that can make an endpoint paid and discoverable.

x402 turns an HTTP 402 response into a machine-payable flow: a client requests a resource, the server answers 402 with payment terms, the client signs a payment and retries, and a facilitator verifies and settles it on-chain before the resource is returned. On Stellar the buyer signs a Soroban authorization entry and the facilitator submits it and sponsors the network fee, so a payment costs a fraction of a cent and the buyer needs no XLM.

This package is a thin umbrella over three packages, re-exported verbatim (no extra behaviour, no private protocol):

| Re-exports | Role | |---|---| | @rail402.dev/agent-helpers | buyer: search the Bazaar, pay under a spend cap | | @rail402.dev/seller-helpers | seller: declare discovery metadata, preflight | | @rail402.dev/errors | the shared machine-readable error registry |

When to use it

  • You are an agent or app that pays for Stellar x402 services and want the discover then pay loop in a few lines, with a mandatory spend cap.
  • You are a seller who wants your paid endpoint to show up in the Bazaar so agents can find it with no prior integration.
  • You want one dependency to install and one place to import from. If you only need one side, install the individual package instead, or import the narrower entry point (see below).

What you need

  • Node.js 20+.
  • Testnet only. Every default in this SDK targets stellar:testnet.
  • To pay: a Stellar account secret seed (S...), funded, holding the payment asset with a trustline. On testnet, fund XLM from friendbot and get USDC from the Circle faucet. Keep the secret in an environment variable.
  • To only search: nothing but a Bazaar URL. Omit the secret.
  • A facilitator URL. Defaults to the hosted testnet facilitator at https://facilitator.rail402.dev; point it at your own by changing bazaarUrl.

Install

npm install @rail402.dev/sdk

Buyer: discover and pay

import { searchBazaar, payAndFetch, discoverAndPay } from "@rail402.dev/sdk";

const config = {
  bazaarUrl: "https://facilitator.rail402.dev", // the Bazaar is served at the facilitator's base URL
  stellarSecret: process.env.RAIL402_SECRET,    // omit for search-only
  network: "stellar:testnet",
};

// Search the Bazaar in natural language.
const found = await searchBazaar(config, "fx quote for a currency pair");
if (found.ok) console.log(found.data); // resources with price, asset and input schema

// Pay a known resource URL, under a required cap (atomic units, as a string).
const paid = await payAndFetch(config, "https://api.example.com/quote", {
  maxAmount: "100000", // 0.01 USDC at 7 decimals
});
if (paid.ok) console.log(paid.data.body); // the resource response, after settlement

// Or do both: discover the cheapest match and pay it, still capped.
const out = await discoverAndPay(config, "fx quote for a currency pair", { maxAmount: "100000" });
if (out.ok) console.log(out.data.body);

maxAmount is required and has no default. It is the ceiling for a single call, in the asset's atomic units as a string (7 decimals for USDC, so "100000" is 0.01). The cap is checked against the real paid quote, not only the unpaid probe.

Seller: make an endpoint discoverable

describeEndpoint builds the discovery metadata you attach to your x402 paywall route. The facilitator catalogs your endpoint, with these parameter descriptions, on the first settled payment. There is no separate registration step.

import { describeEndpoint } from "@rail402.dev/sdk";

const extensions = describeEndpoint({
  params: {
    base: { description: "Base currency or asset, such as XLM or BTC.", example: "XLM" },
    quote: { description: "Quote currency, such as USD.", required: false, example: "USD" },
  },
  outputExample: { base: "XLM", quote: "USD", price: 0.1234 },
});

// Attach `extensions` to your paywall route (here with @x402/hono):
//   "GET /quote": {
//     accepts: { scheme: "exact", network: "stellar:testnet", price: { amount: "100000", asset: "C..." }, payTo: "G..." },
//     description: "Live FX and crypto spot quote for a currency or asset pair.",
//     extensions,
//   }

Handling results

Buyer calls never throw a string. They return a Result you branch on:

type Result<T> =
  | { ok: true; data: T }
  | { ok: false; error: { code: string; reason: string; retryable: boolean } };

const paid = await payAndFetch(config, url, { maxAmount: "100000" });
if (!paid.ok) {
  console.error(paid.error.code, paid.error.reason, paid.error.retryable);
}

code is a stable identifier, reason is always a non-null sentence, and retryable tells an agent whether trying again could help. Codes come from @rail402.dev/errors.

Import only one role

Every symbol is on the package root. To pull in only one side, import a narrower entry point:

import { discoverAndPay }  from "@rail402.dev/sdk/buyer";   // = @rail402.dev/agent-helpers
import { describeEndpoint } from "@rail402.dev/sdk/seller";  // = @rail402.dev/seller-helpers
import { X402Error }        from "@rail402.dev/sdk/errors";  // = @rail402.dev/errors

Related packages

Testnet-first. Part of Rail402. Apache-2.0.