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

@toxfim/xsheets

v1.0.0

Published

A type-safe Node.js and TypeScript library for working with the Google Sheets API.

Readme

@toxfim/xsheets

Type-safe Google Sheets access for Node.js and TypeScript.

@toxfim/xsheets is a small developer library that wraps the Google Sheets Spreadsheet API with a clean Spreadsheet class, strong TypeScript types, and a simple structure that is ready to publish to npm.

Features

  • Simple Spreadsheet class API
  • Works in JavaScript and TypeScript projects
  • Service account authentication
  • Dual package output for ESM and CommonJS
  • Strong public type definitions
  • Small internal architecture with clear separation of concerns
  • Tests for helpers and core data-shaping utilities

Installation

npm install @toxfim/xsheets

Requirements

  • Node.js 18 or later
  • A Google Cloud service account with access to the target spreadsheet
  • The Google Sheets API enabled for your Google Cloud project

Quick Start

import { Spreadsheet } from "@toxfim/xsheets";

const sheet = new Spreadsheet(
  process.env.GOOGLE_CLIENT_EMAIL!,
  process.env.GOOGLE_PRIVATE_KEY!,
);

const rows = await sheet.getValues({
  spreadsheetId: process.env.GOOGLE_SPREADSHEET_ID!,
  sheetName: "Users",
});

console.log(rows);

You can also import a Google service-account JSON file directly:

import { Spreadsheet } from "@toxfim/xsheets";
import credentials from "./credentials.json";

const sheet = new Spreadsheet(credentials);

Usage Examples

Read values

const values = await sheet.getValues({
  spreadsheetId: "your-spreadsheet-id",
  sheetName: "Users",
  range: "A1:C10",
});

Set values

await sheet.setValues({
  spreadsheetId: "your-spreadsheet-id",
  sheetName: "Users",
  range: "A1:B3",
  values: [
    ["name", "active"],
    ["Ada", true],
    ["Grace", false],
  ],
});

Clear values

await sheet.clear({
  spreadsheetId: "your-spreadsheet-id",
  sheetName: "Users",
  range: "A2:B100",
});

Append values

await sheet.append({
  spreadsheetId: "your-spreadsheet-id",
  sheetName: "Users",
  values: [["Linus", true]],
});

Create and delete sheets

await sheet.createSheet({
  spreadsheetId: "your-spreadsheet-id",
  name: "Archive",
});

await sheet.deleteSheet({
  spreadsheetId: "your-spreadsheet-id",
  name: "Archive",
});

API Overview

Constructor

new Spreadsheet(clientEmail: string, privateKey: string)
new Spreadsheet(
  credentials:
    | { clientEmail: string; privateKey: string }
    | { client_email: string; private_key: string }
)

Methods

  • getValues(options)
  • setValues(options)
  • clear(options)
  • append(options)
  • createSheet(options)
  • deleteSheet(options)

Detailed API docs live in docs/API.md.

Error Handling Notes

The library exposes custom error classes:

  • GoogleSheetsError
  • SpreadsheetConfigurationError
  • SheetNotFoundError

These help distinguish configuration issues, missing sheets, and Google API failures.

Development Scripts

npm run dev
npm run lint
npm run test
npm run typecheck
npm run build

Build Instructions

npm install
npm run build

Build output is generated in dist/:

  • dist/index.js for ESM
  • dist/index.cjs for CommonJS
  • dist/index.d.ts for types

Publish Readiness Notes

  • package.json includes dual-package exports
  • Type declarations are generated during build
  • prepublishOnly runs lint, tests, and build
  • Only publishable files are included through the files field

Documentation