# Telegram Public Channel Scraper (`axery/telegram-channel-scraper`) Actor

Scrape posts from any PUBLIC Telegram channel - text, timestamp, view count, media and outbound links. No login, no bot token, no API key.

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

## Pricing

from $2.00 / 1,000 result items

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Public Channel Scraper

Scrapes posts from **public Telegram channels** over plain HTTP — no login, no bot token, no API key, no browser.

### Scope: public channels only

This Actor reads Telegram's own public web preview (`t.me/s/{channel}`) — the page anyone sees without an account. **Private channels, private groups and user accounts are not accessible and are deliberately out of scope**; no attempt is made to reach them.

### What you get per post

Text, exact ISO timestamp, view count, media URLs, outbound links, forward attribution and reply flag.

**View counts are expanded into real numbers.** Telegram publishes them abbreviated (`"1.41M"`, `"834K"`) — unsortable as a string. This Actor parses that into an integer while keeping the original:

```json
"views": 1410000, "views_display": "1.41M"
```

Note the abbreviation means the source value is *rounded* — `1.41M` is not exactly 1,410,000. Both fields are provided so you can see which you're relying on.

**Post text is unwrapped, not stripped.** Telegram renders line breaks as `<br>`, custom emoji as `<tg-emoji>` elements and links as anchors. Naively removing tags would glue words from separate lines together and silently delete every link. This Actor converts `<br>` to newlines *first*, then unwraps the rest, and collects outbound URLs into a separate `links` field.

### Input

| Field | Type | Notes |
|---|---|---|
| `channels` | array | Public channel handles, with or without `@`. |
| `maxItems` | integer | Per channel, newest first. `0` = full reachable history. |
| `incremental` | boolean | Only posts not seen in previous runs — ideal for a daily monitor. |
| `proxyConfiguration` | object | Datacenter is enough — no anti-bot layer encountered. |

### Known limits

- **Public channels only** — see the scope note above. A private, nonexistent, or group handle returns a clear error naming the likely cause rather than an empty dataset.
- **View counts are rounded at the source.** Use `views_display` if you need to know exactly what Telegram showed.
- **History depth varies.** Telegram pages backwards via a `before` cursor; how far back it will serve depends on the channel. The Actor stops cleanly when the cursor runs out.

### Local development

```bash
pip install -r requirements.txt
python test_local.py durov --max 20 --out sample_output.json
python test_local.py telegram --max 50
```

`sample_output.json` in this folder is real output from a live run.

# Actor input Schema

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

One or more PUBLIC channel handles, with or without the leading @ (e.g. `durov`, `@telegram`). Each runs independently and streams into the same dataset. Private channels, groups and user accounts will not work - Telegram does not expose them without an account.

## `maxItems` (type: `integer`):

Maximum posts per channel, newest first. Set to `0` for the channel's full reachable history - the Actor pages backwards until Telegram runs out or a safety guard trips.

## `incremental` (type: `boolean`):

Remember post ids between runs and return only posts not seen before. You are charged only for the new rows, so a daily channel monitor costs a fraction of a full re-scrape after the first run.

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

Apify Proxy settings. No anti-bot layer was encountered on Telegram's public preview - Apify's automatic proxy selection is enough for normal volumes.

## Actor input object example

```json
{
  "channels": [
    "durov",
    "telegram"
  ],
  "maxItems": 100,
  "incremental": false,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `posts` (type: `string`):

One row per post: text, timestamp, numeric view count, media URLs and outbound links.

## `coverage` (type: `string`):

No description

# 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"
    ],
    "maxItems": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("axery/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": ["durov"],
    "maxItems": 100,
}

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,axery/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/aejaOb4ONDaSTHaXJ/builds/oKpQhOc7kFBgQCbj1/openapi.json
