Skip to main content
Gogram Logo

Overview

Gogram is a modern, elegant and concurrent MTProto API framework. It enables you to easily interact with the main Telegram API through a user account (custom client) or a bot identity (bot API alternative) using Go.
Gogram is currently in its stable release stage. While there may still be a few bugs, feel free to use it and provide feedback if you encounter any issues or rough edges. 😊

Setup

Please note that gogram requires Go 1.18 or later to support go-generics.
go get -u github.com/amarnathcjd/gogram/telegram

Verify Installation

package main

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

func main() {
    fmt.Println(telegram.Version, telegram.ApiVersion)
}

Quick Start

New to Go? Check out Go by Example for a quick introduction to the language.
package main

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

func main() {
    client, err := telegram.NewClient(telegram.ClientConfig{
        AppID: 6, AppHash: "<app-hash>",
    })

    if err != nil {
        log.Fatal(err)
    }

    client.Conn() // important, establishes connection to Telegram servers

    // Login as bot or user
    client.LoginBot("<bot-token>") 
    // or client.Login("<phone-number>") for user account
    // or client.AuthPrompt() for interactive login

    // Handle incoming messages
    client.On(telegram.OnMessage, func(message *telegram.NewMessage) error {
        message.Reply("Hello from Gogram!")
        return nil
    }, telegram.FilterPrivate) // waits for private messages only

    client.Idle() // block main goroutine until client is closed
}

Learn More

Why Gogram?

Written entirely in Go with no external dependencies. Native MTProto implementation means you get full access to Telegram’s features without limitations.
Leverages Go 1.18+ generics for compile-time type safety. Clean, intuitive API design that follows Go best practices.
Built for concurrent operations with goroutines. Efficient connection pooling and automatic flood control. Optimized for both bots and user clients.
Full MTProto protocol support including file transfers, media handling, inline bots, payments, and all Telegram features. Regular updates to support new Telegram features.

Features

Type-Safe

Full type safety with Go’s strong typing system.

Concurrent

Built for concurrent operations and high performance.

Modern API

Clean, intuitive API that’s easy to use.

MTProto Native

Full native implementation of MTProto protocol.