Skip to main content

Sync and async Python client for the Funstat/Telelog API (Telegram user/group statistics)

Project description

funstat-api

Python client for the Funstat/Telelog API — Telegram user and group statistics.

Supports both sync and async usage.

Documentation: https://chizumeiji.github.io/funstat-api/

Installation

pip install funstat-api

Quick Start

Sync

from funstat_api import FunstatClient, FunstatConfig

# Optional: configure custom headers or base URL
config = FunstatConfig(headers={"X-My-Header": "Value"})
fs = FunstatClient("your_token", config=config)

# Get user stats
stats = fs.stats("durov")
print(stats.data.total_msg_count)

# Get group members
members = fs.get_group_members("https://t.me/mychat")

# Use as context manager
with FunstatClient("your_token") as fs:
    print(fs.ping())

Async

import asyncio
from funstat_api import AsyncFunstatClient, UserHiddenError

async def main():
    async with AsyncFunstatClient("your_token") as fs:
        try:
            stats = await fs.stats("durov")
            print(stats.data.total_msg_count)
        except UserHiddenError:
            print("This user's data is hidden by privacy settings.")

asyncio.run(main())

Available Methods

Method Description
ping() Check API availability and latency
get_balance() Get current token balance
resolve_username(username) Resolve username to user info
basic_info_by_id(ids) Get basic info by user ID(s)
stats_min(user) Get minimal user statistics
stats(user) Get full user statistics
messages_count(user) Get total message count
groups_count(user) Get number of groups
get_messages(user, ...) Get paginated message list
get_chats(user) Get user's chat list
get_names(user) Get name history
get_usernames(user) Get username history
get_stickers(user) Get used sticker packs
get_gifts(user) Get gift relations
common_groups(user) Get common groups stats
username_usage(username) Who uses or used a username
name_usage(name) Search name usage
rep(user) Get user reputation info
common_groups_for_users(ids) Get common groups for specified users
get_group_info(group) Get group/channel info
get_group_members(group) Get group members
search_text(query) Search messages by text

user and group arguments accept: numeric ID, @username, or https://t.me/... link.

Dependencies

  • pydantic >= 2.0
  • requests >= 2.28 (sync client)
  • httpx >= 0.24 (async client)

Credits

License

MIT

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

funstat_api-0.2.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

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

funstat_api-0.2.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file funstat_api-0.2.0.tar.gz.

File metadata

  • Download URL: funstat_api-0.2.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for funstat_api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5eca37ff0d7a0d88617b1fc705efdb9302e262b7a0bf61eb3c00046683e68365
MD5 6db58fa4ea73502d5540fdd542f9b611
BLAKE2b-256 168f9fa2e408d74cf1596533045ab43d35e5e450d0022760ef96eebd6be7986c

See more details on using hashes here.

File details

Details for the file funstat_api-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: funstat_api-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for funstat_api-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4d72a8a875f59c714d35233d0aceca15e04b3ea87bb9bf90aaace784bc85fcb
MD5 02ac9f6a5583bed1ad700816d833a31d
BLAKE2b-256 b3ab233866438e6414bcc04c40fd22f0d23618c3e34f150d35feec40291b0480

See more details on using hashes here.

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