Blog / API guides

Telegram Scraper or API: What You Get

A Telegram scraper is a program that fetches public channel pages, pulls each post out of what comes back, and pages back through older posts on a schedule. You build and maintain the fetching, the parsing and the history walk yourself. The alternative is four Telegram endpoints that return channel details, a channel's posts, search inside a channel and single posts as JSON, at 1 credit per successful call. All four are restricted, so this post compares the two routes for aggregate work on public channels and topics.

What does building a Telegram scraper involve?

Building a Telegram scraper means writing code that fetches a public channel's content, finds each post in the response, and walks backwards through older posts until it reaches the last one you stored. Then it has to run again tomorrow, pick up only what's new, and store everything without duplicates. That is four pieces of code, and each one needs upkeep for as long as the scraper runs.

The fetcher

The fetcher requests a channel's content, waits for a response, and retries when something goes wrong. At low volume that's a loop with requests and a sleep. At higher volume, with dozens of channels on a schedule, you need queueing, back-off and a way to spread requests over time. Any large platform has to separate people from automated traffic, so a scraper should expect slow responses, errors and blocks. When that happens, stop: getting around a site's protections with proxy rotation or fake accounts is not a fix we'd recommend.

The parser and the history walk

The parser turns markup into rows: post text, time, media links, view or reaction counts if you keep them. Markup changes as a platform ships features, so a parser that worked last month can return empty fields today without raising an error. The history walk adds its own logic: how to ask for older posts, when to stop, and how to resume after a crash without skipping or repeating posts.

The monitor and the rules

A scraper rarely fails loudly. It returns fewer posts, or posts with blank text, and nobody notices for a week. So you add checks on row counts and empty fields per channel per run. Before you build any of it, read Telegram's terms and the law where you operate, and get legal advice if the project is commercial. For the general case of when writing a scraper pays off, Web Scraping with Python is a practical starting point.

What do the Telegram endpoints return?

The Telegram API returns public channel data as JSON, one call per lookup. It has 4 endpoints, all GET, all 1 credit per successful call, and every one is keyed on a channel username. Between them they cover the four jobs a channel scraper does: look up a channel, list its posts, search inside it, and fetch one post. Data is collected from publicly available sources and returned as found at the time of the call.

Endpoint Returns Required Optional
/v1/telegram/channels Channel details username none
/v1/telegram/channels-posts A channel's posts username before
/v1/telegram/channels-search Search results inside a channel username, q none
/v1/telegram/posts One post username, post_id context

A channel lookup is one request with your key in the X-API-Key header:

curl "https://api.perceptlayer.com/v1/telegram/channels?username=telegram" \
  -H "X-API-Key: $API_KEY"

We don't have a recorded response for this API, so this post doesn't show one or name response fields. Run the call in the playground on the Telegram API page to see the exact JSON before you write code that reads it.

Which parameters do the endpoints take?

Every endpoint takes username, a string naming the public channel. channels-search adds q, a string of up to 256 characters. posts adds post_id, a string, and an optional boolean context. channels-posts takes an optional integer before. The reference documents types and limits only, not defaults, page sizes or what before counts from, so test before and context in the playground before you build paging or a thread view on them.

Here is the same pattern in Python, searching one channel for a topic and printing the credit headers every successful response carries:

import os
import requests

resp = requests.get(
    "https://api.perceptlayer.com/v1/telegram/channels-search",
    params={"username": "telegram", "q": "update"},
    headers={"X-API-Key": os.environ["API_KEY"]},
    timeout=30,
)
print(resp.status_code)
print(resp.headers.get("X-Credits-Used"), resp.headers.get("X-Credits-Remaining"))

Which terms apply to the restricted endpoints?

All 4 Telegram endpoints are restricted. They work once you accept the restricted-endpoint terms in the dashboard; the terms are at /legal/restricted-endpoints. Those terms don't permit collecting personal data without a lawful basis, and they don't permit using data from these endpoints to contact people. That rules out building lists of channel members or commenters, outreach, and following what individuals post.

What fits is aggregate work on public channels and topics. Count how often a product, a market term or an incident comes up across a set of news and industry channels. Archive what a brand's own channel publishes. Compare how much coverage a topic gets week by week. If a response carries names or handles of people you don't need, drop them before you store anything. A call made before accepting the terms returns restricted_endpoint (403); the errors docs cover it with the other codes.

How do a scraper and the endpoints compare?

A scraper gives you full control and no per-call bill, and costs you upkeep, block risk and the work of reading the platform's rules. The endpoints give you JSON from four documented paths at 1 credit a call, and the restricted-endpoint terms decide what you may do with the data. The table compares them for a recurring job, such as polling a set of public channels every day.

