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

aardvark-js

v0.0.8

Published

An isomorphic JavaScript client for Aardvark.

Readme

aardvark-js

An isomorphic JavaScript client for Aardvark.

  • Documentation: https://developer-docs.aardvark.sh

Usage

First of all, you need to install the library:

npm install aardvark-js

Or using Yarn...

yarn add aardvark-js

Then you're able to import the library and create an Aardvark client:

require style

const { createClient } = require("aardvark-js");

import style

import { createClient } from "aardvark-js";

UMD

You can now use plain <script> to import aardvark-js from CDNs, like:

<script src="https://cdn.jsdelivr.net/npm/aardvark-js"></script>

Getting Started

Secure Authentication

!IMPORTANT! Do NOT put your Aardvark Application Secret in frontend code. This is opaque and anyone with access to your application will be able to steal your credentials and authenticate as you.

Our recommended approach is to have an endpoint in a secure runtime (typically an API or serverless function) that authenticates with your application ID and application secret, and returns a token which can be securely used in your frontend to now make Aardvark requests.

Secure Runtime Endpoint (Node/Express API endpoint)

The below example code outlines how you could run a very simple Node API or serverless function which authenticates with Aardvark and returns the secure token to your frontend to initialize and securely interact with Aardvark.

const express = require("express");
const cors = require("cors");
const bodyParser = require("body-parser");

const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

const port = 3030;
const { createClient } = require("aardvark-js");

const aardvark = createClient(
  "https://api.aardvark.sh",
  {
    applicationId: YOUR_APP_ID,
    applicationSecret: YOUR_APP_SECRET,
  },
  YOUR_COMMUNITY_ID
);

app.post("/aardvark", async (req, res) => {
  const response = await aardvark.authenticate({
    externalId: req.body.externalId,
  });
  res.status(200).send(response);
});

app.listen(port, () => {
  console.log(`Aardvark SDK example app listening on port ${port}`);
});

Frontend client initialization

import { createClient } from "aardvark-js";

// note: the url and port chosen match the secure runtime example above
const { data: authCredentials } = await axios.post(
  "http://localhost:3030/aardvark",
  {
    externalId: MY_USER_ID,
  }
);

const aardvark = createClient(
  "https://api.aardvark.sh",
  authCredentials,
  COMMUNITY_ID
);

Logging in

const aardvarkUser = await aardvark.initialize({
  externalId: MY_SYSTEMS_USERID, // could be a username, guid, etc
});

Listen for messages

Messages from both channels and DMs will trigger the function passed as an argument to the .listen((type, message)) function.

await aardvarkUser.listen((type, message) => {
  console.log(message);
});

Sample output might be

{
  "messageId": "99a74b26-c215-4acc-8a20-9d2e6c7e58fb",
  "conversationId": "b49c646d-6626-44b3-a2a3-69f8a0f0b30d",
  "message": "I'm a test message!",
  "datetime": "2023-01-11T13:15:30Z",
  "encrypted": false,
  "userId": "f2a29045-3076-44e5-8269-e116416d87e8",
  "senderUsername": "AardvarkAustin#0001",
  "senderProfilePicUri": "myuri.com/pfp.jpg",
  "channelId": "99a74b26-c215-4acc-8a20-9d2e6c7e58fb",
  "channelName": "General"
}

Connect a metamask wallet

await aardvarkUser.connectWallet(WalletProvider.METAMASK);

Sending a message to a username

const conversationId = await aardvarkUser.createConversation({
  parties: [
    {
      username: AARDVARK_USERNAME, // ex: 'KidnappedKitten#0001'
    },
  ],
});

await aardvarkUser.sendMessage(conversationId, {
  message: messageContent.value,
});

Sending a message to a wallet address

const conversationId = await aardvarkUser.createConversation({
  parties: [
    {
      walletPublicKey: "0xBfaFb822806E0551071BD86521641DE6fD50439C",
    },
  ],
});

await aardvarkUser.sendMessage(conversationId, {
  message: messageContent.value,
});

Get all channels

const channels = await aardvarkUser.getChannels();

Sample response

{
  "data": [
    {
      "id": "93e811c2-e2f3-4cd2-8e88-307caa96c915",
      "createdAt": "2023-02-02T17:31:48.861634+00:00",
      "name": "General",
      "description": "General chat for all users",
      "communityId": "d327d192-570a-44a0-8f87-833c382d27e9"
    },
    {
      "id": "0def97fa-9106-4b41-9259-e98578c4a591",
      "createdAt": "2023-02-02T17:40:54.431071+00:00",
      "name": "Trading",
      "description": "Trade, swap, barter, profit!",
      "communityId": "d327d192-570a-44a0-8f87-833c382d27e9"
    }
  ],
  "paging": {
    "offset": 0,
    "size": 25,
    "totalCount": 2
  }
}

Add user to channel

await aardvarkUser.addToChannel({ channelId: GENERAL_CHANNEL_ID });

Send message in channel

await aardvarkUser.sendChannelMessage(channelId, {
  message: "I'm a message in a channel!",
});