Skip to main content

Export Telegram Stories viewers and build analytics reports.

Project description

Telegram Stories Analytics

tg-stories exports your own Telegram Stories through Telethon, fetches viewer lists, computes engagement analytics, and renders local JSON, Markdown, and HTML reports.

The CLI is packaged as a normal Python console script and works on macOS, Linux, and Windows. Authentication is stored in the system keyring. On macOS it can also reuse credentials created by the local telegram-telethon skill.

Install

For normal use:

pipx install telegram-stories-analytics

For local development:

python -m venv .venv
source .venv/bin/activate
python -m pip install -e .

Telegram API Credentials

Create api_id and api_hash at https://my.telegram.org under API Development Tools.

Then login once:

tg-stories auth login --profile personal

Check the session:

tg-stories auth status --profile personal

On macOS, if you already use the telegram-telethon skill, this tool can reuse that Keychain session:

tg-stories auth status --profile ivanopcode --auth-source telegram-telethon

Export Stories

Full export:

tg-stories export --profile personal --progress --open

This writes:

exports/my-telegram-stories-full.json
exports/my-telegram-stories-analysis.json
exports/my-telegram-stories-analysis.md
exports/my-telegram-stories-analysis.html

The full JSON contains each story, Telegram story link when available, metadata, counts, and a nested viewers array with viewer identity, view date, and reaction.

Rebuild Reports

If you already have a full export, recompute analytics without calling Telegram:

tg-stories analyze exports/my-telegram-stories-full.json --open

Render or open HTML from an analysis JSON:

tg-stories html exports/my-telegram-stories-analysis.json --open
tg-stories open exports/my-telegram-stories-analysis.json

Analytics

The generated analysis includes:

  • all-time regularity and >=80% viewers;
  • recent windows, by default 30, 90, and 180 days;
  • sliding-window regularity;
  • fastest regular viewers by median view latency;
  • story-level speed buckets: 5m, 15m, 1h, 6h, and 24h;
  • top viewers by absolute reactions;
  • top viewers by reaction rate;
  • lapsed viewers, new recent viewers, and declining viewers;
  • contact, mutual contact, non-contact, and premium segments.

Important definitions:

  • view_rate = viewed_story_count / story_count
  • reaction_rate_per_viewed_story = reaction_count / viewed_story_count
  • view_latency_seconds = viewer view_date - story date

Environment Auth

For CI-like or temporary usage, credentials can be provided through environment variables:

export TG_STORIES_API_ID=12345
export TG_STORIES_API_HASH=...
export TG_STORIES_SESSION=...
tg-stories export --auth-source env

Do not commit exported reports. Viewer data is personal data.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telegram_stories_analytics-0.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telegram_stories_analytics-0.1.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file telegram_stories_analytics-0.1.0.tar.gz.

File metadata

File hashes

Hashes for telegram_stories_analytics-0.1.0.tar.gz
Algorithm Hash digest
SHA256 976229db3e397210070c8d646171548d7061d6ee4e3814359e3c23364b717f3e
MD5 6c6c9d4af48a55377b0c46c4762745ca
BLAKE2b-256 323878d366ea0d82cbc25364593033b02c842e85bceea3be8cfa724e25225a69

See more details on using hashes here.

Provenance

The following attestation bundles were made for telegram_stories_analytics-0.1.0.tar.gz:

Publisher: publish.yml on ivanopcode/telegram-stories-analytics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file telegram_stories_analytics-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for telegram_stories_analytics-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfab138621b527baf75438348d3a4cd89339db54e15b45f1e1427b2795b50115
MD5 855626e2b08b06b69b29d6c6f161ec11
BLAKE2b-256 36806986b1f1d864aa4f541fa4c65f6fa2052fe771ea7b931977647c1bf05550

See more details on using hashes here.

Provenance

The following attestation bundles were made for telegram_stories_analytics-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ivanopcode/telegram-stories-analytics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page