Skip to content

API Reference

This page is generated from source code docstrings and signatures via mkdocstrings.

Package

telegras

telegras - Telegram + FastAPI focused integration service.

create_app

create_app(*, app=None, settings=None, service=None, merge_lifespan=True)

Create or configure the FastAPI application.

This function can either create a new standalone FastAPI app or mount telegras routes onto an existing FastAPI app.

Parameters:

Name Type Description Default
app FastAPI | None

Optional existing FastAPI app to mount routes onto. If None, creates a new standalone app.

None
settings AppSettings | None

Optional application settings. If None, loads from environment.

None
service TelegramIngestionService | None

Optional TelegramIngestionService instance. If None, creates one.

None
merge_lifespan bool

Whether to merge lifespans when mounting on existing app. Only applicable when app is provided.

True

Returns:

Type Description
FastAPI

The configured FastAPI application (new or provided)

get_file_direct_url async

get_file_direct_url(file_id)

Given a Telegram file_id, return a direct HTTPS URL for that file.

Note: This URL is temporary and should be used only to download once.

download_file async

download_file(file_url)

Download a Telegram file via HTTPS.

Key modules

telegras.app

create_app

create_app(*, app=None, settings=None, service=None, merge_lifespan=True)

Create or configure the FastAPI application.

This function can either create a new standalone FastAPI app or mount telegras routes onto an existing FastAPI app.

Parameters:

Name Type Description Default
app FastAPI | None

Optional existing FastAPI app to mount routes onto. If None, creates a new standalone app.

None
settings AppSettings | None

Optional application settings. If None, loads from environment.

None
service TelegramIngestionService | None

Optional TelegramIngestionService instance. If None, creates one.

None
merge_lifespan bool

Whether to merge lifespans when mounting on existing app. Only applicable when app is provided.

True

Returns:

Type Description
FastAPI

The configured FastAPI application (new or provided)

telegras.telegram_api

get_file_direct_url async

get_file_direct_url(file_id)

Given a Telegram file_id, return a direct HTTPS URL for that file.

Note: This URL is temporary and should be used only to download once.

download_file async

download_file(file_url)

Download a Telegram file via HTTPS.

telegras.webhook_attachments

telegras.default_handlers

register_handler_plugin

register_handler_plugin(plugin)

Register a callable that returns handler mappings.

handler_plugin

handler_plugin(func)

Decorator for registering handler plugins.

telegras.persistence.repository