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

@prismpublication/sdk

v1.0.0

Published

Prism Ad Network SDK for AI Chatbots

Readme

@prismpublication/sdk

Prism Ad Network SDK for AI Chatbots - Integrate ads into your AI and start monetizing!

Installation

npm install @prismpublication/sdk

Getting Credentials

From the Bot Developer portal (/app/publisher):

  1. Create or select a bot.
  2. Copy that bot's botId.
  3. Create an SDK key (full token is shown only at creation time).
  4. Use:
    • apiKey = SDK key token
    • botId = portal bot ID
    • baseUrl = your API base (for local: http://localhost:8080/api)

Quick Start

import { PrismAds } from '@prismpublication/sdk';

// Initialize the SDK
const prismAds = new PrismAds({
  apiKey: 'YOUR_API_KEY',
  botId: 'your-bot-id',
  position: 'inline',
  adFormat: 'text'
});

// Fetch and display an ad
async function handleUserMessage(userMessage) {
  const response = await generateAIResponse(userMessage);
  
  // Show ad every 5 messages
  if (prismAds.shouldShowAd(userId, 5)) {
    const ad = await prismAds.displayAd({
      topic: detectTopic(userMessage),
      userId: userId
    });
    
    if (ad) {
      // Track impression
      prismAds.trackImpression(ad.id, userId);
      return [response, ad];
    }
  }
  
  return [response];
}

React Integration

import { PrismAdComponent, usePrismAd } from '@prismpublication/sdk/react';

// Using the hook
function ChatMessage() {
  const { ad, loading, refresh } = usePrismAd({
    apiKey: 'YOUR_API_KEY',
    botId: 'your-bot-id',
    baseUrl: 'http://localhost:8080/api',
    topic: 'technology',
    userId: 'user-123',
    frequency: 5
  });

  if (loading) return <div>Loading ad...</div>;
  if (!ad) return null;

  return (
    <div>
      <h3>{ad.title}</h3>
      <p>{ad.description}</p>
      <a href={ad.clickUrl}>{ad.ctaText}</a>
    </div>
  );
}

// Using the component
function App() {
  return (
    <PrismAdComponent
      apiKey="YOUR_API_KEY"
      botId="your-bot-id"
      baseUrl="http://localhost:8080/api"
      topic="tech"
      userId="user-123"
      frequency={5}
    />
  );
}

API Reference

PrismAds Class

new PrismAds(config: PrismConfig)

Configuration Options

| Option | Type | Required | Description | |--------|------|----------|-------------| | apiKey | string | Yes | Your Prism API key | | botId | string | Yes | Your bot's unique ID | | position | string | No | Ad placement: 'inline', 'sidebar', 'floating' | | adFormat | string | No | Format: 'text', 'card', 'banner' | | baseUrl | string | No | Custom API URL for self-hosted |

Methods

fetchAds(context?: AdContext): Promise<Ad[]>

Fetch multiple ads with targeting context.

displayAd(context?: AdContext): Promise<Ad | null>

Get a single ad for display.

formatAd(ad: Ad): FormattedAd

Format an ad based on the configured format type.

trackImpression(adId: string, userId?: string): Promise

Track when an ad is displayed.

trackClick(adId: string, userId?: string): Promise

Track when an ad is clicked.

trackRevenue(adId: string, amount: number, userId?: string): Promise

Track ad revenue (in cents).

shouldShowAd(userId: string, frequency?: number): boolean

Check if an ad should be shown based on message frequency.

resetMessageCount(userId: string): void

Reset the message counter for a user.

getMessageCount(userId: string): number

Get the current message count for a user.

Types

interface Ad {
  id: string;
  title: string;
  description: string;
  ctaText: string;
  clickUrl: string;
  imageUrl?: string;
  advertiser: string;
  tags?: string[];
}

interface AdContext {
  topic?: string;
  userId?: string;
  [key: string]: any;
}

Examples

Discord Bot

const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.MessageContent] });

const prismAds = new PrismAds({
  apiKey: process.env.PRISM_API_KEY,
  botId: 'discord-bot',
  adFormat: 'card'
});

client.on('messageCreate', async (message) => {
  if (message.author.bot) return;
  
  const response = await generateAIResponse(message.content);
  
  if (prismAds.shouldShowAd(message.author.id, 10)) {
    const ad = await prismAds.displayAd({ topic: 'general' });
    
    if (ad) {
      const embed = new EmbedBuilder()
        .setTitle(ad.title)
        .setDescription(ad.description)
        .addFields({ name: ad.ctaText, value: ad.clickUrl });
      
      await message.reply({ embeds: [embed] });
      await prismAds.trackImpression(ad.id, message.author.id);
    }
  }
});

Telegram Bot

const TelegramBot = require('node-telegram-bot-api');

const bot = new TelegramBot(process.env.TELEGRAM_TOKEN, { polling: true });

const prismAds = new PrismAds({
  apiKey: process.env.PRISM_API_KEY,
  botId: 'telegram-bot'
});

bot.on('message', async (msg) => {
  if (msg.from.is_bot) return;
  
  const response = await generateAIResponse(msg.text);
  
  if (prismAds.shouldShowAd(msg.from.id, 5)) {
    const ad = await prismAds.displayAd();
    
    if (ad) {
      const adText = `\n\n━━━ Sponsored ━━━\n${ad.title}\n${ad.description}\n${ad.ctaText}: ${ad.clickUrl}`;
      bot.sendMessage(msg.chat.id, response + adText);
      await prismAds.trackImpression(ad.id, msg.from.id);
    }
  }
});

License

MIT