FAQ
Quick answers to the questions that come up early. If yours is not here, the source on GitHub usually has the answer in 200 lines or fewer.
gogram vs Bot API vs TDLib
Common questions
Use the HTTP Bot API if its features cover your need. It is genuinely simpler. gogram is for when they do not: user accounts, large files, raw updates, low-level TL methods, no polling overhead, no per-request HTTP cost.
Default to bot. Use a user account only when something you need is bot-restricted: reading old chat history, joining channels on its own, voting in polls, performing contact lookups, posting stories.
Yes. Export with ExportStringSession, paste into a fresh client on another host with the same api id/hash, and you are signed in there too. No code change needed.
Re-authenticate. For bots that means another LoginBot with the same token. For users, the full code/2FA flow again. The old auth key is dead either way.
One of these usually explains it:
- You changed (or someone added) the 2FA password. Every other session was terminated.
- Two processes were using the same session and Telegram killed both.
- The user manually revoked the session from the official client.
- The account was banned.
Re-authenticate to start over. To pre-emptively cull stale sessions:
// raw TL methods on the generated surface
auths, _ := client.AccountGetAuthorizations()
for _, a := range auths.Authorizations {
if a.Current { continue }
_, _ = client.AccountResetAuthorization(a.Hash)
}// raw TL methods on the generated surface
auths, _ := client.AccountGetAuthorizations()
for _, a := range auths.Authorizations {
if a.Current { continue }
_, _ = client.AccountResetAuthorization(a.Hash)
}Latency-bound by the round-trip to Telegram's DC. Throughput-bound by your network and gogram's parallel sender pool. Benchmark from your specific deployment with the Tools— runs in the browser via WASM and gives per-DC ping and 100 MB download numbers in under a minute.
Yes. Pure Go, no CGo, builds and runs natively on Windows, macOS, Linux, BSDs.
Yes, via GOOS=js GOARCH=wasm. Browsers do not have raw TCP, so set UseWebSocketTLS: true. There is no disk in the WASM build, so use MemorySession or StringSession. The Tools page on this site is a live example.
TDLib is C++ with a heavy build and a C-binding layer. It works fine. Reasons to prefer gogram: pure Go (no CGo), idiomatic API rather than a TDLib-style command/event queue, smaller binary, easier to vendor, easier to read the source.
Reasons to prefer TDLib: official, broader feature coverage of recent additions, mature.
