# Telegram Scraper (`dainty_screw/telegram-scraper`) Actor

Seamlessly extract public messages from any Telegram public channel and gain valuable insights. Perfect for researchers, marketers, and data analysts.

- **URL**: https://apify.com/dainty\_screw/telegram-scraper.md
- **Developed by:** [codemaster devops](https://apify.com/dainty_screw) (community)
- **Categories:** Lead generation, Social media
- **Stats:** 1,086 total users, 6 monthly users, 100.0% runs succeeded, 30 bookmarks
- **User rating**: 4.61 out of 5 stars

## Pricing

$19.99/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period. You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## 🚀 Telegram Channel Scraper

Scrape public Telegram channels with enterprise-friendly flexibility. The actor now supports post **ID ranges**, **date ranges**, configurable post limits, and optional **comment harvesting**, all while capturing richer post metadata such as reactions and attachments.

***

### 🔧 Input Example

```json
{
    "channels": [
        "mediumcom"
    ],
    "maxCommentsPerPost": 10,
    "maxPostsPerChannel": 10,
    "postsFrom": 10,
    "postsTo": 20,
    "proxy": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    },
    "includeComments": false
}
```

#### 📝 Input Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `channels` | `array` | List of public channel usernames (e.g. `["mediumcom"]`). |
| `postsFrom` | `integer` | (Optional) Minimum post ID to consider (channels start at 1). |
| `postsTo` | `integer` | (Optional) Maximum post ID (set to `0`/omit to ignore). |
| `maxPostsPerChannel` | `integer` | Caps the number of posts processed per channel (default `200`). |
| `fromDate` | `string` | (Optional) ISO timestamp – collect posts on/after this moment. |
| `toDate` | `string` | (Optional) ISO timestamp – collect posts on/before this moment. |
| `includeComments` | `boolean` | When enabled, fetches the public comment thread for each post (if available). |
| `maxCommentsPerPost` | `integer` | Maximum number of comments captured per post (default `100`). |
| `proxy` | `object` | Proxy settings – **RESIDENTIAL** proxies strongly recommended/required. |
| `navigationTimeoutSecs` | `integer` | Timeout per HTTP fetch in seconds (default `120`). |

You can mix-and-match ID ranges, date filters, and maximum post counts to control the crawl scope precisely.

***

### 📤 Output Example

```json
[
  {
    "id": 18,
    "channelName": "mediumcom",
    "channelTitle": "Medium",
    "authorName": "Medium / Medium.com",
    "authorTelegram": "https://t.me/mediumcom",
    "date": "2024-01-05T12:24:33+00:00",
    "viewsCount": "15",
    "text": "https://journal.thriveglobal.com/look-for-people...",
    "linkPreview": "Thrive Global\n\n“Look For People Who Need You...”",
    "reactions": [
      {
        "emoji": "👍",
        "count": 42,
        "countDisplay": "42"
      }
    ],
    "attachments": [
      {
        "type": "tgme_widget_message_photo",
        "caption": "Image caption",
        "url": "https://t.me/..."
      }
    ],
    "commentsCount": "3",
    "commentsCollected": 3,
    "comments": [
      {
        "authorName": "Jane Doe",
        "authorTelegram": "https://t.me/janedoe",
        "date": "2024-01-05T13:00:00+00:00",
        "text": "Great update!"
      }
    ]
  }
]
```

#### 📋 Output Fields

| Field | Type | Description |
|-------|------|-------------|
| `id` | `integer` | Message ID. |
| `channelName` | `string` | Channel username. |
| `channelTitle` | `string` | Channel title (when available). |
| `channelDescription` | `string` | Channel description text (first listing hit). |
| `subscribersText` | `string` | Subscriber counter text from Telegram (if visible). |
| `authorName` | `string` | Author display name. |
| `authorTelegram` | `string` | Link to the author/channel. |
| `date` | `string` | ISO 8601 timestamp. |
| `viewsCount` | `string` | View counter displayed by Telegram. |
| `text` | `string` | Message body text. |
| `linkPreview` | `string` | Link preview text. |
| `reactions` | `array` | Emoji reactions with numeric counts. |
| `attachments` | `array` | Metadata for attached media (type, caption, url). |
| `commentsCount` | `string` | Comment counter Telegram shows on the post. |
| `comments` | `array` | Collected comments (author, link, date, text) when enabled. |
| `commentsCollected` | `integer` | How many comments were captured for this post. |

***

### 💡 How to Use

1. **Specify channels** – supply the public usernames you want to scrape.
2. **Choose your range strategy** – mix ID limits, date filters, and `maxPostsPerChannel` to bound the crawl.
3. **Toggle comments** – enable `includeComments` (and tune `maxCommentsPerPost`) to add discussion threads.
4. **Configure proxies** – use Apify RESIDENTIAL or your own high-quality proxies for consistent access.
5. **Run the actor** – monitor the logs for skipped/blocked content and adjust parameters as needed.

***

### 🛠️ Tips & Tricks

- Combine **date filters** with `maxPostsPerChannel` to collect recent activity without guessing IDs.
- When you do rely on IDs, start with humane limits (e.g. first 50 posts) and expand gradually.
- A handful of messages require the official Telegram app and will be skipped – the actor logs them.
- Respect Telegram policies: throttling retries and using residential IPs dramatically improves success rates.

***

### 🔗 Connect With Us

- **🌐 Blog**: [Quick Life Solutions](https://quicklifesolutions.com)
- **📺 YouTube**: [CodeMaster-421](https://www.youtube.com/@CodeMaster-421)
- **📸 Instagram**: [@quicklifesolutionsofficial](https://www.instagram.com/quicklifesolutionsofficial/)
- **🗓️ Free Consultation**: [Book a call](https://tidycal.com/quicklifesolutions/free-consultation)
- **🛠️ More Tools**: [Explore our Apify actors](https://apify.com/dainty_screw)

### 🆘 Support

- **💬 Discord**: [Raise a support ticket](https://discord.gg/2WGj2PDmHb)
- **📧 Email**: <codemasterdevops@gmail.com>

Happy scraping! 😎🧹✨

# Actor input Schema

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

Provide one or several Telegram channel names you want to scrape the posts from.

## `postsFrom` (type: `integer`):

Lowest post identifier to consider (channels start at 1). Leave empty to fetch from the newest posts backwards.

## `postsTo` (type: `integer`):

Highest post identifier to consider. Leave empty to let the actor work solely with date ranges or max posts limits.

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

Caps how many posts are collected per channel, regardless of ID range (helps when using date filters).

## `fromDate` (type: `string`):

ISO date/time – only posts on or after this timestamp are collected (e.g. 2023-01-01T00:00:00Z).

## `toDate` (type: `string`):

ISO date/time – only posts on or before this timestamp are collected.

## `includeComments` (type: `boolean`):

When enabled, the actor loads the comments thread for each post (if available) and adds it to the output.

## `maxCommentsPerPost` (type: `integer`):

Upper limit of comments collected for each post when comment scraping is enabled.

## `proxy` (type: `object`):

<strong>A proxy server is required to run this actor!</strong> Either use an Apify residential proxy, or provide your own proxy servers. Datacenter proxies will not work.

## Actor input object example

```json
{
  "channels": [
    "mediumcom"
  ],
  "postsFrom": 10,
  "maxPostsPerChannel": 10,
  "includeComments": false,
  "maxCommentsPerPost": 10,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# 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": [
        "mediumcom"
    ],
    "postsFrom": 10,
    "postsTo": 0,
    "maxPostsPerChannel": 10,
    "maxCommentsPerPost": 10,
    "proxy": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("dainty_screw/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": ["mediumcom"],
    "postsFrom": 10,
    "postsTo": 0,
    "maxPostsPerChannel": 10,
    "maxCommentsPerPost": 10,
    "proxy": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("dainty_screw/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": [
    "mediumcom"
  ],
  "postsFrom": 10,
  "postsTo": 0,
  "maxPostsPerChannel": 10,
  "maxCommentsPerPost": 10,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call dainty_screw/telegram-scraper --silent --output-dataset

```

## MCP server setup

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