Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference beetween using pyTelegramBotAPI and Telegram Bot API

I'm new to python and telegram bot programming, and I have been programming a telegram bot using pyTelegramBotAPI because the tutorials I followed used it, but I can't find no information on the internet about a definition/description about pyTelegramBotAPI and why should I use it instead of Telegram Bot API. Can someone help me with these questions? I literally couldn't find these information on the internet. Thanks

like image 838
Bruno Avatar asked Aug 08 '26 10:08

Bruno


1 Answers

pyTelegramBotAPI is a python implementation of the Telegram Bot API.

You're not choosing to use pyTelegramBotAPI instead of the Telegram Bot API - rather you're choosing to use pyTelegramBotAPI for the Telegram Bot API. This is one of numerous Python implementations and Python is just one of many languages that implementations are written in. If you really want, you can operate a Telegram Bot using shell commands.

In general terms, an implementation of a HTTP-based API written in a particular language simplifies building your program by allowing you to specify your ID's and credentials, and then simply calling functions to get things done, instead of having to engineer every call and include the paramaters manually or repetitively. It also takes care of constructing the requests and passing the paramaters in a compatible format to the server, while it may also provide some additional parsing to the paramaters provided to the abstracted functions.

Reasons you may wish to use pyTelegramBotAPI:

  • You like the features and functionality of pyTelegramBotAPI. I.e. You're looking for a framework for a project like one of these

  • You want a Python implementation of the Telegram Bot API without having to build it from scratch yourself.

  • You want a fairly comprehensive and extensible implementation of the Telegram Bot API (true at the time of writing this)

The Documentation explains what you need to be aware of, and how certain aspects translate to the API. I.e, there's a paragraph explaining the convention of method names has been modified to more idiomatic Python;

Methods

All API methods are located in the TeleBot class. They are renamed to follow common Python naming conventions. E.g. getMe is renamed to get_me and sendMessage to send_message.

There's also a note about the renaming of from to from_user

Reasons you may not want to use pyTelegramBotAPI

As mentioned above, pyTelegramBotAPI is maintained and updated regularly at the time of writing this. However, there's never a guarantee that code written by someone else will always be maintained in either it's original form or forked off and taken in a new direction.

You may choose against using something like this if:

  • Python is unavailable in your environment
  • You require an extremely simple and lightweight use of a bot and could maintain it quicker by referring directly to the official Telegram API reference.
  • You are looking to integrate to another project using a different language.
  • You aren't confident in extending the the code to suit your requirements.
like image 98
hmedia1 Avatar answered Aug 09 '26 23:08

hmedia1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!