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

googlechat.js

v0.1.0

Published

Google Chat client for Node.js — spaces, DMs, threads, search, presence and real-time events with plain cookie auth (no browser extension). Includes incoming-webhook helpers.

Readme

googlechat.js

A Google Chat client for Node.js, in the spirit of youtubei.js: talk to the same internal endpoints the Chat web app uses — spaces, DMs, threads, search, unreads, presence, attachments and real-time events — from any ordinary project. You only need the cookies of a logged-in Google session. No browser extension, no headless browser, no local server.

Unofficial and not affiliated with Google. The endpoints are internal and can change without notice. Use an account you are willing to risk; automation may violate Google's terms.

npm install ./googlechat.js      # or: npm pack → npm install googlechat.js-0.1.0.tgz
npm run build                    # when installing from source

ESM, Node.js ≥ 20.3. From CommonJS: const { GoogleChat } = await import('googlechat.js').

Quick start

import { GoogleChat } from 'googlechat.js';

const chat = await GoogleChat.create({ cookie: process.env.GOOGLE_COOKIE });

const spaces = await chat.spaces.list();
const messages = await chat.messages.list(spaces[0].id, { limit: 20 });
await chat.messages.send(spaces[0].id, 'hello!');
await chat.messages.reply(spaces[0].id, messages[0].topic_id, 'in-thread reply');

Getting the cookies

  1. Sign in at https://chat.google.com in your browser.
  2. Export the cookies of google.com — any of these formats works as cookie:
    • the Cookie request header (DevTools → Network → any chat.google.com request → copy value),
    • a Cookie-Editor / EditThisCookie JSON export,
    • the contents of a Netscape cookies.txt,
    • a plain object { SID, HSID, SSID, OSID, … }.
  3. Required: SID, HSID, SSID (and OSID, which is set once you've opened chat.google.com).

Treat cookies like a password. Store them in an env var or secret manager, never in git.

Options

GoogleChat.create({
  cookie,                     // required
  cacheFile: '.gchat-auth.json', // persist the XSRF token between runs (or pass `store`)
  fetch: myFetch,             // custom fetch (proxy, retry, tests)
  userAgent, logLevel: 'warn',
  lazy: true,                 // don't authenticate until first call
});

If the session cookies expire you'll get Auth failed … cookies are invalid or expired; export fresh ones.

API

| | | |---|---| | chat.me | signed-in user | | chat.spaces.list() / get(id) / find(q) / items() | spaces + DMs, unread-aware sidebar | | chat.messages.list(id, {limit, since, until}) / topics(id) | message history (newest first) | | chat.messages.send(id, text) / reply(id, topicId, text) / sendImage(id, text, path, topicId?) | posting | | chat.threads.get(id, topicId) | full thread | | chat.dms.list() / get(dmId) / threads(dmId) | direct messages | | chat.search(query, options) | global search | | chat.unreads.summary() / badges() / markRead(id) / markUnread(id) / markThreadRead() / markAllRead() | read state | | chat.presence.get(userIds) / getOne(id) / dms() | presence | | chat.attachments.url(token) / download(token) | files & images | | chat.listen() | real-time events (below) | | chat.client | the low-level GoogleChatClient (every endpoint, raw results) |

since / until accept epoch ms or strings like "7d", "2h".

Real-time events

const live = await chat.listen();            // { subscribe: 'all' | [ids] | false, keepOnline: true }
live.on('message', (e) => console.log(e.groupId?.id, e.body?.message?.text));
live.on('typing', (e) => …);                 // also: readReceipt, userStatus, reaction,
live.on('error', (err) => …);                //       membershipChanged, groupUpdated, connect, disconnect
live.stop();

Incoming webhooks & Chat-app events (official API)

Separate from the cookie client; no login needed. Also importable as googlechat.js/webhook.

import { GoogleChatWebhook, cards, createChatEventHandler } from 'googlechat.js/webhook';

const hook = new GoogleChatWebhook(process.env.GCHAT_WEBHOOK_URL);
await hook.sendText('*Deploy finished* <users/all>');
await hook.reply('deploy-123', 'same thread');           // threadKey
await hook.sendCard(cards.card({ header: { title: 'Build' }, sections: [cards.section('Result', [cards.textParagraph('ok')])] }));

// receive messages in a Chat app HTTP endpoint (verifies Google's bearer JWT)
http.createServer(createChatEventHandler(async (e) => e.type === 'MESSAGE' ? `You said: ${e.message?.text}` : undefined,
  { verify: { audience: process.env.PROJECT_NUMBER } })).listen(8080);

Retries on 429/5xx, URL validation, auto-split of long text (sendLong), classic and Workspace-add-on payloads. For add-on endpoints verify with { audience: '<endpoint URL>', issuer: 'https://accounts.google.com', certsUrl: GOOGLE_JWKS_URL, email: '<service account>' }.

Notes

  • Dependencies: only protobufjs (loaded lazily when the first request is encoded).
  • Derived from the gchat CLI project; the Chrome-extension bridge, CLI and HTTP server were removed.
  • Image upload and a few endpoints were previously only reachable through the extension; they now use direct requests with your cookies and are the least battle-tested part.

Tests

npm test — cookie parsing, authentication/caching (mock fetch), webhook and event-handler suites.

MIT