Skip to main content

YTelegraph

PyPi Package Version Supported Python versions PyPi downloads PyPI Downloads PyPi status License

YTelegraph is a simple, user-friendly Python wrapper for the Telegraph API. Publish your content to Telegraph with just a few lines of code!

Table of Contents

Installation

pip install your-telegraph

Quick Start

Publish a Telegraph page in just 4 lines of code:

from ytelegraph import TelegraphAPI

ph = TelegraphAPI()
content = "# Hello, Telegraph!\n\nThis is my first Telegraph page using YTelegraph."
ph_link = ph.create_page_md("My First Page", content)
print(f"Your page is live at: {ph_link}")

That's it! No need to worry about tokens, account creation, or complex API calls.

Key Features

  • Simple: Create and publish Telegraph pages with minimal code.
  • Markdown Support: Write your content in Markdown and let YTelegraph handle the conversion.
  • Flexible Token Management: Use your own token or let YTelegraph handle account creation.
  • Full API Access: For advanced users, complete access to Telegraph API features is available.

Why YTelegraph?

"All you need is a title and content. That's it. Just like https://telegra.ph/, but in Python."

YTelegraph brings the simplicity of Telegraph's web interface to your Python projects. Whether you're creating a bot, a content management system, or just want to quickly publish some content, YTelegraph makes it easy.

More Examples

Create a page from a Markdown file

from ytelegraph import TelegraphAPI

ph = TelegraphAPI()

with open('my_article.md', 'r') as f:
    content = f.read()

ph_link = ph.create_page_md("My Article", content)
print(f"Article published at: {ph_link}")

Use your own Telegraph token

from os import environ
from ytelegraph import TelegraphAPI

TELEGRA_PH_TOKEN = environ.get("TELEGRA_PH_TOKEN")

ph = TelegraphAPI(TELEGRA_PH_TOKEN)

This method is useful if you want to use an existing Telegraph account or manage tokens yourself.

Advanced Usage

Try and see the examples/second_usage.py at here.

Token Management

YTelegraph offers flexible token management:

  1. Automatic: If no token is provided, YTelegraph creates a new account and manages the token for you.
  2. Environment Variable: Set the TELEGRA_PH_TOKEN environment variable, and YTelegraph will use it automatically.
  3. Direct Input: Pass your token directly to the TelegraphAPI constructor.
  4. Token file path: Set PH_TOKEN_PATH if you want the automatically created token stored somewhere other than the default token file.

Choose the method that best fits your workflow and security requirements.

Create Account

While YTelegraph handles account creation automatically, you might want to create your own Telegraph account for more control. Here's a quick guide:

  1. Visit this URL in your browser (feel free to customize the parameters): https://api.telegra.ph/createAccount?short_name=Sandbox&author_name=Anonymous

    • Replace Sandbox with any name to help you remember this account (only visible to you)
    • Change Anonymous to your preferred author name (default for your articles)
    • Or keep them as is – it's totally fine!
  2. After accessing the link, you'll see a response like this:

    {
      "ok": true,
      "result": {
        "short_name": "Sandbox",
        "author_name": "Anonymous",
        "author_url": "",
        "access_token": "abcedfeghijklmnopqrstuvwxyz",
        "auth_url": "https://edit.telegra.ph/auth/qwertyuiop"
      }
    }
    
  3. The access_token (in this example, abcedfeghijklmnopqrstuvwxyz) is what you'll use in your code. (Note: This is not a real token!)

For more details, check out the Telegraph API documentation.

YTelegraph makes this process super easy, but it's good to know how to do it manually if you ever need to.

Development and Testing

This project still uses the small setuptools/pip workflow it started with:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt -e .
python -m unittest discover -s tests
python -m compileall ytelegraph tests
python -m pip install build
python -m build

You can also test the package with uv without converting the project to uv:

uv run --with-requirements requirements.txt python -m unittest discover -s tests
uv run --with-requirements requirements.txt python -m compileall ytelegraph tests
uv run --with build --with-requirements requirements.txt python -m build

The examples in examples/ and scripts in draft_tests/ are live Telegraph API checks. Run them intentionally because they can create or edit Telegraph pages:

python examples/basic_usage.py
python examples/second_usage.py

Versioning

For the versions available, see the CHANGELOG.md file.

Support

If you encounter any problems or have any questions, please open an issue on our GitHub repository.

Contributing

We welcome contributions! Feel free to submit issues or pull requests.

License

YTelegraph is released under the MIT License. See LICENSE for details.

Metadata

Release files for your-telegraph 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for your-telegraph 0.2.2
File Size Uploaded
your_telegraph-0.2.2.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for your-telegraph 0.2.2
File Interpreter ABI Platform
your_telegraph-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 27.4 kB

Release files / your_telegraph-0.2.2.tar.gz

Download URL your_telegraph-0.2.2.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ffda56eaf33dac4e492e52ba583ec930fda72734931832c11e0a31456e126d72
BLAKE2b-256 checksum
How to use checksums
f588638fbde6fd80c02ae67440c80bd46faa85e2d1c09cc2499b3215ac6d8188
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release files / your_telegraph-0.2.2-py3-none-any.whl

Download URL your_telegraph-0.2.2-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3fb5d3004d09674625f833021b59e1b6507d1fbcaeba3265e4393fccdbf1d63
BLAKE2b-256 checksum
How to use checksums
278e206d89d28d233c036328b42624079aa7b725e0c995d39d1a3df0db616b9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page