An asynchronous and simplified Telegraph API Wrapper in Python
Project description
nusuGraph
An asynchronous and simplified wrapper for the Telegraph API.
Installation
pip install -U nusugraph
Usage
import asyncio
from nusugraph import Telegraph
async def main():
graph = Telegraph(
token=None, # if no token was passed, then an anonymous account will be created
tokenList=None, # list of tokens to be used in a cycle
timeout=10, # timeout for httpx.AsyncClient
)
# Create a Page
text = "Hello, world!"
# Account will be created if no token was passed
response = await graph.createPage(
author="Nusab Taha", htmlContent="<b>Hello</b>", title="Just Saying Hello"
)
url = response["url"]
print(url) # https://telegra.ph/Just-Saying-Hello-12-28-4
# Upload Media from local file
imagePath = "assets/sample.jpg"
url = await graph.uploadMediaFromFile(imagePath)
print(url) # https://telegra.ph/file/daf9c776a1c25264321cd.jpg
# Upload Media from it's bytes content
with open(imagePath, "rb") as file:
imageBytes = file.read()
url = await graph.uploadMediaFromBytes(content=imageBytes, fileType="image/jpeg")
print(url) # https://telegra.ph/file/3406d7261c8c62869ab91.jpg
if __name__ == "__main__":
asyncio.run(main())
WHY?
I needed a simple and asynchronous wrapper for the Telegraph API, with the ability to use multiple tokens in a cycle. That's the reason.
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
nusuGraph-2.1.tar.gz
(5.9 kB
view details)
Built Distribution
File details
Details for the file nusuGraph-2.1.tar.gz
.
File metadata
- Download URL: nusuGraph-2.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63822661e26b08deba68f381864c6b06bed73612fb023120c75300158cb1c60c |
|
MD5 | db50330c46d68ef268b5115eda91a5d6 |
|
BLAKE2b-256 | d86226d487ced2b2babc17bcd76d5098675d5a5612cb61cec694afd326d9f225 |
File details
Details for the file nusuGraph-2.1-py3-none-any.whl
.
File metadata
- Download URL: nusuGraph-2.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 652e4a5fb3e2d4f92a0e047800d594e55233a515d32ae0dc49e48070803628c9 |
|
MD5 | 71f6247e1c89b15f5fb05011e15b742b |
|
BLAKE2b-256 | 9298483050722f429e304ccb5b06e8afd7df5659cbc72f8cad16a142e5aeafc8 |