Skip to main content

Welcome to MadelineProto

MadelineProto is a fully async PHP library that allows you to interact with Telegram’s MTProto API directly - without the limitations of the Bot API. Build powerful bots, userbots, and automation tools with the same capabilities as official Telegram clients.
Approved by Telegram! MadelineProto is officially recognized and trusted by Telegram.

Why MadelineProto?

MadelineProto gives you direct access to Telegram’s MTProto protocol, enabling capabilities that go far beyond the standard Bot API:

True MTProto Access

Communicate directly with Telegram’s servers using the same protocol as official apps - no Bot API limitations

Fully Async Architecture

Built on AMPHP for incredible speed and parallel processing. Handle thousands of operations simultaneously

User & Bot Support

Login as a user with phone number, bot with token, or even via QR code. Build userbots and bots with the same codebase

Advanced Features

VoIP calls, secret chats, Stories, 4GB file uploads, custom filters, plugins, and much more

What Can You Build?

Powerful Bots

Create feature-rich Telegram bots with event handlers, filters, and plugins

File Management

Upload and download files up to 4GB with parallel processing and progress tracking

VoIP Integration

Make and receive Telegram voice calls programmatically with audio streaming

Secret Chats

Work with end-to-end encrypted secret chats with full MTProto support

Key Features

  • Full MTProto API Access: Every method available in official Telegram apps
  • Async/Await: Powered by AMPHP v3 and PHP fibers for non-blocking operations
  • Event-Driven Architecture: Handle updates with filters, attributes, and plugins
  • Database Support: Optional MySQL, PostgreSQL, or Redis backend for reduced RAM usage
  • File Operations: Upload/download files up to 4GB with bot API file ID support
  • Prometheus Metrics: Built-in monitoring and metrics collection
  • Docker Ready: Official Docker images for amd64, arm64, and riscv64

Quick Example

Here’s how simple it is to create a bot that responds to messages:
<?php

use danog\MadelineProto\EventHandler\Attributes\Handler;
use danog\MadelineProto\EventHandler\Message;
use danog\MadelineProto\EventHandler\SimpleFilter\Incoming;
use danog\MadelineProto\SimpleEventHandler;

if (!file_exists('madeline.php')) {
    copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
require 'madeline.php';

class MyBot extends SimpleEventHandler
{
    #[Handler]
    public function handleMessage(Incoming&Message $message): void
    {
        $message->reply("Hello from MadelineProto!");
    }
}

MyBot::startAndLoop('bot.madeline');

Real-World Examples

These open-source projects showcase MadelineProto’s capabilities:

Core Components

MadelineProto’s architecture is built on standalone, reusable components:

Ready to Start?

Quick Start

Build your first bot in under 5 minutes

Installation

Install via Composer or PHAR

Requirements

Check system requirements and PHP extensions

API Documentation

Explore the complete API reference

Community & Support

MadelineProto requires PHP 8.2 or higher (64-bit). Make sure your environment meets the requirements before getting started.

Build docs developers (and LLMs) love