Use Custom API server#

For example, if you want to use self-hosted API server:

session = AiohttpSession(
    api=TelegramAPIServer.from_base('http://localhost:8082')
)
bot = Bot(..., session=session)
class aiogram.client.telegram.TelegramAPIServer(base: str, file: str, is_local: bool = False, wrap_local_file: ~aiogram.client.telegram.FilesPathWrapper = <aiogram.client.telegram.BareFilesPathWrapper object>)[source]#

Base config for API Endpoints

api_url(token: str, method: str) str[source]#

Generate URL for API methods

Параметри:
  • token – Bot token

  • method – API method name (case insensitive)

Повертає:

URL

base: str#

Base URL

file: str#

Files URL

file_url(token: str, path: str) str[source]#

Generate URL for downloading files

Параметри:
  • token – Bot token

  • path – file path

Повертає:

URL

classmethod from_base(base: str, **kwargs: Any) TelegramAPIServer[source]#

Use this method to auto-generate TelegramAPIServer instance from base URL

Параметри:

base – Base URL

Повертає:

instance of TelegramAPIServer

is_local: bool = False#

Mark this server is in local mode.

wrap_local_file: FilesPathWrapper = <aiogram.client.telegram.BareFilesPathWrapper object>#

Callback to wrap files path in local mode