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

rayon-sdk-js

v2.1.0

Published

Server-side JavaScript and TypeScript client for Rayon API

Readme

Rayon JavaScript / TypeScript SDK

Rayon manages current material for supported public sources. Send the source-page URL, profile and exact request. No script collection or preparation is needed for this header flow. Replace the reserved example URLs with your approved source and endpoint. {} uses default profile values; supply measured values when needed.

Keep the API key server-side. Your integration owns the target HTTP client, authentication, cookies and session. Rayon generates telemetry; your client sends the target request.

Quickstart · Material options · API reference

Install

Requires Node.js 20.18.1+. ESM, CommonJS and TypeScript are included.

npm install rayon-sdk-js@^2.1.0

Generate

import { RayonClient } from 'rayon-sdk-js';

const apiKey = process.env.RAYON_API_KEY;
if (!apiKey) throw new Error('Set RAYON_API_KEY');
const client = new RayonClient(apiKey);
try {
  const result = await client.generate({
    source_url: 'https://shop.example.com/account',
    profile: {},
    request: {
      url: 'https://shop.example.com/api/check', method: 'POST',
      content_type: 'application/json', body: '{}',
    },
  });
  if (result.fallback_reason) {
    console.warn('A fallback was used. Contact support with request ID:', result.request_id);
  }
  // Apply result.headers with your target client. Keep client open for further calls.
} finally {
  await client.close();
}

Apply every returned header unchanged, including optional a0, to the exact request. Keep application headers and session state in your target client. Generate fresh telemetry for each request and inspect the target response to check acceptance. Rayon returns no target cookies.

Fallback reporting

When fallback_reason is present and non-null, a fallback was used. Contact support with request_id about the mapping issue. fallback_message provides safe guidance when available. Do not infer fallback from timing alone.

Results also expose optional path, material_reuse, discovery_state and discovery_duration_ms. Older responses can omit these fields.

Optional material and preparation

For an explicit override, supply either scripts (complete ordered sources) or material_ref (a private reference), never both. Omit the unused field; null and empty values are invalid. Customer uploads and references remain private to the API key. Automatic requests should keep both fields omitted on every call so new public material can be selected.

Form mode still requires explicit material. Set mode: "form", supply the exact URL-encoded POST application body before telemetry insertion, and prepend the returned form_body once. It contains telemetry only. Preserve duplicate fields and encoding. See form integration.

Preparation is optional for explicit material. It checks the supplied context before a workload; it is separate from managed selection and generation. Usable validated mappings can be ready without every internal record being mapped. Generated headers and form fields must still pass output validation.

// explicitShape includes scripts or material_ref and the current full context.
const ready = await client.prepareAndWait(explicitShape, { waitTimeoutMs: 60_000 });
const { scripts, material_ref, ...context } = explicitShape;
const result = await client.generate({ ...context, material_ref: ready.material_ref });

prepare, getPreparation(id, { wait: 0 }), waitUntilReady and prepareAndWait remain available. Waits default to 60 seconds; status long polls accept 0–10 seconds. Timeout or abort leaves the server job running. Resume with RayonError.preparationId. Terminal kinds are preparation_failed and preparation_expired. Readiness expires separately from the source reference; prepare current explicit context again when readiness expires or inputs change.

Client options and errors

Reuse one client for connections. usage() is a free access/allowance check. Default API URL: https://api.rayonapi.com; timeout: 45 seconds. Constructor options include baseUrl, timeoutMs and a caller-owned dispatcher. Pass { signal } to cancel a call. CommonJS: const { RayonClient } = require('rayon-sdk-js'). Use validate_profile for offline profile validation.

RayonError exposes kind, statusCode, requestId, code, retryAfter, reason, action, domain, field, billingStatus and retryable when available. Check request history before retrying a timeout or uncertain billing outcome. Only a definite uncharged material_expired receives one recovery attempt, and only while original explicit sources remain retained in that client. No other generation error is automatically retried.

Explicit-source caching retains up to 128 bundles / 16 MiB per client, coalesces uploads and refreshes near expiry. References last up to five minutes and may expire earlier. Automatic generation never pins a returned reference. The SDK does not fetch target scripts, send target requests or cache generated telemetry.

Errors · Release instructions · Support · MIT license