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.1.4.tar.gz (14.8 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.1.4-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: telegraph_next-1.1.4.tar.gz
  • Upload date:
  • Size: 14.8 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.1.4.tar.gz
Algorithm Hash digest
SHA256 685a3500591613b8d26290e9987720506e54d478c8df4a7875e1de33e1f87263
MD5 ae99c6e97d5e69565a7fee306a4208ab
BLAKE2b-256 84efca8ebeb8bd870bd7420c555d6a1b9eb040276468e67bcc57ab54e7900df5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: telegraph_next-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 13.5 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.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 03c53e036d0713f12ee319a123327013391b2ebd9b8bcd409639fc12a36f6f63
MD5 e2ccfe560ea1621f0414d659c621c86f
BLAKE2b-256 f0a1ed6ad89b83895b7060b2c9663192c4520196d29dc476537d98d59fe6fd54

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