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

@agentcash/sdk

v0.1.0

Published

TypeScript SDK for the AgentCash public API

Readme

AgentCash SDK

TypeScript bindings for the AgentCash public API, generated from its OpenAPI document and wrapped with a small runtime for authentication, errors, React Query, custom base URLs, and custom Fetch implementations.

Core client

Use an API key from trusted server-side code:

import { AgentCash } from "@agentcash/sdk";

const agentcash = new AgentCash({
  apiKey: process.env.AGENTCASH_API_KEY!,
});

const { wallets } = await agentcash.wallets.list();
const { balance, accounts } = await agentcash.balance.get();

OAuth access tokens with the API's agentcash:read scope are also supported. A credential callback is evaluated for every request, so it can refresh or retrieve the current token lazily:

const agentcash = new AgentCash({
  accessToken: () => getAccessToken(),
});

Request OAuth tokens for the https://api.agentcash.dev/v1 resource. Browser applications should use OAuth rather than embedding a long-lived API key.

Errors and custom transport options

Non-success responses throw AgentCashError, which exposes the HTTP status and parsed response body:

import { AgentCashError } from "@agentcash/sdk";

try {
  await agentcash.wallets.list();
} catch (error) {
  if (error instanceof AgentCashError) {
    console.error(error.status, error.body);
  }
}

The constructor also accepts baseUrl and fetch for alternate environments, tests, or runtimes with a custom Fetch implementation.

React Query

React integrations live behind the @agentcash/sdk/react export so core consumers do not need React or TanStack Query. Install React Query alongside the SDK and place AgentCashProvider beneath its QueryClientProvider:

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { AgentCash } from "@agentcash/sdk";
import { AgentCashProvider, useListWallets } from "@agentcash/sdk/react";
import { useMemo } from "react";

const queryClient = new QueryClient();

function Wallets() {
  const query = useListWallets();

  if (!query.data) return null;
  return <pre>{JSON.stringify(query.data.wallets, null, 2)}</pre>;
}

interface AppProps {
  getAccessToken: () => Promise<string>;
  userId: string;
}

function App({ getAccessToken, userId }: AppProps) {
  const agentcash = useMemo(
    () => new AgentCash({ accessToken: () => getAccessToken() }),
    [getAccessToken]
  );

  return (
    <QueryClientProvider client={queryClient}>
      <AgentCashProvider client={agentcash} cacheKey={userId}>
        <Wallets />
      </AgentCashProvider>
    </QueryClientProvider>
  );
}

cacheKey must be a stable identifier for the authenticated user or account. Changing it when the active account changes keeps cached API data isolated. The provider owns transport injection; there is no global SDK configuration.

Generated and handwritten code

  • src/generated contains Kubb output and is committed to git.
  • src/http.ts and src/client.ts provide authentication, transport, and the public core client.
  • src/react provides the side-effect-free React provider and hook adapters.
  • generators/provider-hook-generator.ts generates the public provider-aware hooks alongside Kubb's internal hooks.

Do not edit files under src/generated manually.

Regeneration

From the repository root, run:

pnpm api:generate

Turbo first regenerates apps/web/openapi/v1.json from the Hono API and then runs Kubb for @agentcash/sdk. Review and commit both the OpenAPI and generated SDK diffs.

Public class-client method aliases such as wallets.list() are configured in the clientMethodNames map in kubb.config.ts. Keep OpenAPI operation IDs descriptive and globally unique; React hooks and models intentionally retain names such as useListWallets and ListWalletsQueryResponse.

Validation

pnpm --filter @agentcash/sdk test
pnpm --filter @agentcash/sdk build
pnpm check