Skip to main content

A simple Python wrapper for the Telegraph API

Project description

YTelegraph

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.

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.

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

Testing

To run the basic integration tests, execute the examples in the examples/ directory:

python examples/basic_usage.py
python examples/advanced_usage.py

Versioning

We use SemVer for 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.

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

your_telegraph-0.1.4.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

your_telegraph-0.1.4-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file your_telegraph-0.1.4.tar.gz.

File metadata

  • Download URL: your_telegraph-0.1.4.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for your_telegraph-0.1.4.tar.gz
Algorithm Hash digest
SHA256 59cd32c70f0c12f671761291d8a20f545b2e82b529a1aa77d3bca4fea74f8ed2
MD5 dc3024afebf3efc7b0e4cf26da42ca56
BLAKE2b-256 74ac8a8e4fe481ede2fd57be50b6d005a8ce421ad64951dfa9a42e1969a52c97

See more details on using hashes here.

File details

Details for the file your_telegraph-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for your_telegraph-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bc85e9a85211cb8b820efd495a63f22cd4635fdf6e3f8542066d449eb1eb54fd
MD5 ace9f5c3d38fc3241ae59662dde7c524
BLAKE2b-256 a50c5381228bec0bb85c5ff1c170abefe21070304ad1bee42205a7533b86d680

See more details on using hashes here.

Supported by

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