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

@hearthnpm/public-api-client

v1.1.0

Published

Official TypeScript client for the Hearth Public API v1 and OAuth 2.0 PKCE

Downloads

252

Readme

@hearthnpm/public-api-client

Client TypeScript officiel pour Hearth Public API v1.

Les tokens happ_... sont des secrets serveur-à-serveur. Ne les placez jamais dans du JavaScript livré à un navigateur public. Pour une application Web, mobile ou desktop agissant au nom d'un utilisateur, utilisez OAuth Authorization Code + PKCE S256 (M54).

Installation

npm install @hearthnpm/public-api-client

Node.js 18 ou plus récent est requis (le SDK utilise le fetch natif).

Exemple

import { HearthPublicApiClient } from "@hearthnpm/public-api-client";

const hearth = new HearthPublicApiClient({
  baseUrl: "https://hearth.syscorp-technologies.com",
  token: process.env.HEARTH_TOKEN!,
});

const me = await hearth.me();
const { items: servers } = await hearth.servers();

console.log(me.application.name, servers);

Envoyer un message

await hearth.createMessage(
  "CHANNEL_ID",
  { content: "Bonjour depuis mon bot." },
  { idempotencyKey: crypto.randomUUID() },
);

Authentification et scopes

Créez une application dans Hearth, installez-la sur le serveur concerné, accordez uniquement les scopes nécessaires puis créez un token API. Les scopes de l'API v1 incluent notamment :

  • servers.read
  • channels.read
  • messages.read
  • messages.write
  • members.read
  • roles.read
  • events.read
  • webhooks.read
  • webhooks.write

Le token ne contourne jamais les permissions Hearth du bot installé sur le serveur.

Gestion des erreurs

import {
  HearthPublicApiClient,
  HearthPublicApiError,
} from "@hearthnpm/public-api-client";

try {
  await hearth.server("SERVER_ID");
} catch (error) {
  if (error instanceof HearthPublicApiError) {
    console.error(error.status, error.code, error.requestId);
  }
}

Versionnage

Le SDK suit son propre SemVer et est indépendant de la version de l'application Hearth :

  • 1.0.x : corrections du SDK ;
  • 1.x.0 : nouvelles méthodes compatibles avec Public API v1 ;
  • 2.0.0 : rupture de compatibilité du SDK.

L'API HTTP reste versionnée séparément sous /api/v1.

Publication (mainteneurs)

Depuis la racine du dépôt :

npm run sdk:build
npm run sdk:pack
npm run sdk:publish

Ou directement :

cd packages/public-api-client
npm run build
npm pack --dry-run
npm publish --access public

OAuth 2.0 / PKCE

Le SDK 1.1.0 expose createHearthOAuthPkce, hearthOAuthAuthorizationUrl, exchangeHearthOAuthCode, refreshHearthOAuthToken et revokeHearthOAuthToken. Les access tokens hoat_... peuvent être passés à HearthPublicApiClient exactement comme un token applicatif.