Skip to main content

Modernized Asynchronous Telegraph API wrapper (revived fork)

Project description

🚀 Telegraph-Next

Modern, High-Performance Asynchronous Telegraph API Wrapper

PyPI License Stars Python


Quick StartKey FeaturesInstallationBug Report

🌟 Why Telegraph-Next?

Telegraph-Next is a revitalized, async-first wrapper for the Telegra.ph API. We took the robust foundation of the original project and upgraded it for the modern era of high-load Telegram bots and scalable services.

✨ Key Features

  • ⚡ Fully Asynchronous: Built from the ground up on aiohttp for non-blocking performance.
  • 🛡️ Pydantic-Powered: Every response is a validated object. Get full IDE autocompletion and type safety.
  • 🌐 Native DPI Bypass: Built-in direct IP routing (149.154.164.13) bypasses ISP SNI blocks natively without proxies.
  • 🖼️ Universal Image Uploads: upload_file() uses catbox.moe as a highly-reliable fallback due to Telegraph's global upload restrictions.
  • 🎞️ Smart HTML Middlewares: Automatic YouTube iframe handling and HTML tag filtering out of the box.
  • 🧼 Clean & Fixed: Zero resource leaks, fixed YouTube parsing bugs, and restored missing dependencies.
  • 🧩 Easy Integration: Designed as a drop-in modernization for high-load systems.

📦 Installation

Install the latest version via pip:

pip install telegraph-next

🛠 Quick Start

1. Basic Usage (Classic)

import asyncio
from telegraph import Telegraph

async def main():
    # Initialize the client
    telegraph = Telegraph()
    
    # Create an account
    await telegraph.create_account(short_name='Abbasxan', author_name='Abbasxan')
    
    # Create a new page with HTML content
    page = await telegraph.create_page(
        title='My First Page',
        content_html='<h1>Hello!</h1><p>Created using <b>Telegraph-Next</b>.</p>'
    )
    
    print(f"Page live at: {page.url}")

asyncio.run(main())

2. Using Context Manager (Recommended)

async with Telegraph() as tg:
    await tg.create_account(short_name='Abbasxan')
    page = await tg.create_page('Modern Way', content_html='<i>Seamless!</i>')
    print(page.url)

3. File Uploading (Catbox Fallback)

Due to Telegraph's servers blocking native uploads globally, telegraph-next natively falls back to catbox.moe for ultra-reliable image uploads.

async def upload_demo():
    # Returns an UploadedFile object containing the full URL
    uploaded = await telegraph.upload_file('photo.jpg')
    
    # Note: Returns the FULL url, so do not prepend https://telegra.ph!
    print(f"File uploaded to: {uploaded.src}") 

🚀 Advanced: HTML Middlewares

Telegraph-Next automatically processes your HTML to ensure it matches Telegra.ph's strict rules:

  • Converts YouTube links to supported embeds.
  • Strips unsupported attributes while keeping src and href.
  • Unwraps unsupported tags to preserve content.

🤝 Credits & Support

Developed and maintained by Abbasxan (Neon Group).
Original concept by IvanProgramming.

If you find this project useful, please give it a ⭐ on GitHub!


Licensed under MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telegraph_next-1.2.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telegraph_next-1.2.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file telegraph_next-1.2.0.tar.gz.

File metadata

  • Download URL: telegraph_next-1.2.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for telegraph_next-1.2.0.tar.gz
Algorithm Hash digest
SHA256 2fb96194f0968365e1d0b76bb7dce95f8f84a938feb1e50ac17994967ff13bd7
MD5 b1f1e0d7fc6c94033b423879c2df0f1d
BLAKE2b-256 ffb9ab9c5dc2c1ba9534c2b9f19cc003014a3f74c03a0ba4291248c6ccf5060e

See more details on using hashes here.

File details

Details for the file telegraph_next-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: telegraph_next-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for telegraph_next-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90d680f24ffc1cdde26132366a9cf4a73c2dec7d6e02d4f9fab7ae5e500a7469
MD5 2581338b015176d4e1a1c45eb483d4ba
BLAKE2b-256 85d5822b9c1d4cdfa92b671c3254b09a391bc215f15fa4760114b06728c3671b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page