# Telegram Channel Scraper — Full History, No Silent Empties (`apitory/telegram-channel-scraper`) Actor

Scrapes public Telegram channels via the no-login web preview, walking the FULL history back to post 1 or your cap. Never silently returns empty: unservable channels come back as named status items, free. Pay only for delivered posts — /bin/bash.0015 each.

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

## Pricing

from $1.50 / 1,000 message delivereds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## 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 Scraper — Full History, No Silent Empties

Scrapes public Telegram channels through the **no-login web preview** and walks the **full history** — from the newest post back to post 1, or to your cap. No Telegram account, no login, no session strings, no proxy setup.

### Quickstart

Paste this input and press Run:

```json
{
  "channels": ["telegram"],
  "maxPostsPerChannel": 100
}
```

That pulls the 100 newest posts from the official Telegram channel. Set `maxPostsPerChannel` to `0` when you want the channel's full history. The same JSON works through the Apify API.

### Use cases

- **Channel research and media monitoring** — collect what public channels in your niche are posting, and how their posts perform, without a Telegram account.
- **Content and trend datasets** — build a dated archive of posts (text, views, media type) for analysis, reporting or ML training data.
- **Competitor and community tracking** — schedule regular runs and diff the results to see new posts and view counts over time.
- **Backfill before you subscribe** — grab a channel's full history first, then keep up with small capped runs.

### The difference: it never silently returns empty

The most common complaint about Telegram scrapers is a blank dataset with no explanation. This Actor is built around the opposite contract:

1. **Full-history walk.** Each channel is paginated backwards until post 1, your per-channel cap, or the end of your date window. The cap is applied *after* counting, and the run summary reports **posts available vs posts returned** for every channel — no silent truncation.
2. **Unservable channels are named, not silenced.** If a channel's web preview is disabled, the channel is private, or the name doesn't resolve, the dataset contains an explicit status item (`itemType: "channel_status"`) saying which and why. **Status items are never charged.**
3. **You pay only for delivered posts.** $0.0015 per post actually delivered to your dataset. Every page request is retried with backoff, and the run summary reports the real failed-request count.

### What you get per post

- `channelUsername`, `channelTitle`, `subscribers` (as displayed at pull time)
- `postId`, `postUrl`, `dateISO`
- `text` (plain) and `textHtml`
- `views` (as displayed by Telegram at pull time)
- `mediaType` — photo / video / document / poll / none (type only; media files are not downloaded; for polls, `text` holds the question)

Plus, in the run's Key-Value store (`OUTPUT` key): per-channel stats — posts available vs returned, pages fetched, whether the walk reached the channel start or hit your cap, and any failed requests. The summary never enters the dataset, so you're never charged for it. One honest detail: when a walk stops at your cap, "posts available" is the number counted before the walk stopped (a lower bound, flagged `capReached` in the summary); when the walk reaches post 1, it is the channel's full surviving post count.

### Sample output (real records from live runs)

A delivered post:

```json
{
  "itemType": "post",
  "channelUsername": "tproger",
  "channelTitle": "Типичный программист",
  "subscribers": 78000,
  "postId": 15047,
  "postUrl": "https://t.me/tproger/15047",
  "dateISO": "2026-11-25T10:09:10+00:00",
  "text": "2 декабря иду на Conversations в Москве. Это конференция Just AI о том, как компании используют генеративный ИИ.\n\nЯ уже поручаю агентам и свои задачи, и часть работы команды. Бывает, за день успеваю то, на что раньше уходило несколько дней. По-моему, самое сложное тут — быстро об …",
  "mediaType": "photo",
  "fetchedAt": "2026-11-25T15:45:51.444Z",
  "views": 3390,
  "forwards": null
}
```

(`text` trimmed for display and `textHtml` omitted; every other field exactly as delivered.)

An unservable channel comes back as a named status item — never as a silent empty result, and never charged:

```json
{
  "itemType": "channel_status",
  "channelUsername": "BotFather",
  "status": "not_found",
  "detail": "No public channel preview exists for this name (not found, a user/bot, or private).",
  "fetchedAt": "2026-11-25T15:44:43.453Z"
}
```

### Inputs

