TGMarket

API documentation

REST API v1 for searching and exporting Telegram channels. JSON, cursor pagination, the same filter schema as the UI and exports. The machine-readable schema is the backend OpenAPI (/openapi.json).

Authentication

Create a key in Dashboard → API keys (Premium and Super plans). Key format: mk_live_<prefix>_<secret>, shown only once. Send it in the header:

Authorization: Bearer mk_live_ab12cd34_xxxxxxxxxxxxxxxx
# or
X-API-Key: mk_live_ab12cd34_xxxxxxxxxxxxxxxx

Scopes: read (default) and export — for POST /v1/exports. At most two active keys, so you can rotate without downtime.

Billing

You pay for data returned, not for calls. Everything is charged in credits: 1 credit = $0.001.

  • Each paid request — 1 credit ($1 per 1,000 requests).
  • Each channel row — at the field-set rate: Base 0.5 credits, +Metrics 1.5, +Ads 2, History 3.
  • Each post — 0.5 credits.
  • A channel this key already paid for within 30 days is returned for free.
  • /count and facets — request fee only.

The amount charged is returned in the X-Credits-Charged header. Balance and usage — GET /v1/usage. Export prices — see pricing.

Endpoints

MethodPathDescriptionCost
GET/v1/categoriesCategory treefree
GET/v1/languagesLanguages with channel countsfree
GET/v1/usageBalance, daily usage, limitsfree
POST/v1/channels/searchFilters + q, cursor, up to 100 per pagerequest + rows
POST/v1/channels/countCounts and facetsrequest
GET/v1/channels/{id|username}Channel card (?fields=base,metrics,ads)request + row
GET/v1/channels/{id}/historyDaily subscribers & metrics (?days=)request + History
GET/v1/channels/{id}/postsRecent posts (?limit= up to 100)request + posts
GET/v1/channels/{id}/referencesCited by / citesrequest + rows
POST/v1/posts/searchFull-text post searchrequest + posts
POST/v1/exportsAsync export (export scope)export price
GET/v1/exports/{id}Status and download linkfree

Filters (ChannelQuery)

The query object is the same for /channels/search, /channels/count and /exports. Omit empty fields.

qstringtext: title, username, description, posts
category_ids / exclude_category_idsint[]categories (areas or subcategories)
channel_idsint[]specific channels
languagesstring[]language codes: ru, en, uk…
kindall | channel | grouptype
subscribers_min / subscribers_maxintsubscribers
avg_views_min, reach_24h_minnumberviews and 24h reach
er_min, err_24h_minnumberER / ERR, %
growth_7d_min, growth_30d_min, growth_pct_30d_minnumbergrowth
posts_30d_min, last_post_afterint, dateactivity
created_after / created_beforedatecreation date
has_ads_contact, ad_share_maxbool, 0..1ads
fraud_max0..1fraud score threshold
verified_only, exclude_scamboolflags (exclude_scam=true by default)
sort, orderstringsame values; desc|asc

Examples

Search channels

curl -X POST https://api.tgmarket.example/v1/channels/search \
  -H "Authorization: Bearer $MK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": {"q": "stock market", "languages": ["en", "hi"], "subscribers_min": 5000, "sort": "growth_30d"},
    "fields": ["base", "metrics"],
    "limit": 100
  }'

Response:

{
  "items": [{"id": 2365318039, "username": "GPTronhub", "title": "…", "subscribers": 169432, "er": 0.16, …}],
  "total": 605,
  "next_cursor": "eyJoIjoi…"   // pass as cursor in the next request
}

Count only

curl -X POST https://api.tgmarket.example/v1/channels/count -H "Authorization: Bearer $MK_KEY" \
  -H "Content-Type: application/json" -d '{"query": {"category_ids": [21]}}'

Card and history

curl "https://api.tgmarket.example/v1/channels/durov?fields=base,metrics" -H "Authorization: Bearer $MK_KEY"
curl "https://api.tgmarket.example/v1/channels/1006503122/history?days=90" -H "Authorization: Bearer $MK_KEY"

Export

curl -X POST https://api.tgmarket.example/v1/exports -H "Authorization: Bearer $MK_KEY" -H "Content-Type: application/json" \
  -d '{"query": {"q": "crypto"}, "fields": ["base","metrics"], "format": "csv", "row_limit": 20000}'
# → {"export_id": "…", "rows": 20000, "price_credits": 32000, "status": "queued"}

curl https://api.tgmarket.example/v1/exports/<export_id> -H "Authorization: Bearer $MK_KEY"
# → {"status": "done", "progress": 100, "download_url": "https://…", …}

Rate limits

  • Premium — 1 request per second, Super — 10, Enterprise — by contract.
  • Every response includes X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.
  • Beyond 10,000 results per query — use /v1/exports.
  • A hard daily cap on unique channels per key; exceeding it freezes the key until manual review.

Errors

All errors share one format:

{"error": {"code": "payment_required", "message": "…"}}
  • 401 invalid_api_key — invalid or revoked key
  • 402 payment_required / 402 insufficient_funds — balance exhausted, top up in the dashboard (need/have in the body)
  • 403 api_not_in_plan, 403 scope_required, 403 key_frozen, 403 ip_not_allowed
  • 429 rate_limited — RPS exceeded; wait the number of seconds in Retry-After
  • 400 too_deep, 400 bad_cursor, 422 — invalid parameters