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

@common-grants/sdk

v0.4.1

Published

The CommonGrants protocol TypeScript SDK

Downloads

262

Readme

@common-grants/sdk

The CommonGrants protocol TypeScript SDK.

Table of contents

Installation

npm install @common-grants/sdk

Usage

Quick start

import { Client, Auth } from "@common-grants/sdk/client";

// 1. Create a client
const client = new Client({
  baseUrl: "https://api.example.org",
  auth: Auth.apiKey("your-api-key"),
});

// 2. Fetch opportunities
const opportunities = await client.opportunities.list();
for (const opp of opportunities.items) {
  console.log(`${opp.title} (${opp.status.value})`);
}

Kitchen sink example

This example shows how the SDK's modules work together: fetching data with the client, validating it with schemas, using type-safe constants, and accessing typed custom fields via a plugin.

import { Client, Auth } from "@common-grants/sdk/client";
import { OpportunityBaseSchema } from "@common-grants/sdk/schemas";
import type { OpportunityBase } from "@common-grants/sdk/types";
import { OppStatusOptions } from "@common-grants/sdk/constants";
import { definePlugin } from "@common-grants/sdk/extensions";

// Define a plugin with typed custom fields
const myPlugin = definePlugin({
  extensions: {
    Opportunity: {
      category: { fieldType: "string", description: "Grant category" },
      legacyId: { fieldType: "integer", description: "Legacy system ID" },
    },
  },
} as const);

// Create a client
const client = new Client({
  baseUrl: "https://api.example.org",
  auth: Auth.bearer("your-jwt-token"),
});

// Fetch opportunities with typed custom fields
const results = await client.opportunities.search({
  query: "education",
  statuses: [OppStatusOptions.open],
  schema: myPlugin.schemas.Opportunity,
});

for (const opp of results.items) {
  console.log(`${opp.title} (${opp.status.value})`);

  // Custom fields are fully typed
  console.log(`  Category: ${opp.customFields?.category?.value}`);
  console.log(`  Legacy ID: ${opp.customFields?.legacyId?.value}`);
}

// Validate standalone JSON data
const rawJson = await fetch("https://api.example.org/data.json").then(r => r.json());
const validated: OpportunityBase = OpportunityBaseSchema.parse(rawJson);

Modules

The SDK is organized into modules, each available as a separate import path:

| Module | Import path | Description | | ---------------------------------------------- | ------------------------------- | --------------------------------------------- | | Client | @common-grants/sdk/client | HTTP client with auth, pagination, and search | | Schemas | @common-grants/sdk/schemas | Zod schemas for data validation | | Types | @common-grants/sdk/types | Inferred TypeScript types | | Constants | @common-grants/sdk/constants | Runtime enum constants | | Extensions | @common-grants/sdk/extensions | Custom field and plugin framework |

API Client

HTTP client with built-in authentication, auto-pagination, and environment variable configuration. See the Client guide for setup, authentication, and usage examples. For runnable scripts, see list-opportunities.ts, get-opportunity.ts, and search-opportunities.ts.

Schemas and Validation

Zod schemas for validating and parsing CommonGrants data, along with inferred TypeScript types (@common-grants/sdk/types) and runtime enum constants (@common-grants/sdk/constants). See the Schemas guide for validation examples, type safety patterns, and the full API reference.

Extensions and Plugins

Extension framework for adding typed custom fields to CommonGrants schemas, either ad hoc or as reusable plugins. See the Extensions guide for the full guide. For runnable scripts, see custom-fields.ts and plugins.ts.

License

CC0-1.0