| Input | Meaning |
|---|---|
| `channels` | Usernames or t.me URLs, e.g. `telegram`, `@durov`, `https://t.me/s/nexta_live` |
| `maxPostsPerChannel` | Cap per channel (default 1000; `0` = full history) |
| `sinceDate` / `untilDate` | Optional post-date window (YYYY-MM-DD) |
| `includeViews` / `includeForwards` | Engagement fields on/off |

### Pricing

Pay-per-event: **$0.00005 per run start + $0.0015 per delivered post** ($1.50 per 1,000 posts). Channel status items are free. No charge for posts that were counted but cut by your cap or date window.

### Known limits (stated honestly)

- **Public, preview-enabled channels only.** A channel that has disabled its web preview cannot be read without a Telegram account — this is a Telegram platform limit that applies to every no-login scraper. Such channels come back as `status: "preview_disabled"`, free of charge.
- **Deleted posts are unrecoverable**, and post IDs have gaps where posts were deleted. A gap is not a missed post.
- **Views are the values Telegram displays at pull time**, parsed from its rounded display figures (e.g. "1.75M").
- **Forward counts are not displayed** by the web preview, so `forwards` is reported as `null` — never invented.
- Very large channels with `maxPostsPerChannel = 0` can hit the run timeout; the summary still reports exactly how far the walk got.

### Pre-launch testing

Before publishing, this Actor was run on Apify's own infrastructure against 5 public channels of very different sizes (official channels with ~430–450 posts, mid-size media, and a 127k-post news channel): **500 posts delivered, 0 failed requests, 0 unexpected empty pages**. A full-history run on the official Telegram channel returned exactly **430 posts, post IDs 1–460, walk verified to post 1** — matching an independent off-platform prototype of the same route (319 requests, 5,327 posts, 0 failures). Bogus and non-channel names were verified to return named `not_found` status items instead of empty datasets.

# Actor input Schema

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

Public channel usernames or t.me URLs, e.g. "telegram", "@durov", "https://t.me/s/nexta_live". Usernames and public channels only — private channels and invite links (t.me/+...) cannot be read without a Telegram account.

## `includeForwards` (type: `boolean`):

Include the forwards field. Note: the Telegram web preview does not display per-post forward counts, so this field is reported as null (never invented). Turn off to omit the field entirely.

## `includeViews` (type: `boolean`):

Include each post's view count as displayed by Telegram at pull time.

## `maxPostsPerChannel` (type: `integer`):

Maximum posts delivered per channel. The cap is applied after counting, and the run summary reports how many posts were available vs returned. 0 = full history (can be very large for old channels — the run may hit its timeout; partial stats are still reported honestly).

## `sinceDate` (type: `string`):

Only return posts published on or after this date (YYYY-MM-DD). The history walk stops once it passes this date.

## `untilDate` (type: `string`):

Only return posts published on or before this date (YYYY-MM-DD).

## Actor input object example

```json
{
  "channels": [
    "telegram"
  ],
  "includeForwards": true,
  "includeViews": true,
  "maxPostsPerChannel": 1000
}
```

# Actor output Schema

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

One item per delivered post (itemType=post): channelUsername, channelTitle, subscribers, postId, postUrl, dateISO, text, textHtml, views, forwards, mediaType. Plus one item per channel that could not be served (itemType=channel_status, never charged) with the reason. A run summary — per-channel posts available vs returned, pages fetched, failed requests — is stored in the Key-Value store under the OUTPUT key, never as a dataset item, so you are never charged for it.

# 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": [
        "telegram"
    ],
    "includeForwards": true,
    "includeViews": true,
    "maxPostsPerChannel": 1000
};

// Run the Actor and wait for it to finish
const run = await client.actor("apitory/telegram-channel-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": ["telegram"],
    "includeForwards": True,
    "includeViews": True,
    "maxPostsPerChannel": 1000,
}

# Run the Actor and wait for it to finish
run = client.actor("apitory/telegram-channel-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": [
    "telegram"
  ],
  "includeForwards": true,
  "includeViews": true,
  "maxPostsPerChannel": 1000
}' |
apify call apitory/telegram-channel-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,apitory/telegram-channel-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/8uPYl6EYkdTrRqHKT/builds/5yODfdpegFVhY6q8x/openapi.json
