Before you start
- Get an API keySign up for 100 free credits, no card. Keys start with
gs_live_. - Put it in the environmentEvery example reads it from
GROUNDSOCIAL_API_KEY:export GROUNDSOCIAL_API_KEY=gs_live_… - Set up Python
pip install requests
Call Telegram post API from Python
GET /v1/telegram/posts. Save this as main.py and run python main.py. It prints message.text and message.views.
import os
import requests
API = "https://api.groundsocial.dev"
HEADERS = {"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"}
res = requests.get(
f"{API}/v1/telegram/posts",
params={"url": "https://t.me/durov/552"},
headers=HEADERS,
timeout=60,
)
res.raise_for_status()
data = res.json()
print(data["message"]["text"], data["message"]["views"])
print("credits charged:", res.headers["x-credits-charged"])The response
A real Telegram response to this call, recorded from the live source and shortened for display: arrays keep their first items and … marks every cut. Live calls return current data in the same shape.
{
"message": {
"message_id": 552,
"chat": {
"id": -1001006503122,
"type": "channel",
"username": "durov",
"title": "Pavel Durov"
},
"date": 1791730360,
"date_iso": "2026-10-11T14:52:40.000Z",
"is_edited": false,
"author_signature": "Pavel Durov",
"from": null,
"text": "✨ Designers × AI\n\n🆕 The mockup era is over. Today’s AI tools give every designer a superpower: you can now craft your id…",
"text_html": "<tg-emoji emoji-id=\"5325547803936572038\"><i class=\"emoji\" style=\"background-image:url('//telegram.org/img/emoji/40/E29CA…",
"links": [
"https://t.me/designers"
],
"hashtags": [],
"views": 3980000,
"reactions": [
{
"type": "paid",
"emoji": null,
"custom_emoji_id": null,
"total_count": 10900
},
{
"type": "custom_emoji",
"emoji": null,
"custom_emoji_id": "5936157098181135162",
"total_count": 21800
},
"… 2 more"
],
"forward_origin": {
"type": "channel",
"chat": {
"username": "designers",
"title": "Telegram Designers"
},
"message_id": 266,
"sender_name": null,
"url": "https://t.me/designers/266"
},
"reply_to_message": null,
"media": [
{
"url": null,
"thumbnail_url": "https://cdn4.telesco.pe/file/XeC4MvHbgytJjO49Y2ltkhKjLjjDf88qWvFjRmS836sDH4yHXcEoiW1ocXbC82SniBzoyWGH8fd1j9rsnV9SBuMRHZE…",
"width": null,
"height": null,
"duration": 75,
"title": null,
"performer": null,
"file_size": null,
"emoji": null,
"type": "video"
}
],
"poll": null,
"link_preview": null,
"is_service": false,
"url": "https://t.me/durov/552"
}
}Top-level fields
| Field | Type | Description |
|---|---|---|
message | TelegramMessage | A channel post or a comment, after the Bot API Message object. |
Parameters
| Name | In | Type | Description |
|---|---|---|---|
url (required) | query | string | A public post link, https://t.me/<channel>/<id> (or <channel>/<id>). Example: https://t.me/durov/552. |
Errors and retries
Every error is JSON with error.code (stable: branch on it), message, hint (what to do next), docs_url and retryable. A failed call is never charged. Retry only when retryable is true, after the Retry-After header.
import os, time
import requests
def call(url, **kwargs):
headers = {"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"}
for attempt in range(3):
res = requests.get(url, headers=headers, timeout=60, **kwargs)
if res.ok:
return res.json()
err = res.json()["error"]
# Branch on the stable code; the hint says what to do next.
if err["retryable"] and attempt < 2:
time.sleep(int(res.headers.get("Retry-After", 2)))
continue
raise RuntimeError(f"{err['code']}: {err.get('hint', err['message'])}")
data = call("https://api.groundsocial.dev/v1/telegram/posts", params={"url": "https://t.me/durov/552"})| Status | Meaning |
|---|---|
200 | The post. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | No public Telegram chat or post by that name. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | Telegram is temporarily unavailable. Retryable; nothing was charged. |
Every error code and what to do about it.
Pricing
| Cost | |
|---|---|
| Per call | 1 credit per call |
| 1,000 calls | $1.00 on the starter pack, $0.40 at volume |
| No key (MPP or x402) | $0.01 per call |
| Failed call | Refunded, never charged |
Every response has x-credits-charged and x-credits-remaining headers. Credits never expire. Packs and calculator.
From an AI agent (MCP)
The same call is the telegram_post_get tool on the hosted MCP server, so Claude, Cursor or any MCP client can make it without code. Add the server once:
claude mcp add --transport http groundsocial https://api.groundsocial.dev/mcpThen ask for it in words (“One public Telegram post: text, views, reactions, media, forward and reply”), or call the tool directly:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "telegram_post_get",
"arguments": {
"url": "https://t.me/durov/552"
}
}
}MCP setup for Claude Desktop, Cursor, VS Code and ChatGPT.
Expand Telegram links in your feed
Pass any t.me/<channel>/<id> link; a deleted post answers target_not_found and is not charged.
Questions
Does it include comments?
No, use the post comments endpoint.
Keep going
- This call in JavaScript, TypeScript, Go, PHP, cURL.
- Telegram post API reference: every field and status code.
- Telegram tutorials and all Python tutorials.
- Telegram API: every endpoint and price.
- How to scrape Telegram channel with Python: A public Telegram channel, group or bot: title, bio, exact subscribers, media counts.
- How to scrape Telegram channel posts with Python: A page of a public channel’s posts (20, newest first), or posts matching words.
- How to scrape Telegram comments with Python: Comments on a Telegram channel post, 50 a page, from its discussion group.
Run it on your own data
One key for Telegram and 76 more platforms, over REST or MCP. Free credits on signup, no card.
Telegram is a trademark of Telegram FZ-LLC. We are not affiliated with or endorsed by Telegram.