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

Scrape public Telegram channels: the profile, follower count, and bio, plus every message with its date, views, and links. Limit it to the last few days or a start date to track what a channel posts.

- **URL**: https://apify.com/tri_angle/telegram-scraper.md
- **Developed by:** [Tri⟁angle](https://apify.com/tri_angle) (Apify)
- **Categories:** Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 5,034 total users, 133 monthly users, 100.0% runs succeeded, 60 bookmarks
- **User rating**: 2.81 out of 5 stars

## Pricing

from $1.25 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

### What does Telegram Scraper do?

Telegram Scraper will enable you to scrape profiles and messages from Telegram in just a couple of seconds.

### Features

**Get Profile** - returns details for the profile, ignores all other content.

**Collect Messages (optional)** - returns messages, it supports text, replies and polls.

### Why scrape Telegram?

Telegram has a large number of users and is a great source of data for various industries and use cases.
If you would like more inspiration on how scraping Telegram could help your business or organization, check out our [industry pages](https://apify.com/industries).

### How to scrape Telegram

It's easy to scrape Telegram with Telegram Scraper. Just follow these few steps:

1. Click on Try for free.
2. Enter the exact profile name you want to scrape.
3. Click on Run.
4. When Telegram Scraper has finished, preview or download your data from the Dataset tab.

### How much will it cost to scrape Telegram?

Apify gives you with $5 free usage credits every month on the [Apify Free plan](https://apify.com/pricing). This Actor is priced per usage. The best course of action is to start a test run and check its running costs once finished.

But if you need to get more data regularly from Telegram, you should grab an Apify subscription. We recommend our [$49/month Starter plan](https://apify.com/pricing).

### Input and Output examples

\[Input]

```
{
    collectMessages: select,
    profiles: array,           		        // Username(s)
	proxyConfigurationOptions: object,
    oldestMessageDate: string,              // Date of oldest messages
	scrapeLastNDays: integer                // Scrape only messages from lst (e.g. 2) days
}
```

\[Output]
1 item/profile with message = null or 1 item/message

```
[{
  "username": "@telegram",
  "fullName": "Telegram News",
  "avatarUrl": "https://cdn1.telesco.pe/file/LW...L9A.jpg",
  "followers": 13,
  "bio": "The official Telegram on Telegram. Much recursion. Very Telegram. Wow.",
  "url": "https://telegram.me/s/telegram",
  "message":
    {
      "fulldate": "2024-08-01T16:13:55.000Z",
      "date": "August 1",
      "views": 4,
      "image": "",
      "video": "",
      "description": "For all the features from our July update like a front flash for video messages and more – check out our latest blog:https://telegram.org/blog/w3-browser-mini-app-storeJuly Features1 • 2 • 3 • 4 • 5 • 6 • More",
      "preview": {
        "link": "https://telegram.org/blog/w3-browser-mini-app-store",
        "text": "Telegram\n  \n  Telegram Browser, Mini App Store, Gifting Stars and More\n  Today's update brings a new in-app browser that supports multiple tabs and makes Web3 available to almost a billion users, a Mini App Store with popular mini apps, the ability to gift Stars to friends, a weather widget for stories – and much more."
      },
      "link": "https://telegram.me/s/telegram/323",
      "reply": "",
      "poll": ""
    },
},
```

# Actor input Schema

## `collectMessages` (type: `boolean`):

Scrape messages of provided profiles.

## `profiles` (type: `array`):

The profiles to look for. Must be exact. You can also provide a link to the profile, e.g. https://t.me/telegram

## `oldestMessageDate` (type: `string`):

Works only when collecting messages. Only messages uploaded after or on this date will be scraped.

## `scrapeLastNDays` (type: `integer`):

Specify how old scraped posts can be (in days). Putting <code>1</code> will get you only today's posts, <code>2</code> - tomorrow's and today's, and so on. If the <code>Post newer than</code> field was set, the most recent post will be chosen.

## Actor input object example

```json
{
  "collectMessages": true,
  "profiles": [
    "telegram"
  ]
}
```

# 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 = {
    "profiles": [
        "telegram"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tri_angle/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 = { "profiles": ["telegram"] }

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

```

## MCP server setup

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