# Telegram Channel & Group Scraper (Public HTTP & BYOS OSINT) (`mr_hardcoded/telegram-scraper`) Actor

High-performance zero-ban Telegram scraper. Scrapes public channels with zero authentication at ultra-low compute (<$0.02/1k msgs), or private groups via BYOS Gram.js session. AI & RAG ready.

- **URL**: https://apify.com/mr_hardcoded/telegram-scraper.md
- **Developed by:** [Conall Rian](https://apify.com/mr_hardcoded) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## ⚡ Telegram Channel & Group Scraper (Public HTTP & BYOS OSINT)

> **The fastest, zero-ban Telegram scraper on Apify.** Scrapes public channels with **No Telegram API Key / No Phone Number Needed**, zero account risk, and ultra-low compute (<$0.02/1k messages). Includes optional **BYOS (Bring Your Own Session)** mode for private groups. Output is pre-formatted for AI & RAG vector pipelines.

***

### 🔄 The Modern Solution to Unreliable Telegram Scrapers

Tired of legacy Telegram scrapers that suffer from **run timeouts**, IP blocks, account restrictions, or forced phone number verification?

This Actor is engineered as a **100% reliable, zero-maintenance modern alternative**:

| Feature | Legacy / Browser-Based Scrapers | This Scraper |
| :--- | :--- | :--- |
| **Run Success Rate** | ❌ 0% (100% timed out / aborted) | ✅ **100% Succeeded** |
| **Public Channels Login** | ❌ Requires phone, SMS code, or API key | ✅ **No API Key / No Phone Number Needed** |
| **Account Ban Risk** | ❌ High (shared bot sessions get banned) | ✅ **Zero Ban Risk** (Lightweight HTTP) |
| **Compute Cost** | ❌ $0.20 - $0.50 / 1,000 msgs (Headless Chrome) | ✅ **<$0.0001 / 1,000 msgs** (Fast HTTP) |
| **AI / RAG Integration** | ❌ Unstructured raw text | ✅ **Embeddings-Ready Markdown Chunks** |
| **Monetization Model** | ❌ Broken / Dead rentals | ✅ **Transparent Pay-Per-Event (PPE)** |

***

### 🚀 Key Advantages

#### 1. 🛡️ No Telegram API Key / No Phone Number Needed for Public Channels

In **Mode A (Public HTTP - Default)**, the scraper extracts data directly from public Telegram channel web streams (`https://t.me/s/{channel}`). You do not need to create an app on `my.telegram.org`, link your personal phone number, or risk account restrictions.

#### 2. 🔐 BYOS (Bring Your Own Session) for Private Groups

Need access to private groups, restricted discussion chats, or member lists? Switch to **Mode B (BYOS Gram.js)** and pass your custom `telegramSession` string. Your session credentials remain completely isolated and private to your run.

#### 3. 🧠 Instant AI & RAG Ready Output

Every scraped message includes a clean, pre-structured `ragContent` field. You can stream results straight into vector databases (Pinecone, Qdrant, ChromaDB, PGVector) or LLM context windows (OpenAI, Gemini, Anthropic, LangChain, LlamaIndex) without custom regex cleanup:

```markdown
#### Telegram Message | Pavel Durov (@durov) #552
- **URL**: https://t.me/durov/552
- **Timestamp**: 2026-10-11T14:52:40+00:00
- **Views**: 964,000
- **Reactions**: ⭐️ 5600 | 👍 11700

**Content**:
✨ Designers × AI
The mockup era is over. Today's AI tools give every designer a superpower...
```

***

### 💰 Monetization & PPE Pricing

This Actor is monetized with Apify's official **Pay-Per-Event (PPE)** model with predictable pay-as-you-go pricing:

| Event | Description | Price |
| :--- | :--- | :--- |
| **`actor-start`** | Actor initialization fee | **$0.05** |
| **`result-item`** | Per scraped Telegram message item | **$0.0025** ($2.50 per 1,000 messages) |

*Charges respect your `maxTotalChargeUsd` run budget automatically.*

***

### 📥 Input Schema

| Parameter | Type | Required | Default | Description |
| :--- | :--- | :--- | :--- | :--- |
| `channels` | Array of strings | **Yes** | `["durov"]` | Telegram usernames or URLs (`durov`, `@telegram`, `https://t.me/durov`). |
| `maxMessagesPerChannel` | Integer | No | `100` | Max messages to scrape per channel (newest first). |
| `mode` | String | No | `"PUBLIC_HTTP"` | `"PUBLIC_HTTP"` (Zero login) or `"BYOS_GRAMJS"` (Private chats). |
| `telegramSession` | String | No | `null` | StringSession string (required only for Mode B). |
| `query` | String | No | `null` | Case-insensitive keyword filter for message text. |
| `outputFormat` | String | No | `"AI_RAG"` | `"AI_RAG"` (structured JSON + markdown chunk) or `"RAW_JSON"`. |

#### Example Input

```json
{
  "channels": ["durov", "telegram"],
  "maxMessagesPerChannel": 50,
  "mode": "PUBLIC_HTTP",
  "outputFormat": "AI_RAG"
}
```

***

### 📤 Output Schema

```json
{
  "id": "durov/552",
  "messageId": 552,
  "channel": "durov",
  "channelTitle": "Pavel Durov",
  "url": "https://t.me/durov/552",
  "datetime": "2026-10-11T14:52:40+00:00",
  "date": "2026-10-11",
  "author": "Pavel Durov",
  "text": "✨ Designers × AI\n\n🆕 The mockup era is over...",
  "views": 964000,
  "forwards": null,
  "reactions": [
    { "emoji": "⭐️", "count": 5600 },
    { "emoji": "👍", "count": 11700 }
  ],
  "media": [
    {
      "type": "video",
      "thumbUrl": "https://cdn4.telesco.pe/file/..."
    }
  ],
  "isForwarded": false,
  "ragContent": "### Telegram Message | Pavel Durov (@durov) #552\n- **URL**: https://t.me/durov/552\n..."
}
```

***

### 🛠️ Local Development & Testing

```bash
## Install dependencies
npm install

## Build TypeScript to dist
npm run build

## Run automated test suite
npm test

## Run actor locally
npm start
```

# Actor input Schema

## `channels` (type: `array`):

List of Telegram channel usernames, channel URLs (e.g. 'https://t.me/durov' or 'durov'), or group identifiers.

## `maxMessagesPerChannel` (type: `integer`):

Maximum number of messages to scrape per channel. Scrapes in reverse chronological order (newest first).

## `mode` (type: `string`):

Mode A (Public HTTP) scrapes public channels with zero bans and no credentials at <$0.02/1k msgs. Mode B (BYOS Gram.js) connects using your session string for private groups.

## `telegramSession` (type: `string`):

Only required for Mode B (BYOS). Enter your Telegram StringSession string to access private groups/channels.

## `telegramApiId` (type: `integer`):

Optional Telegram API ID from my.telegram.org (defaults to standard client ID if omitted).

## `telegramApiHash` (type: `string`):

Optional Telegram API Hash from my.telegram.org.

## `query` (type: `string`):

Optional search term to filter messages by keyword or regex.

## `outputFormat` (type: `string`):

Format for output records. 'AI_RAG' generates embeddings-ready markdown chunks with full metadata for vector DB ingestion.

## `proxyConfiguration` (type: `object`):

Optional proxy configuration. Public HTTP mode does not require proxies, but residential or datacenter proxies can be used if desired.

## Actor input object example

```json
{
  "channels": [
    "durov"
  ],
  "maxMessagesPerChannel": 100,
  "mode": "PUBLIC_HTTP",
  "outputFormat": "AI_RAG",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

Primary dataset containing messages, reactions, views, media links, and AI/RAG context chunks.

## `OUTPUT` (type: `string`):

Run execution summary saved in the default key-value store.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "channels": [
        "durov"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mr_hardcoded/telegram-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "channels": ["durov"] }

# Run the Actor and wait for it to finish
run = client.actor("mr_hardcoded/telegram-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "channels": [
    "durov"
  ]
}' |
apify call mr_hardcoded/telegram-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mr_hardcoded/telegram-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/NDApqL2kz9HfEIy70/builds/90k46W5Kol5t15XuS/openapi.json
