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

signal-rest-ts

v0.2.5

Published

typescript wrapper around signal-cli-rest-api

Readme

signal-rest-ts

About

signal-rest-ts is a TypeScript wrapper around signal-cli-rest-api. It can be used in TypeScript or JavaScript based projects, both as a module and in a browser.

Installation

npm

npm install signal-rest-ts

Usage

[!IMPORTANT] In order to use the Receive service, signal-cli-rest-api should be ran in json-rpc mode.

As a module

Get all group metadata, for all accounts

import { SignalClient } from "signal-rest-ts";

const getAllGroups = async () => {
  const signal = new SignalClient("http://localhost:8080");
  const accounts = await signal.account().getAccounts();

  const groups = await Promise.all(
    accounts.map(async (a) => {
      return await signal.group().getGroups(a);
    });
  );

  console.log(groups);
};

Send a message to a user

import { SignalClient } from "signal-rest-ts";

const sendMeAMessage = async () => {
  const signal = new SignalClient("http://localhost:8080");
  const accounts = await signal.account().getAccounts();

  const msg = await signal.message().sendMessage({
    number: accounts[0],
    message: "This is an automated message!",
    recipients: ["+1234567890"],
  });
};

Reply to messages matching a regular expression

const signal = new SignalClient("http://localhost:8080");
const accounts = await signal.account().getAccounts();

signal.receive().registerHandler(accounts[0], /^(ha){2,}/, async (context) => {
  console.log(context.sourceUuid + " -> " + context.message);
  context.reply("What's so funny?");
});

signal.receive().startReceiving(accounts[0]);

Working across all accounts

If your handler should run across all accounts associated to the API, you will want to set a handler for each account. You will also want to "start receiving" for each account. Each account's messages are listened to using a separate WebSocket.

accounts.forEach((account) => {
  signal.receive().registerHandler(account, /^\!command/, async (context) => {
    // ...
  });
  signal.receive().startReceiving(account);
}

Exiting Cleanly

It may be smart to clean up open WebSockets. Or if your application keeps running it may be because they are open. You can close all sockets using ReceiveService#stopAllReceiving().

For example, in a Node-based application:

process.on("SIGINT", () => {
  signal.receive().stopAllReceiving();
});

DOM

Target

A version of the library bundled for the DOM is built to dist/signal-web.js in the default build script. This can be included using a script tag.

<script type="text/javascript" src="signal-web.js"></script>

This will add window.SignalClient which exports the SignalClient class and can be instantiated to access the underlying services, as in the examples above.

CORS

Note that you will have to properly configure CORS, since requests to the endpoint are almost certainly going to be cross-origin.

For example, nginx can be configured to serve permissive CORS headers. Note this example is not secure. Hardening is left as an exercise for the user.

location ~/signal-api/(.*)$ {
  proxy_pass http://10.0.0.1:8080/$1$is_args$args;
  add_header 'Access-Control-Allow-Origin' '*';
  add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
  add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
  add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}

Samples

LLM React Bot

samples/deepseek-react-bot.ts provides examples for receiving and reacting to messages using the context react method. This sample utilizes DeepSeek and reacts to ~2% of messages with an emoji representative of the message's content.

NPR Hourly News

samples/npr-hourly-news.ts is a sample script that shows how to handle commands, use the contextual reply method, and handle attachments. When the script is running, if a user types !npr the bot will fetch the podcast feed, download the latest episode, and reply with it attached.

Running Tests

To run the test suite you can simply use the npm task "test": npm run test

Contributions

Contributions are welcome. To contribute, fork the repo and make your changes, then open a pull request on this repository.

License

Released as-is under MIT license with no warranties.