gogramgogram

The Telegram MTProto library for Go.

gogram is a complete Telegram client written in pure Go. Build bots, automate accounts, mirror channels, run userbots, ship anything Telegram can do — without leaving the language.

Install
$ go get github.com/amarnathcjd/gogram/telegram
Smallest possible bot
Three real API calls, twelve real lines. No magic. The client connects over MTProto, signs in as the bot, and posts a message to the bot's own Saved Messages.
main.go
package main

import (
	"github.com/amarnathcjd/gogram/telegram"
)

func main() {
	client, _ := telegram.NewClient(telegram.ClientConfig{
		AppID:   123456,
		AppHash: "your-app-hash",
		Session: "session.dat",
	})

	if err := client.Connect(); err != nil {
		panic(err)
	}

	client.LoginBot("123:abc")
	client.SendMessage("me", "hello from gogram")
}
package main

import (
	"github.com/amarnathcjd/gogram/telegram"
)

func main() {
	client, _ := telegram.NewClient(telegram.ClientConfig{
		AppID:   123456,
		AppHash: "your-app-hash",
		Session: "session.dat",
	})

	if err := client.Connect(); err != nil {
		panic(err)
	}

	client.LoginBot("123:abc")
	client.SendMessage("me", "hello from gogram")
}
What you get

A complete client. Not a wrapper.

Everything below is real, shipping today. Nothing you have to bring yourself.

Pure MTProto

Speaks Telegram's real protocol over TCP or WebSocket. No HTTP Bot API, no hidden HTTP hops, no leaky abstractions.

wire.mtproto
layer 2272,371 constructors · 606 error codes
Transport
TCP · wss
Framing
obfuscated2
Auth
DH + PFS

Bots and users

Same client, same surface. Log in with a token, phone, or QR.

bot.log

Updates dispatcher

Type-safe handlers. Filters. Middleware. Conversations. All in one dispatcher.

on/start→ command
onmessage:hi→ msg
oncallback:vote:*→ callback
oninline:*→ inline

Five data centres

Automatic DC migration. Persistent per-DC senders for parallel file transfer.

DC1 · DC2 · DC3 · DC4 · DC5

Real performance

Parallel exported senders. Auto-reconnect. Flood-wait handling. DC migration baked in.

download19.2MB/s
upload19.7MB/s
ping55ms
ram11.7MB

Portable sessions

File, base64 string, in-memory, or AES-encrypted. Move between hosts freely.

string session
AgSDBQVGdVBqAAA...9Xf8b7lwEDN4pIcqU
Which auth flow do I need?

Pick a lane, get the call.

Use this
client.LoginBot(token)

A single API call. BotFather issues the token, gogram calls auth.importBotAuthorization, and the session file caches the auth key for every subsequent run.

Bot login docs
Also in this site

More than docs.

This site bundles the live TL schema reference for layer 227, every RPC error gogram knows about with hand-written explanations, and a browser-based tools that benchmarks Telegram's data centres in WebAssembly.