| [ Web Proxy ] |
| Viewing: https://gotd.dev | [Back] [Original] |
Telegram client in Go
A full MTProto 2.0 API client in pure Go for users and bots the same protocol the official apps and TDLib speak, with batteries-included helpers for auth, uploads, downloads and updates.
go get github.com/gotd/td@latest
client.API().package main
import (
"context"
"github.com/gotd/td/telegram"
)
func main() {
// Get api_id and api_hash from https://my.telegram.org/apps.
client := telegram.NewClient(appID, appHash, telegram.Options{})
if err := client.Run(context.Background(), func(ctx context.Context) error {
// The client is connected only while this function runs.
api := client.API()
// Call any of the 781 MTProto methods directly.
dc, err := api.HelpGetNearestDC(ctx)
if err != nil {
return err
}
_ = dc
return nil
}); err != nil {
panic(err)
}
}
See the first-client guide and echo bot tutorial to go further.
| Web Proxy Viewer | New URL | Original Page |