Skip to main content
<div align="center">

<img src="logo.png" width="220" alt="PyJetra Logo">

# PyJetra

**Modern Python wrapper for the Jetra Bot API — Sync & Async**

**کتابخانه‌ی مدرن پایتون برای Jetra Bot API — همگام و ناهمگام**

[![PyPI version](https://img.shields.io/pypi/v/pyjetra?style=for-the-badge&logo=pypi&color=blue)](https://pypi.org/project/pyjetra/)
[![PyPI downloads](https://img.shields.io/pypi/dm/pyjetra?style=for-the-badge&color=purple)](https://pypi.org/project/pyjetra/)
[![Python versions](https://img.shields.io/pypi/pyversions/pyjetra?style=for-the-badge&logo=python)](https://pypi.org/project/pyjetra/)
[![License](https://img.shields.io/github/license/lyrdaadhrpyk802-ux/pyjetra?style=for-the-badge&color=orange)](https://github.com/lyrdaadhrpyk802-ux/pyjetra/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/lyrdaadhrpyk802-ux/pyjetra?style=for-the-badge&logo=github&color=yellow)](https://github.com/lyrdaadhrpyk802-ux/pyjetra/stargazers)
[![GitHub issues](https://img.shields.io/github/issues/lyrdaadhrpyk802-ux/pyjetra?style=for-the-badge&logo=github&color=red)](https://github.com/lyrdaadhrpyk802-ux/pyjetra/issues)
[![Jetra](https://img.shields.io/badge/jetra.ir-official-purple?style=for-the-badge)](https://jetra.ir/)

</div>

---

## About

**PyJetra** is a Python library for building [Jetra](https://jetra.ir/) bots. It wraps the **Jetra Bot API** in a clean, modern interface with full support for both synchronous and asynchronous workflows.

**PyJetra** یک کتابخانه‌ی پایتون برای ساخت ربات‌های [جترا](https://jetra.ir/) است که یک رابط تمیز و مدرن روی **Jetra Bot API** فراهم می‌کند و از هر دو حالت همگام و ناهمگام به‌طور کامل پشتیبانی می‌کند.

Whether you are building a small personal bot or a large group-management system, PyJetra gives you the tools you need — without hiding the details.

---

## Install

```bash
pip install pyjetra

Requires Python 3.7+. — نیازمند پایتون ۳٫۷ به بالا.


Features

🔄 Sync & Async / همگام و ناهمگام JetraBot and AsyncJetraBot with matching APIs 🎛️ Full Bot API / پوشش کامل messages, media, edits, deletes, callbacks, webhooks 🧠 FSM / مدیریت وضعیت built-in state management for multi-step flows 🎨 Inline keyboards / دکمه‌های شیشه‌ای multi-level menus, URL buttons, callbacks 🧩 Filters / فیلترها CommandFilter, TextFilter, RegexFilter 📨 Edited events / ویرایش پیام @bot.on_edited_message 📎 Full media / رسانه‌ی کامل photo, document, video, audio, voice, sticker, animation, location, contact, venue, live photo 🌐 Webhook / وب‌هوک set_webhook, delete_webhook, get_webhook_info + WSGI/ASGI handlers 💬 Rich Message / تایپ کامل replies, forwards, reply_photo, reply_document, is_forwarded, mentions 🧱 Helpers / هلپرها ChatPermissions factories, User.full_name, Chat.display_name 🛡️ Safe uploads / آپلود امن 25 MB client-side check with FileTooLargeError 🔒 Clean sessions / نشست تمیز async with AsyncJetraBot(...) for leak-free bots


Quick start

from pyjetra import (
    JetraBot,
    CommandFilter,
    InlineKeyboardMarkup,
    InlineKeyboardButton,
)

bot = JetraBot("YOUR_BOT_TOKEN")

@bot.on_message(filters=[CommandFilter("start")])
def start(msg):
    keyboard = InlineKeyboardMarkup([
        [InlineKeyboardButton(text="Open Jetra", url="https://jetra.ir")],
        [InlineKeyboardButton(text="About", callback_data="about")],
    ])
    msg.reply("Welcome to PyJetra!", reply_markup=keyboard)

@bot.on_callback_query()
def on_button(cb):
    if cb.data == "about":
        cb.answer("PyJetra - Python wrapper for the Jetra Bot API")

bot.poll()

Async

import asyncio
from pyjetra import AsyncJetraBot, CommandFilter

async def main():
    async with AsyncJetraBot("YOUR_BOT_TOKEN") as bot:
        @bot.on_message(filters=[CommandFilter("start")])
        async def start(msg):
            await msg.reply("Hello from Async PyJetra!")

        await bot.start_polling()

asyncio.run(main())

Webhook (FastAPI)

import os
from fastapi import FastAPI
from pyjetra import JetraBot, CommandFilter, make_asgi_handler

app = FastAPI()
bot = JetraBot(os.environ["JETRA_TOKEN"])

@bot.on_message(filters=[CommandFilter("start")])
def start(msg):
    msg.reply("Hello from webhook!")

app.add_api_route(
    "/webhook",
    make_asgi_handler(bot, secret_token=os.environ["WEBHOOK_SECRET"]),
    methods=["POST"],
)

@app.on_event("startup")
def setup():
    bot.set_webhook(
        url=os.environ["WEBHOOK_URL"],
        secret_token=os.environ["WEBHOOK_SECRET"],
        allowed_updates=["message", "edited_message", "callback_query"],
    )

FSM

@bot.on_message(filters=[CommandFilter("register")])
def start_register(msg):
    bot.set_state(msg.from_user.id, "waiting_for_name")
    msg.reply("What's your name? / اسمت چیه؟")

@bot.on_message()
def handle_name(msg):
    if bot.get_state(msg.from_user.id) == "waiting_for_name":
        bot.clear_state(msg.from_user.id)
        msg.reply(f"Nice to meet you, {msg.text}!")

Links

· 📦 PyPI — · 📁 GitHub — · 🐛 Issues — · 🚀 Releases — · 📖 Jetra Bot API docs — · 💬 PyJetra channel — · 👥 Community chat —


Developer

Ali VEX

Founder and lead developer of PyJetra Bot developer, Python enthusiast, Jetra community member

Ali VEX created PyJetra and maintains JetraGuard, a full-featured group-management bot built on top of it.

Platform Link 💬 Jetra profile 📢 PyJetra channel 👥 Community chat 🐙 GitHub 📧 Email 📦 PyPI


License

Released under the MIT License. See the LICENSE file for details.


Made with ❤️ for the Jetra community — ساخته‌شده با ❤️ برای جامعه‌ی جترا

```

Metadata

Release files for pyjetra 1.7.2

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

Source distribution (sdist)

Source distribution for pyjetra 1.7.2
File Size Uploaded Provenance Actions
pyjetra-1.7.2.tar.gz 31.8 kB Without provenance Details for pyjetra-1.7.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyjetra 1.7.2
File Interpreter ABI Platform Actions
pyjetra-1.7.2-py3-none-any.whl Python 3 none any Details for pyjetra-1.7.2-py3-none-any.whl

Total release size: 57.4 kB

Release files / pyjetra-1.7.2.tar.gz

Download URL pyjetra-1.7.2.tar.gz
Size 31.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ec94db7f4c42f5a2e70546725e2589701558d14936d71665c2d00bf5ed54f15b
BLAKE2b-256 checksum
How to use checksums
1f775a14663135cf7da65d2ebc5a87deaac443c2c35bea814cd01abfc561772c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / pyjetra-1.7.2-py3-none-any.whl

Download URL pyjetra-1.7.2-py3-none-any.whl
Size 25.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
822423a0484dfb248d9b422e37eae24d2f6a3f6e14f60f0ddecbdf24c3e762d6
BLAKE2b-256 checksum
How to use checksums
7c1021c1ead1a5fecf461137d367f366ad812a44e9692d2fc58dc21c877b1295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for pyjetra 1.7.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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