Install

TeleGlance supports Python 3.10 through 3.14. Install from PyPI:

Bash
pip install teleglance

# Optional extras for CLI and SOCKS proxy support
pip install "teleglance[cli,socks]"

First request

The client is async and designed to be used with async with for automatic cleanup:

Python
import asyncio
from teleglance import TeleGlanceClient

async def main():
    async with TeleGlanceClient() as client:
        # Get channel metadata
        channel = await client.get_channel("telegram")
        print(channel.title, channel.counts.subscribers)

        # Iterate over recent messages
        async for message in client.iter_messages("telegram", limit=10):
            print(f"{message.id}: {message.text[:80]}")

asyncio.run(main())

Pagination

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

Python
# Get first page
messages = await client.get_messages("telegram", limit=20)

# Get next page using oldest message ID
older = await client.get_messages("telegram", limit=20, before=messages[-1].id)

# Or iterate automatically
async for message in client.iter_messages("telegram", limit=100):
    print(message.id, message.date)

Search

Search within a channel using keyword queries:

Python
async for message in client.search("telegram", "release", limit=20):
    print(message.url)

# Search also supports before/after pagination
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