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

@stagewise/api-client

v2.1.0

Published

Public Node.js client for Stagewise API

Readme

@stagewise/api-client

A type-safe Node.js client for the Stagewise API, built with tRPC.

Installation

npm install @stagewise/api-client
# or
pnpm add @stagewise/api-client
# or
yarn add @stagewise/api-client

Usage

Basic Usage

import { createNodeApiClient } from '@stagewise/api-client';

const client = createNodeApiClient({
  baseUrl: 'https://v1.api.stagewise.io', // optional, defaults to this
  headers: {
    'x-access-key': 'your-api-key', // optional if using environment variable
  }
});

// Health check
const health = await client.health.query();
console.log(health);

Using Default Client

import { nodeApiClient } from '@stagewise/api-client';

// Uses default configuration
const result = await nodeApiClient.health.query();

Configuration

The client can be configured in several ways:

Environment Variables

API_URL=https://v1.api.stagewise.io
API_ACCESS_KEY=your-api-key

Constructor Options

import { createNodeApiClient } from '@stagewise/api-client';

const client = createNodeApiClient({
  baseUrl: 'http://localhost:3001', // Custom API URL
  headers: {
    'x-access-key': 'your-api-key',
    'custom-header': 'value'
  },
  fetch: customFetch // Custom fetch implementation
});

Agent Streaming

import { createNodeApiClient } from '@stagewise/api-client';

const client = createNodeApiClient();

const response = await client.agent.streamText.mutate({
  messages: [{ role: 'user', content: 'Hello!' }],
  model: 'gemini-2.0-flash-lite',
  tools: {}
});

// Handle streaming response
for await (const chunk of response) {
  console.log(chunk);
}

Types

All types are automatically inferred from the API router:

import type { 
  AppRouter, 
  RouterInputs, 
  RouterOutputs,
  TRPCClient 
} from '@stagewise/api-client';

// Input types for API calls
type HealthInput = RouterInputs['health'];

// Output types for API responses  
type HealthOutput = RouterOutputs['health'];

// Full client type
type Client = TRPCClient<AppRouter>;

Authentication

The client uses API keys for authentication. Set your API key either:

  1. As an environment variable: API_ACCESS_KEY=your-key
  2. In the client options: headers: { 'x-access-key': 'your-key' }

Error Handling

import { TRPCError } from '@trpc/client';

try {
  const result = await client.someEndpoint.query();
} catch (error) {
  if (error instanceof TRPCError) {
    console.error('tRPC Error:', error.code, error.message);
  } else {
    console.error('Network Error:', error);
  }
}

License

MIT