| Crates.io | frankenstein |
| lib.rs | frankenstein |
| version | 0.45.0 |
| created_at | 2021-03-13 13:39:49.566585+00 |
| updated_at | 2025-09-25 13:03:28.315667+00 |
| description | Telegram bot API client for Rust |
| homepage | |
| repository | https://github.com/ayrat555/frankenstein |
| max_upload_size | |
| id | 368283 |
| size | 716,063 |

Telegram bot API client for Rust.
It's a complete wrapper for Telegram bot API, and it's up-to-date with version 9.2 of the API.
Frankenstein's data structures (Rust structs and enums) are mapped one-to-one from Telegram bot API types and method parameters.
Run cargo add frankenstein or add the following to your Cargo.toml.
[dependencies]
frankenstein = { version = "0.45", features = [] }
You likely want to use either a blocking or an async client. Enable it via the Features.
Without enabling any additional features this crate will only ship with Telegram types.
client-ureq - a blocking HTTP API client based on ureqtrait-sync - a blocking API trait, it's included in the client-ureq feature. It may be useful for people who want to create a custom blocking client (for example, replacing an HTTP client)client-reqwest - an async HTTP API client based on reqwest. This client partially supports wasm32, but file uploads are currently not supported there.trait-async - an async API trait, it's used in the client-reqwest. It may be useful for people who want to create a custom async clientFor example for the async client add the following line to your Cargo.toml file:
frankenstein = { version = "0.45", features = ["client-reqwest"] }
Examples in this section use the blocking client (frankenstein::Api), but async examples would look the same (just replace frankenstein::Api with frankenstein::AsyncApi)
All types described in the API docs have direct counterparts in the Frankenstein. For example, in the docs there is the user type:
id Integer Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
is_bot Boolean True, if this user is a bot
first_name String User's or bot's first name
last_name String Optional. User's or bot's last name
username String Optional. User's or bot's username
language_code String Optional. IETF language tag of the user's language
can_join_groups Boolean Optional. True, if the bot can be invited to groups. Returned only in getMe.
can_read_all_group_messages Boolean Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
supports_inline_queries Boolean Optional. True, if the bot supports inline queries. Returned only in getMe.
In Frankenstein, it's described like this:
pub struct User {
pub id: u64,
pub is_bot: bool,
pub first_name: String,
pub last_name: Option<String>,
pub username: Option<String>,
pub language_code: Option<String>,
pub can_join_groups: Option<bool>,
pub can_read_all_group_messages: Option<bool>,
pub supports_inline_queries: Option<bool>,
}
Optional fields are described as Option.
Every struct can be created with the associated builder. Only required fields are required to set, optional fields are set to None when not provided:
use frankenstein::methods::SendMessageParams;
let send_message_params = SendMessageParams::builder()
.chat_id(1337)
.text("hello")
.build();
#![cfg(feature = "client-ureq")]
use frankenstein::TelegramApi;
use frankenstein::client_ureq::Bot;
use frankenstein::methods::{GetUpdatesParams, SendMessageParams};
use frankenstein::types::AllowedUpdate;
let token = "123:ABC";
let bot = Bot::new(token);
// Send a message
let send_message_params = SendMessageParams::builder()
.chat_id(1337)
.text("hello")
.build();
let result = bot.send_message(&send_message_params);
// or get the updates (= interactions with the bot)
let update_params = GetUpdatesParams::builder()
.allowed_updates(vec![AllowedUpdate::Message])
.build();
let result = bot.get_updates(&update_params);
Every function returns a Result with a successful response or failed response.
See more examples in the examples directory.
Some methods in the API allow uploading files. In the Frankenstein for this FileUpload enum is used:
pub enum FileUpload {
InputFile(InputFile),
String(String),
}
pub struct InputFile {
path: std::path::PathBuf
}
It has two variants:
FileUpload::String is used to pass the ID of the already uploaded fileFileUpload::InputFile is used to upload a new file using multipart upload.Frankenstein implements all Telegram bot API methods. To see which parameters you should pass, check the official Telegram Bot API documentation or docs.rs/frankenstein
You can check out real-world bots created using this library:
git checkout -b my-new-feature)git commit -am 'Add some feature')git push origin my-new-feature)Ayrat Badykov (@ayrat555)