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

ami-bridge

v2.2.0

Published

Asterisk Manager Interface AMI Client

Readme

ami-bridge

Asterisk Manager Interface (AMI) client for Node.js, written in TypeScript and distributed as CommonJS.

Features

  • AMI client for Node.js (CommonJS + TypeScript, Node >= 18).
  • High-level API for common AMI actions (Ping, CoreStatus, QueueStatus, SIPPeers, etc.).
  • Built-in CLI (ami-bridge) for quick inspection and event dumps.
  • Test suite with Vitest and V8-based coverage (ready for Codecov).

Installation

npm install ami-bridge

Requires Node.js >= 18.

Usage (TypeScript / ESM consumers)

import { createClient, Actions } from 'ami-bridge';

const client = createClient({
  host: '127.0.0.1',
  port: 5038,
  login: 'admin',
  password: 'admin',
});

client.connect();

client.send(new Actions.Ping(), (err, data) => {
  if (err) {
    console.error('PING error:', err);
  } else {
    console.log('PING response:', data);
  }
});

More complete example handling connection lifecycle and multiple actions:

import { createClient, Actions } from 'ami-bridge';

const amibridge = createClient({
  host: '127.0.0.1',
  port: 5038,
  login: 'admin',
  password: 'admin',
});

amibridge.on('incorrectServer', () => {
  amibridge.logger.error('Invalid AMI welcome message. Are you sure if this is AMI?');
  process.exit(1);
});

amibridge.on('connectionRefused', () => {
  amibridge.logger.error('Connection refused.');
  process.exit(1);
});

amibridge.on('incorrectLogin', () => {
  amibridge.logger.error('Incorrect login or password.');
  process.exit(1);
});

amibridge.on('event', (event) => {
  amibridge.logger.info('event:', event);
});

amibridge.on('connected', () => {
  setTimeout(() => {
    amibridge.on('disconnected', () => {
      process.exit(0);
    });

        // Promise-based API is also available via sendAsync:
    amibridge.sendAsync(new Actions.QueueStatus())
      .then((res) => amibridge.logger.info('QueueStatus:', res))
      .catch((err) => amibridge.logger.error('QueueStatus error:', err));

    amibridge.send(new Actions.Ping(), (errPing, resPing) => {
      if (errPing) {
        amibridge.logger.error('Ping error:', errPing);
      } else {
        amibridge.logger.info('Ping response:', resPing);
      }
      amibridge.disconnect();
    });
  }, 10000);
});

amibridge.connect();

Public API from the ami-bridge package (entrypoint dist/index.js): Client, createClient, Actions, Action, Event, Response, Logger, SilentLogger.

Usage (CJS)

const { createClient, Actions } = require('ami-bridge');

const client = createClient({
  host: '127.0.0.1',
  port: 5038,
  login: 'admin',
  password: 'admin',
});

client.connect();

client.send(new Actions.Ping(), (err, data) => {
  if (err) {
    console.error('PING error:', err);
  } else {
    console.log('PING response:', data);
  }
});

CLI

A CLI bin ami-bridge is included:

npx ami-bridge <user> <password> [host[:port]] [-h host] [-p port] [-f eventsFile]

Example:

npx ami-bridge admin admin 127.0.0.1:5038

Options:

  • -h: AMI host (default 127.0.0.1)
  • -p: AMI port (default 5038)
  • -f: saves received events to a JSON file

Examples

The example/ folder has runnable scripts against a real Asterisk instance (CJS, requires ami-bridge installed locally via file:..):

  • basic-usage.js — connect, send several actions (Ping, CoreStatus, Status, Hangup, QueueStatus, Command) with callbacks, auto-disconnect after 10s.
  • async-await.js — same idea using sendAsync() / await instead of callbacks.
  • events.js — listen for event, rawEvent, and rawEvent.<Name> (Hangup, Newchannel, VarSet), periodic Ping keepalive, clean shutdown on SIGINT.

Run:

cd example
npm install
node basic-usage.js    # or async-await.js / events.js

Edit the host/login/password fields in each script to match your Asterisk Manager config (manager.conf).

Development

npm run build
npm run lint
npm test

Generate lcov coverage:

npm run coverage:lcov

License

MIT