Skip to main content

favicon

tg-archive is a tool for exporting Telegram group chats into static websites, preserving chat history like mailing list archives.

IMPORTANT: I'm no longer actively maintaining or developing this tool. Can review and merge PRs (as long as they're not massive and are clearly documented).

Preview

The @fossunited Telegram group archive.

image

How it works

tg-archive uses the Telethon Telegram API client to periodically sync messages from a group to a local SQLite database (file), downloading only new messages since the last sync. It then generates a static archive website of messages to be published anywhere.

Features

  • Periodically sync Telegram group messages to a local DB.
  • Download user avatars locally.
  • Download and embed media (files, documents, photos).
  • Renders poll results.
  • Use emoji alternatives in place of stickers.
  • Single file Jinja HTML template for generating the static site.
  • Year / Month / Day indexes with deep linking across pages.
  • "In reply to" on replies with links to parent messages across pages.
  • RSS / Atom feed of recent messages.

Install

  • Get Telegram API credentials. Normal user account API and not the Bot API.

    • If this page produces an alert stating only "ERROR", disconnect from any proxy/vpn and try again in a different browser.
  • Install with: uv pip install tg-archive (tested with Python 3.13.2).

Usage

  1. tg-archive --new --path=mysite (creates a new site. cd into mysite and edit config.yaml).
  2. tg-archive --sync (syncs data into data.sqlite). Note: First time connection will prompt for your phone number + a Telegram auth code sent to the app. On successful auth, a session.session file is created. DO NOT SHARE this session file publicly as it contains the API autorization for your account.
  3. tg-archive --build (builds the static site into the site directory, which can be published)

Customization

Edit the generated template.html and static assets in the ./static directory to customize the site.

Note

  • The sync can be stopped (Ctrl+C) any time to be resumed later.
  • Setup a cron job to periodically sync messages and re-publish the archive.
  • Downloading large media files and long message history from large groups continuously may run into Telegram API's rate limits. Watch the debug output.

Licensed under the MIT license.

Metadata

Release files for tg-archive 1.3.1

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

Source distribution (sdist)

Source distribution for tg-archive 1.3.1
File Size Uploaded
tg_archive-1.3.1.tar.gz 30.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tg-archive 1.3.1
File Interpreter ABI Platform
tg_archive-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 60.7 kB

Release files / tg_archive-1.3.1.tar.gz

Download URL tg_archive-1.3.1.tar.gz
Size 30.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c8e91de03cf823d14245e6827c6fc0b49596d7738aa93725e836abbc11674965
BLAKE2b-256 checksum
How to use checksums
3d2447a722fe29e2a7048adf21d15068a9193a9613563e22321f2561829358d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.8

Release files / tg_archive-1.3.1-py3-none-any.whl

Download URL tg_archive-1.3.1-py3-none-any.whl
Size 30.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
311b2125759930eced8a46550a46e751cc2437c52651f4059619b1b71cdbdb4f
BLAKE2b-256 checksum
How to use checksums
2963ce588764846001339af90ae5a391622968c6a7757f8318ad48012e4a7fe3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.8

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

1.3.0

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.5.5

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.4.0

1 release file

0.3.10

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

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