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

@ufotech/rpc-ts-sdk

v1.0.4

Published

TypeScript interface generator from open-rpc documentations

Readme

@ufo-tech/rpc-ts-sdk

A CLI and library to generate TypeScript interfaces from an OpenRPC JSON schema file or URL.


Features

  • Converts OpenRPC components.schemas into TypeScript interfaces.
  • Handles enum, oneOf, type: [...], arrays, references, and nested objects.
  • Supports input as a local file or URL (via --input).
  • Output path and file name are fully configurable.
  • Always generates a base interface for RPC error handling.
  • Can be used globally via CLI or as a programmatic import in your project.

Installation

npm install -g @ufotech/rpc-ts-sdk

CLI Usage

rpc-ts-sdk-gen -i <path-or-url-to-openrpc.json> -o <path-to-schemas.ts>

Arguments:

  • -i, --input Path or URL to the OpenRPC JSON file. If not provided, defaults to openrpc.json in your current directory.

  • -o, --out Path and file name for the generated TypeScript interfaces file. If not provided, defaults to schemas.ts in your current directory.

Examples

From local file:

rpc-ts-sdk-gen -i ./openrpc.json -o ./types/openrpc-interfaces.ts

From URL:

rpc-ts-sdk-gen --input https://example.com/openrpc.json --out ./src/api/interfaces.ts

Default usage (with defaults):

rpc-ts-sdk-gen

Generated Output

  • TypeScript interfaces for every schema in components.schemas

  • Accurate support for union types, enums, nullable fields, arrays, and object nesting.

  • Always includes a basic error interface:

    export interface RpcError {
      code: number;
      message: string;
      data?: any;
    }

Library (Programmatic) Usage

You can use the generator as a library in your own Node/TypeScript project:

import { generateSchemas } from '@ufo-tech/rpc-ts-sdk';

await generateSchemas({
  input: './openrpc.json', // Can also be a URL
  output: './types/schemas.ts'
});

How it works

  1. Parses the OpenRPC JSON schema from a file or URL.

  2. Processes all entries in components.schemas to generate accurate TypeScript interfaces.

  3. Handles advanced OpenRPC/JSON Schema features:

    • enum → union types
    • oneOf, anyOf → TypeScript unions
    • Arrays, nested objects, references ($ref)
    • null/nullable fields
  4. Removes duplicate union types (number | numbernumber).

  5. Appends a base error interface for use in RPC error handling.


When to use

  • Backend/Frontend fullstack teams who want strongly-typed contracts with OpenRPC-compatible APIs.
  • Rapid TypeScript DTO/model generation from OpenRPC/OpenAPI/JSON-schema-like contracts.
  • Automated SDK/type updates when your OpenRPC spec changes.

Best Practices & Recommendations

  • Keep your OpenRPC schema up to date with your backend API.
  • Generate interfaces as part of your build or deploy process for always up-to-date types.
  • Consider ignoring the generated file in git if it’s auto-generated (schemas.ts).

License

MIT


Troubleshooting

  • Error: No components.schemas found! Ensure your OpenRPC JSON has a valid components.schemas section.

  • Error: Cannot find module or "file not found" Double-check your -i/--input and -o/--out paths.

  • Want to contribute? Fork the repo, submit a pull request, or open an issue for bugs and feature requests!


Links


Questions or feedback? Create an issue on GitHub or contact the UFO Tech team.