SmartUserInfo is a powerful Telegram Info API built with FastAPI and Pyrogram, designed to retrieve detailed information about Telegram users, bots, channels, and groups. This API provides insights such as account age estimation, data center locations, premium status, and real-time status tracking. π₯
Project URL: github.com/TheSmartDevs/SmartUserInfo β
Updates Channel: t.me/TheSmartDev π
Developer: @ISmartCoder π₯
- User & Bot Information π: Retrieve details like user ID, username, first/last name, premium status, verification status, and account flags (e.g., scam or fake).
- Channel & Group Details π₯: Fetch information about Telegram channels, groups, and supergroups, including member count, description, and join links.
- Account Age Estimation β : Estimate the account creation date based on user ID with a custom algorithm.
- Data Center Location βοΈ: Identify the Telegram data center location (e.g., Miami, Amsterdam, Singapore) for users and chats.
- Real-time Status Tracking π: Get the current status of users (e.g., online, offline, recently online).
- FastAPI Integration π₯: Provides a robust, scalable API with endpoints for health checks, entity information, and interactive documentation.
- Pyrogram Backend β : Leverages Pyrogram for reliable Telegram API interactions.
- Error Handling βοΈ: Comprehensive error handling for invalid usernames, channels, or other issues.
- Deployment Ready π: Easy setup instructions for Render, Heroku, or VPS.
Endpoint | Description | Parameters |
---|---|---|
/ |
Serves the status dashboard (HTML) π | None |
/info |
Retrieves Telegram entity information β | username (query parameter) |
/health |
API health check and detailed information βοΈ | None |
/docs |
Interactive Swagger UI documentation π | None |
/redoc |
Alternative ReDoc API documentation β | None |
The API returns JSON responses with a consistent structure:
-
Success Response β :
{ "success": true, "type": "user|bot|group|supergroup|channel", "id": "<entity_id>", "first_name": "<first_name>", // For users/bots "last_name": "<last_name>", // For users/bots "username": "<username>", "dc_id": <data_center_id>, "dc_location": "<location>", "is_premium": <boolean>, // For users/bots "is_verified": <boolean>, // For users/bots "is_bot": <boolean>, // For users/bots "flags": "Clean|Scam|Fake", // For users/bots "status": "<status>", // For users/bots "account_created": "<date>", // For users/bots "account_age": "<age>", // For users/bots "members_count": <number>, // For groups/channels "description": "<description>", // For groups/channels "api_dev": "@ISmartCoder", "api_updates": "https://t.me/TheSmartDev", "links": { "android": "<tg_link>", "ios": "<tg_link>", "permanent": "<tg_link>", "join": "<tg_link>" // For groups/channels } }
-
Error Response β:
{ "success": false, "error": "<error_message>" }
- Python 3.8+
- Telegram API credentials (
API_ID
,API_HASH
,BOT_TOKEN
) β- Obtain these from my.telegram.org and create a bot via @BotFather.
- Git
- A deployment platform (Render, Heroku, or VPS) π₯
-
Clone the Repository π:
git clone https://github.com/TheSmartDevs/SmartUserInfo.git cd SmartUserInfo
-
Install Dependencies π₯:
pip install -r requirements.txt
Ensure
requirements.txt
includes:fastapi uvicorn pyrogram python-dateutil
-
Configure Environment Variables β : Create a
config.py
file in the project root with the following:API_ID = "your_api_id" API_HASH = "your_api_hash" BOT_TOKEN = "your_bot_token"
-
Create Status Page βοΈ: Create a
status.html
file in the project root for the/
endpoint. Example:<!DOCTYPE html> <html> <head> <title>SmartUserInfo API π</title> </head> <body> <h1>SmartUserInfo API π₯</h1> <p>API is running! Check <a href="/docs">API Docs</a> for details. β </p> <p>Developed by <a href="https://t.me/ISmartCoder">@ISmartCoder</a> π</p> <p>Updates: <a href="https://t.me/TheSmartDev">t.me/TheSmartDev</a> π₯</p> </body> </html>
-
Run the Application β :
python app.py
The API will be available at
http://localhost:5000
.
-
Create a Render Account β : Sign up at render.com and create a new Web Service.
-
Connect GitHub Repository βοΈ: Link your GitHub repository (
github.com/TheSmartDevs/SmartUserInfo
) to Render. -
Configure Build Settings β :
- Build Command:
pip install -r requirements.txt
- Start Command:
python app.py
- Environment Variables:
API_ID
: Your Telegram API IDAPI_HASH
: Your Telegram API HashBOT_TOKEN
: Your Telegram Bot TokenPORT
:5000
(default)
- Build Command:
-
Add Status Page π: Ensure
status.html
is included in your repository. -
Deploy π₯: Trigger the deployment from Renderβs dashboard. The API will be accessible at the provided Render URL.
-
Create a Heroku Account π: Sign up at heroku.com.
-
Deploy via Button π₯: Click the "Deploy to Heroku" button above, or manually deploy:
- Clone the repository and push to Heroku:
heroku create git push heroku main
- Clone the repository and push to Heroku:
-
Configure Environment Variables β : In the Heroku dashboard, add:
API_ID
API_HASH
BOT_TOKEN
-
Add Buildpacks βοΈ: Add the Python buildpack in the Heroku dashboard or via:
heroku buildpacks:set heroku/python
-
Add Status Page π: Ensure
status.html
is in the repository. -
Scale Dynos β :
heroku ps:scale web=1
-
Access the API π₯: The API will be available at
https://your-app-name.herokuapp.com
.
-
Set Up VPS π: Use a provider like DigitalOcean, AWS, or Linode. Install Ubuntu 20.04+.
-
Install Dependencies β :
sudo apt update sudo apt install python3 python3-pip git
-
Clone Repository π₯:
git clone https://github.com/TheSmartDevs/SmartUserInfo.git cd SmartUserInfo pip3 install -r requirements.txt
-
Configure Environment Variables β : Create a
config.py
file or export variables:export API_ID="your_api_id" export API_HASH="your_api_hash" export BOT_TOKEN="your_bot_token"
-
Add Status Page π: Create
status.html
as described in the local setup. -
Run with Uvicorn π₯:
uvicorn app:app --host 0.0.0.0 --port 5000
-
Set Up Reverse Proxy (Optional) βοΈ: Use Nginx to expose the API:
sudo apt install nginx sudo nano /etc/nginx/sites-available/smartuser
Add:
server { listen 80; server_name your_domain_or_ip; location / { proxy_pass http://localhost:5000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
Enable and restart Nginx:
sudo ln -s /etc/nginx/sites-available/smartuser /etc/nginx/sites-enabled/ sudo systemctl restart nginx
-
Run in Background β : Use
screen
orpm2
to keep the app running:pip3 install pm2 pm2 start "uvicorn app:app --host 0.0.0.0 --port 5000" --name smartuser
-
Interactive Docs β : Access at
/docs
(Swagger UI) or/redoc
(ReDoc). -
Example Request π₯:
curl -X GET "http://your-api-url/info?username=ISmartCoder"
-
Example Response (User) β :
{ "success": true, "type": "user", "id": 123456789, "first_name": "Smart", "last_name": "Coder", "username": "ISmartCoder", "dc_id": 4, "dc_location": "STO, Stockholm, Sweden, SE", "is_premium": false, "is_verified": false, "is_bot": false, "flags": "Clean", "status": "Online", "account_created": "August 13, 2020", "account_age": "4 years, 10 months, 16 days", "api_dev": "@ISmartCoder", "api_updates": "https://t.me/TheSmartDev", "links": { "android": "tg://openmessage?user_id=123456789", "ios": "tg://user?id=123456789", "permanent": "tg://user?id=123456789" } }
-
Example Response (Channel) π:
{ "success": true, "type": "channel", "id": -100123456789, "title": "TheSmartDev", "username": "TheSmartDev", "dc_id": 2, "dc_location": "AMS, Amsterdam, Netherlands, NL", "members_count": 1000, "description": "Updates for SmartUserInfo API", "api_dev": "@ISmartCoder", "api_updates": "https://t.me/TheSmartDev", "links": { "join": "t.me/TheSmartDev", "permanent": "t.me/TheSmartDev" } }
Contributions are welcome! Please:
- Fork the repository. π
- Create a new branch (
git checkout -b feature/your-feature
). β - Commit your changes (
git commit -m 'Add your feature'
). βοΈ - Push to the branch (
git push origin feature/your-feature
). π₯ - Open a pull request. β
This project is licensed under the MIT License. See the LICENSE file for details. π
For support, join our updates channel: t.me/TheSmartDev or contact @ISmartCoder. π₯