You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

GramApi

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

GramApi

Telegram API for gifts

1.0.3
pipPyPI
Maintainers
1

🎁 GramApi – Telegram Gift & Star Parser Library

GramApi is a lightweight and efficient Python library designed for parsing gifts and stars from Telegram Business chats using both official API and optional userbot integration.

Perfect for analytics, automation, dashboards, and backend services.

📦 Installation

pip install gramapi

🚀 Quick Start

from gramapi import GiftParser

parser = GiftParser(bot_token="1234567890:ABC-DEF1234ghIkl-zyx57W2v1u123ew11")
gifts = parser.fetch_recent_gifts(chat_id="@your_channel")

for gift in gifts:
    print(f"🎁 Gift ID: {gift.id}, Sender: {gift.sender.username}, Type: {gift.type}, Amount: {gift.amount}")

🔧 Features

  • 🧾 Parse all available Telegram gifts and stars
  • 📊 Extract metadata: gift ID, sender info, type, value, timestamp
  • 🛡️ Rate-limit safe
  • 🔌 Supports both Bot API and UserBot (Telethon)

📚 API Reference

GiftParser

GiftParser(bot_token: str, use_userbot: bool = False)

Methods:

  • fetch_recent_gifts(chat_id: str, limit: int = 100) -> List[Gift]
    Fetch recent gift transactions from a chat/channel.

  • get_gift_by_id(gift_id: str) -> Gift
    Fetch a single gift object by ID.

  • listen(callback: Callable[[Gift], None])
    Start real-time monitoring (UserBot required).

🎁 Gift Object Structure

class Gift:
    id: str
    sender: User
    type: str  # "star", "nft", "custom"
    amount: int
    timestamp: datetime

🧪 Async Usage Example

import asyncio
from gramapi import GiftParser

async def main():
    parser = GiftParser(bot_token="123:ABC", use_userbot=True)

    async for gift in parser.stream("@gift_channel"):
        print(f"New gift from {gift.sender.username}: {gift.type} x{gift.amount}")

asyncio.run(main())

📄 License

MIT License

📬 Support

Telegram support bot: @gramapi_support_bot

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts