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.
Advanced Usage
Try and see the example/second_usage.py
at here.
Token Management
YTelegraph offers flexible token management:
- Automatic: If no token is provided, YTelegraph creates a new account and manages the token for you.
- Environment Variable: Set the
TELEGRA_PH_TOKEN
environment variable, and YTelegraph will use it automatically. - 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/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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file your_telegraph-0.2.0.tar.gz
.
File metadata
- Download URL: your_telegraph-0.2.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ca441ad4ef74a3ed9523992b060d57517b974622de408b91356661c0df40bed |
|
MD5 | 4268e32124bad22a31de5dcd63c0d4b6 |
|
BLAKE2b-256 | 99f19e63441d8de2f0f366eaed58ecc73685f8c874709d3c007b3fc59d299545 |
File details
Details for the file your_telegraph-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: your_telegraph-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dfdc8cd73de320acb182fd255f20dd8e80f93151a581625269e8fc6c10fe44b |
|
MD5 | 77558d676ff5f74c9093a350c98aafa4 |
|
BLAKE2b-256 | ba26aa66273589a2dc308ce01b8f25939384ce4fbd9f184008b3361ebf518249 |