tgcalls 0.2.0-beta1

An elegant Rust client for Telegram voice and video calls.
docs.rs failed to build tgcalls-0.2.0-beta1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: tgcalls-0.0.0

TgCalls Crates.io Downloads

TgCalls brings voice and video calling to Telegram clients written in Rust. It bridges Telegram's calling stack with a clean Rust API, making it easy to stream media, join voice chats, and integrate voice and video calling into your Telegram clients.

Whether you're building a music bot, a voice assistant, or any application that needs to participate in Telegram calls, TgCalls gets you there with a simple and ergonomic API.

Getting Started

Add tgcalls to your Cargo.toml:

[dependencies]
tgcalls = "0.2"

Before using tgcalls, make sure you have:

  • FFmpeg available on your PATH for media decoding.
  • A C++ toolchain and development libraries required to build NTgCalls.

On Debian/Ubuntu:

sudo apt install build-essential zlib1g-dev ffmpeg

Examples

To try the examples:

git clone https://github.com/ankit-chaubey/tgcalls.git
cd tgcalls

export API_ID=123456
export API_HASH=your_api_hash_here

cargo run --example group_audio_call -- -1001234567890 /path/to/song.mp3

On the first run, you'll be asked to sign in with your phone number and login code. Your session is then saved locally, so you only need to authenticate once.

Let's Stream

Joining a group call and playing a file takes just a few lines:

let calls = Calls::new(client);
calls.play(chat_id, "song.mp3").await?;

Behind the scenes, TgCalls handles everything required to get your media into the call. It creates or joins the group call, establishes the media connection, negotiates with Telegram, and streams your audio or video through FFmpeg. All you need to provide is the client, the chat, and the media you want to play.

To leave the call:

calls.leave(chat_id).await?;

Let's go through the examples to see it in action:

cargo run --example group_audio_call -- -1001234567890 /path/to/song.mp3

Direct, one-on-one calls work the same way in spirit, ring someone, exchange keys, stream, though the setup underneath is a little more involved since P2P calls are end-to-end encrypted and need a live signaling loop while connecting. The p2p_audio_call example walks through it end to end.

Video and screen share follow the same pattern, Media::video, Media::av, and Media::screen build the right ffmpeg pipeline for you. The examples/ folder has a short, working file for each of these, that's genuinely the fastest way to see how it all fits together.

Credits

TgCalls wouldn't exist without these projects and the people behind them.

License

Licensed under either the MIT License or the Apache License 2.0, at your option.