Skip to main content

Sans io implementation of telegram api

Tiny telegram bot-api wrapper library.

Reasons

  • aiotg is framework, not library and have no proxy support.
  • Raw api calls translation is better for understanding and will not break if telegram api will be changed.
  • snake_case

Features

  • support both, sync and async ways to deal with io.
  • Simple as telegram api is.
  • snake_case api converted to telegram camelCase.
  • Polling offset handled for you via get_updates method.
  • Handling timeout between requests automatically (via delay keyword-only argument).
  • Use any io backend you want.

Implementation

Sans io implementation based on generators for simplifying flow and holding state. siotelegram have io backends based on:

  • requests
  • aiohttp
  • httpx

Installation

  • sync:
    • python -m pip install siotelegram[requests]
  • async:
    • python -m pip install siotelegram[aiohttp]
    • python -m pip install siotelegram[httpx]

Examples

Common

import asyncio

import siotelegram


TOKEN = "token"


def requests_example():
    api = siotelegram.RequestsTelegramApi(TOKEN, timeout=10)
    response = api.get_updates()
    print(response)


async def aiohttp_example():
    async with siotelegram.AioHTTPTelegramApi(TOKEN, timeout=10) as api:
        response = await api.get_updates()
        print(response)


if __name__ == "__main__":
    import time
    # requests
    requests_example()
    time.sleep(1)
    # aiohttp
    asyncio.run(aiohttp_example())

Send files

import siotelegram
api = siotelegram.RequestsTelegramApi(TOKEN, timeout=10)
name = "capybara.jpg"
api.send_photo(chat_id=chat_id, caption="Hellow world!", files_=dict(photo=open(, "rb")))

# or from in-memory bytes
import pathlib
import io
data = pathlib.Path(name).read_bytes()
f = io.BytesIO(data)
f.name = name
api.send_photo(chat_id=chat_id, caption="Hellow world!", files_=dict(photo=f))

Metadata

Release files for siotelegram 1.3.0

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

Source distribution (sdist)

Source distribution for siotelegram 1.3.0
File Size Uploaded Provenance
siotelegram-1.3.0.tar.gz 5.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for siotelegram 1.3.0
File Interpreter ABI Platform
siotelegram-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / siotelegram-1.3.0.tar.gz

Download URL siotelegram-1.3.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9a202163e69f35b6c2350d90818ede33879f69698bd7b77241706b7bc7b47771
BLAKE2b-256 checksum
How to use checksums
527f6aa04e80a76dedfbf9901da7e3de5b5aa3a03fd499e9a3137fbb8179934f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Release files / siotelegram-1.3.0-py3-none-any.whl

Download URL siotelegram-1.3.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ea69d48fcda500e05439f671aec026a362fcb7089740ad854ea18ec10b5accd
BLAKE2b-256 checksum
How to use checksums
1ac56cc32bade515035aac2d56b40993e794a8d9e7308d289158318ce4669bc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Security for siotelegram 1.3.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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