Install

TeleGlance requires Node.js 18 or newer. Install from npm:

Bash
npm install teleglance

# Or with yarn/pnpm
yarn add teleglance
pnpm add teleglance

First request

The client supports both ESM and CommonJS. Remember to call close() when done:

TypeScript
import { TeleGlanceClient } from 'teleglance';

const client = new TeleGlanceClient();

try {
  // Get channel metadata
  const channel = await client.getChannel('telegram');
  console.log(channel.title, channel.counts.subscribers);

  // Iterate over recent messages
  for await (const message of client.iterMessages('telegram', { limit: 10 })) {
    console.log(`${message.id}: ${message.text.slice(0, 80)}`);
  }
} finally {
  await client.close();
}

Pagination

History is newest-first by default. Use before for older messages:

TypeScript
// Get first page
const messages = await client.getMessages('telegram', { limit: 20 });

// Get next page using oldest message ID
const older = await client.getMessages('telegram', {
  limit: 20,
  before: messages[messages.length - 1].id
});

// Or iterate automatically
for await (const message of client.iterMessages('telegram', { limit: 100 })) {
  console.log(message.id, message.date);
}

Search

Search within a channel using keyword queries:

TypeScript
for await (const message of client.search('telegram', 'release', { limit: 20 })) {
  console.log(message.url);
}

// Search also supports before/after pagination
const results = await client.search('python', 'async', { limit: 50 });

CLI usage

The CLI provides JSON output for scripting and data export:

Bash
# Get channel info
teleglance channel telegram --output channel.json

# Fetch message history
teleglance messages telegram --limit 100 --output messages.json

# Search and save results
teleglance search telegram "release" --limit 50 --output search.json