MarkdownCopies this page as Markdown, ready to paste into an AI assistant.
Telegram API
3 Telegram endpoints behind one key, priced in credits per call and routed to the cheapest healthy source.
On this page
Social · 3 endpoints · from 1 credit per call
Endpoints
- POSTTelegram Channel
/v1/run/telegram.channelPublic Telegram channel profile: title, description, avatar, verified badge, subscriber count and media counters.1 creditper call - POSTTelegram Channel Posts
/v1/run/telegram.channel_postsLatest public posts of a Telegram channel with text, time, views, reactions, media and link previews; pages back by cursor.1 creditper call - POSTTelegram Post
/v1/run/telegram.postOne public Telegram channel post by its t.me link: text, time, views, reactions, media and link preview.1 creditper call
Calling them
Every endpoint on this page is one POST to https://api.primaryapi.com/v1/run/{sku} with your API key and a JSON body. Responses share one envelope, so code written for one endpoint handles the others. For example, telegram.channel:
curl -sS -X POST "https://api.primaryapi.com/v1/run/telegram.channel" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"handle":"telegram"}'const res = await fetch('https://api.primaryapi.com/v1/run/telegram.channel', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRIMARYAPI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
handle: 'telegram',
}),
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.code}: ${body.error}`);
// found:false is a successful answer ("does not exist"), not an error
console.log(body.output.found ? body.output.data : body.output.reason, body.credits);import os
import requests
res = requests.post(
"https://api.primaryapi.com/v1/run/telegram.channel",
headers={"Authorization": f"Bearer {os.environ['PRIMARYAPI_API_KEY']}"},
json={
"handle": "telegram",
},
timeout=60,
)
body = res.json()
if not res.ok:
raise RuntimeError(f"{body['code']}: {body['error']}")
# found=False is a successful answer ("does not exist"), not an error
print(body["output"]["data"] if body["output"]["found"] else body["output"]["reason"], body["credits"])New to PrimaryAPI? Start with the Quickstart, then read Making requests.