DIY Telegram scraper Telegram endpoints
Setup Fetcher, parser, history walker, storage, monitoring API key in the X-API-Key header
What you get Whatever you can parse from each response JSON from 4 documented endpoints
Channel posts Parsed and paged by your own code channels-posts with username, optional before
Search inside a channel Parse everything, then filter locally channels-search with q up to 256 characters
When markup changes Your parser breaks and you fix it No parser of yours to fix
Blocks and errors Yours to handle at volume A failed call returns an error code and costs 0
Speed As fast as you can fetch without being blocked 1 request a second free, at least 5 a second paid
Terms The platform's terms and local law Restricted-endpoint terms; no personal data without a lawful basis
Cost Hosting and engineering time 1 credit per successful call

What does tracking a channel cost per day?

On the endpoints, cost follows calls, not posts. One channels-posts call per channel per day costs 1 credit, so a channel costs 1 credit a day however many posts it published. Polling 25 public news and industry channels once a day is 25 calls × 1 credit = 25 credits a day, or 25 × 30 = 750 credits a month.

The 100 free credits you get after verifying an email address, with no credit card, cover that plan for 100 ÷ 25 = 4 days. Add a weekly channels-search for 4 topic terms in each of the 25 channels, and you add 25 × 4 × 4 = 400 calls a month, for 1,150 credits. The Starter pack's 10,000 covers 8 months of that; purchased credits last 12 months, with no subscription. Failed calls cost nothing and return X-Credits-Used: 0. See pricing for what credits cost and the credits docs for how each call is billed.

Which route should you choose?

Choose by what you'll do with the data and how often you need it, because that decides whether upkeep or per-call cost dominates. The verdicts below assume aggregate work on public channels and topics, the uses the restricted-endpoint terms allow. If your plan involves profiling, tracking or contacting individuals, neither route is the answer.

  • Topic and market tracking across public channels: poll channels-posts once a day per channel and count your terms in what you store. One credit per channel per day.
  • Finding past coverage of a topic in a known channel: call channels-search with the channel's username and your q, instead of paging through its whole history.
  • Archiving a brand's own channel: call channels-posts on a schedule and store the posts with the run date; test before in the playground to see how it pages back.
  • Citing or checking one specific post: call posts with username and post_id.
  • An AI agent answering questions about public channels: connect the MCP server at https://perceptlayer.com/mcp, where search_endpoints and get_endpoint cost nothing and call_endpoint spends credits only on success. The AI agents docs cover setup.
  • A one-off look at three channels: open them in Telegram and skip both routes.
  • Learning how scraping works: practise on a test site, not a messaging platform.

For the same trade-off on other social sources, Twitter Scraper or X API and Instagram Scraper or API cover those, and the social media APIs list the rest. To check the fields first, run channels-posts on a public channel in the playground on the Telegram API page, then get a free API key when they fit.

APIs in this post

Frequently asked questions

It depends on where you operate, what you collect and how you use it, and Telegram's own terms set out what the platform allows. Public channel posts about brands, markets and topics are lower risk than data about individuals, which is personal data in many places. Read the terms, get legal advice for commercial use, and don't get around blocks or protections.

Can I collect data about channel members or individual users?

No. All 4 Telegram endpoints are restricted, and the restricted-endpoint terms don't permit collecting personal data without a lawful basis or using data from these endpoints to contact people. Use them for public channels and topics in aggregate, and drop names and handles you don't need before you store results.

How many credits does a Telegram call cost?

Each of the 4 Telegram endpoints costs 1 credit per successful call. A failed call costs nothing and returns X-Credits-Used: 0. Every successful response carries X-Credits-Used and X-Credits-Remaining. Every account gets 100 free credits once, after verifying an email address, and prepaid packs start at 10,000 credits.

How fast can I poll a list of channels?

Limits are per account, shared by all its keys, and counted per minute. A free account gets 1 request a second (60 a minute), so a 25-channel daily poll finishes in under a minute. Paying accounts run at least 5 a second. A 429 rate_limited reply carries a Retry-After header. The rate limits docs cover the headers.

Can I see a Telegram response before writing code?

Yes. The Telegram API page has a playground: pick an endpoint, fill in its parameters and run a real call with your key to see the JSON it returns. Do this before you write a parser, since this post doesn't include a recorded response and the fields are best read from a real call.

  1. Threads Scraper or API: What You Get

    A DIY Threads scraper versus 8 Threads endpoints at 1 credit a call: keyword search, topic tags, brand posts, upkeep, terms and the cost per tag tracked.

  2. Bluesky API: Public Posts and Feeds as JSON

    Search public Bluesky posts as JSON with likeCount, repostCount, replyCount and langs per post, at 1 credit a call. All 15 endpoints are restricted.

  3. Pinterest Scraper or API: What You Get

    A DIY Pinterest scraper versus 6 Pinterest endpoints at 1 credit a call: pin search, board pins, upkeep, terms and the credits per search term tracked.

Start with 100 free credits

No password to set. We email you a sign-in link, and your key works on every API.

No credit card. 100 free credits on signup.