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

telegram-audience-harvester

v1.0.0

Published

Telegram bot audience and subscriber extractor via MTProto PTS synchronization

Readme

Telegram-Audience-Harvester

Export audience and subscribers from your Telegram bot via MTProto update history (updates.getDifference).

License: MIT TypeScript Node.js

English | Русский


Telegram's standard Bot API doesn't provide a way to get a list of your bot's users or subscribers.

This tool logs in to MTProto using your bot token, walks through its PTS update history, and extracts every user who ever sent a message or interacted with the bot.

Quick Start (CLI)

Run it directly with npx:

export TELEGRAM_API_ID="123456"
export TELEGRAM_API_HASH="0123456789abcdef0123456789abcdef"

npx telegram-audience-harvester --token "1234567890:ABCdefGhIJKlmNoPQRsTUVwxyZ" --csv audience.csv

Or pass everything via CLI flags:

npx telegram-audience-harvester \
  --token "1234567890:ABCdefGhIJKlmNoPQRsTUVwxyZ" \
  --api-id 123456 \
  --api-hash "0123456789abcdef0123456789abcdef" \
  --csv ./audience.csv \
  --json ./report.json

CLI Flags

| Flag | Env | Default | Description | |---|---|---|---| | -t, --token <token> | BOT_TOKEN | required | Bot token from @BotFather | | --api-id <id> | TELEGRAM_API_ID | required | Telegram API ID from my.telegram.org | | --api-hash <hash> | TELEGRAM_API_HASH | required | Telegram API Hash from my.telegram.org | | -p, --proxy <url> | PROXY_URL | - | Proxy URL (socks5://, http://, mtproxy) | | -c, --csv <path> | - | - | Path to save CSV file | | -j, --json <path> | - | - | Path to save JSON report | | -d, --delay <ms> | - | 35 | Delay in ms between requests (protects from rate limits) | | --days <num> | - | 7 | Days offline threshold to consider a user active | | --max-iter <num> | - | 5000 | Safety limit on total iterations | | --max-flood <sec>| - | 300 | Max flood wait seconds before giving up |


Library Usage

npm install telegram-audience-harvester

Simple call

import { harvestBotAudience } from 'telegram-audience-harvester';

const report = await harvestBotAudience({
  apiId: 123456,
  apiHash: '0123456789abcdef0123456789abcdef',
  botToken: '1234567890:ABCdefGhIJKlmNoPQRsTUVwxyZ',
  saveCsvPath: './audience.csv',
  onProgress: (p) => {
    console.log(`${p.percent}% done (${p.uniqueUsers} users found)`);
  },
});

console.log(`Found ${report.totalUsers} users (${report.activeUsers} active)`);

Event streaming (for large bots)

If your bot has a massive audience and you want to stream users as they arrive instead of buffering everything in memory:

import { BotAudienceHarvester } from 'telegram-audience-harvester';

const harvester = new BotAudienceHarvester({
  apiId: 123456,
  apiHash: '0123456789abcdef0123456789abcdef',
  botToken: '1234567890:ABCdefGhIJKlmNoPQRsTUVwxyZ',
});

harvester.on('user', (user) => {
  console.log(`User: ${user.id} (@${user.username || 'none'})`);
});

harvester.on('progress', (p) => {
  console.log(`${p.percent}% (PTS: ${p.currentPts}/${p.serverPts})`);
});

const report = await harvester.start();

Output Data

Each extracted user profile contains:

  • id: 64-bit Telegram user ID
  • firstName, lastName: User's display name
  • username: Primary username (without @)
  • usernames: All handles, including Fragment collectible/NFT usernames
  • isPremium: Whether the user has Telegram Premium
  • isDeleted: True if the account was deleted
  • status: Raw MTProto status string (userStatusRecently, userStatusOnline, etc.)
  • lastSeen: Unix timestamp of last seen online (if available)
  • isActive: Calculated based on your activeDaysThreshold (default: 7 days)
  • language: Client language code (ru, en, etc.)
  • photoDcId: Datacenter ID of profile picture

License

MIT © Artemiy Zarubin