Skip to content

IvanProgramming/Telegraph_api

Repository files navigation

TelegraphAPI

Documentation Status Lines of code PyPI wakatime GitHub Repo stars

Asynchronus Python wrapper for telgra.ph API

Installation

Use the package manager pip to install telegraph_api.

pip install telegraph-api

Documentation

You can read documentation of this package on readthedocs

Documentation of original REST api can be found on telegra.ph site

Features

  • Asynchronous
  • HTML2Nodes convertation
  • File uploading
  • Built with Pydantic
  • Documentation is provided

Usage

# Importing required package
from telegraph_api import Telegraph
import asyncio


# Declaring asynchronous function for using await
async def main():
    # Creating new Telegraph object
    telegraph = Telegraph()
    # Creating new account
    await telegraph.create_account("My Favourite Blog", author_name="Ivan")
    # Creating new page
    new_page = await telegraph.create_page(
        "My first Telegraph Post",
        content_html="<p>Hello world!</p>" # Html content can be presented      
    )
    # Printing page url into console
    print(new_page.url)


# Running asynchronous function
asyncio.run(main())

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

I choosed MIT license


Article in my blog about writing this wrapper (On Russian) - https://blog.rteam.club/all/fromegeya2telegram-1/