{"id":19122100,"url":"https://github.com/koval01/telegram-me","last_synced_at":"2025-05-05T16:28:41.308Z","repository":{"id":228009386,"uuid":"771458709","full_name":"koval01/telegram-me","owner":"koval01","description":"A convenient API to get a channel from t.me in json","archived":false,"fork":false,"pushed_at":"2025-05-01T09:45:03.000Z","size":292,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-01T10:34:02.008Z","etag":null,"topics":["api","app","backend","channel","docker","fast","fastapi","kubernetes","microservice","pydantic","python","python3","rest-api","swagger","telegram","tg"],"latest_commit_sha":null,"homepage":"https://telegram.koval.page","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koval01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"koval01","ko_fi":"koval","custom":"https://x.com/PageKoval"}},"created_at":"2024-03-13T10:39:37.000Z","updated_at":"2025-05-01T09:45:00.000Z","dependencies_parsed_at":"2024-04-04T22:24:05.124Z","dependency_job_id":"ebf3f3a4-6ce5-4440-ba9e-a3deccd32daf","html_url":"https://github.com/koval01/telegram-me","commit_stats":null,"previous_names":["koval01/telegramme","koval01/telegram-me"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koval01%2Ftelegram-me","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koval01%2Ftelegram-me/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koval01%2Ftelegram-me/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koval01%2Ftelegram-me/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koval01","download_url":"https://codeload.github.com/koval01/telegram-me/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252533384,"owners_count":21763588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","app","backend","channel","docker","fast","fastapi","kubernetes","microservice","pydantic","python","python3","rest-api","swagger","telegram","tg"],"created_at":"2024-11-09T05:19:52.300Z","updated_at":"2025-05-05T16:28:41.262Z","avatar_url":"https://github.com/koval01.png","language":"Python","funding_links":["https://github.com/sponsors/koval01","https://ko-fi.com/koval","https://x.com/PageKoval"],"categories":[],"sub_categories":[],"readme":"# TelegramMe API\n\nThis repository implements the Telegram channel viewer API in Python using FastAPI. The API provides endpoints to fetch basic information about a channel and retrieve more posts from the channel.\n\n## Prerequisites\n\nBefore you begin, ensure you have the following installed on your machine:\n\n- [Docker](https://docs.docker.com/get-docker/): Docker is used to containerize the application.\n- Basic knowledge of Docker, Python, FastAPI, and Nginx.\n\n## Usage\n\n### Running the Docker App\n\nTo run the TelegramMe API using Docker, follow these steps:\n\n1. Clone this repository to your local machine:\n\n   ```bash\n   git clone https://github.com/koval01/telegram-me\n   cd telegram-me/\n   ```\n\n2. Build the Docker image:\n\n   ```bash\n   docker build -t telegramme-api .\n   ```\n\n3. Run the Docker container:\n\n   ```bash\n   docker run -d -p 8080:8080 telegramme-api\n   ```\n\n   This command will start the FastAPI app inside a Docker container, and it will be accessible at `http://localhost:8080`.\n\n### Running with Nginx as a Balancer\n\nTo run the FastAPI app with Nginx as a balancer, follow these steps:\n\n1. Ensure Docker is installed and the Docker container is built (follow steps 1 and 2 from the previous section).\n\n2. Create a Nginx configuration file (e.g., `nginx.conf`) with the following content:\n\n   ```nginx\n   upstream fastapi {\n       server app:8080;\n   }\n\n   server {\n       listen 80;\n\n       location / {\n           proxy_pass http://fastapi;\n           proxy_set_header Host $host;\n           proxy_set_header X-Real-IP $remote_addr;\n           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n           proxy_set_header X-Forwarded-Proto $scheme;\n       }\n   }\n   ```\n\n3. Run Nginx in a Docker container using the created configuration file:\n\n   ```bash\n   docker run -d -p 80:80 -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro --name nginx nginx\n   ```\n\n   This command will start Nginx in a Docker container, using the provided configuration file as the Nginx configuration.\n\n4. Run the FastAPI app container (follow step 3 from the previous section).\n\n   Now, the FastAPI app will be accessible through Nginx at `http://\u003cyour_server_IP\u003e/`.\n\n### How the example on telegram.koval.page was deployed\n\nThis example is now deployed on multiple vps, I don't recommend using this method as this deployment is difficult to administer as it grows, but it is suitable for demoing or testing.\nLet's start by installing the dependencies. I use ubuntu (24.04) because this distribution allows you to quickly and easily start almost any server.\n\n1. Installing from apt:\n   ```bash\n   sudo -i\n   apt install -y vim git nginx python3 python3-pip python3-venv\n   ```\n\n2. Next we need to configure nginx:\n   ```bash\n   vim /etc/nginx/nginx.conf \n   ```\n   And paste this:\n   ```nginx\n   user www-data;\n   worker_processes auto;\n   pid /run/nginx.pid;\n   error_log /var/log/nginx/error.log;\n   include /etc/nginx/modules-enabled/*.conf;\n\n   events {\n        worker_connections 768;\n        multi_accept on;\n   }\n\n   http {\n        sendfile off;\n        tcp_nopush on;\n        types_hash_max_size 1024;\n\n        include /etc/nginx/mime.types;\n        default_type application/json;\n\n        ssl_protocols TLSv1.2 TLSv1.3; \n        ssl_prefer_server_ciphers on;\n\n        gzip off;\n\n        include /etc/nginx/conf.d/*.conf;\n        include /etc/nginx/sites-enabled/*;\n   }\n   ```\n3. Then need create on server cloudflare's CA (Origin CA certificates):\n   ```bash\n   mkdir -p /etc/ssl/private\n   cd /etc/ssl/private\n   vim cloudflare.crt\n   vim cloudflare.key\n   chmod 600 cloudflare.key\n   chmod 644 cloudflare.crt\n   chown root:root cloudflare.*\n   cd ~\n   ```\n4. After certificate:\n   ```bash\n   vim /etc/nginx/sites-available/fastapi\n   ```\n   ```nginx\n   server {\n    listen 443 ssl;\n    server_name telegram.koval.page;\n\n    ssl_certificate /etc/ssl/private/cloudflare.crt;\n    ssl_certificate_key /etc/ssl/private/cloudflare.key; \n\n    ssl_protocols TLSv1.2 TLSv1.3;\n    ssl_prefer_server_ciphers off;\n\n    location / {\n        proxy_pass http://localhost:8000;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n\n        proxy_redirect off;\n        proxy_buffering off;\n    }\n   }\n   ```\n   ```bash\n   ln -s /etc/nginx/sites-available/fastapi /etc/nginx/sites-enabled/\n   nginx -t\n   systemctl restart nginx\n   ```\n5. Nginx conf done, let's go to app conf:\n   ```bash\n   exit (if you use `sudo -i` for root login)\n   cd ~\n   git clone https://github.com/koval01/telegram-me\n   cd telegram-me/\n   python3 -m venv venv\n   pip install -U -r requirements.txt\n   ```\n   Okay, after installing requirements need again to root login\n   ```bash\n   sudo -i\n   vim /etc/systemd/system/fastapi.service\n   ```\n   ```service\n   [Unit]\n   Description=FastAPI application\n   After=network.target\n   \n   [Service]\n   User=ubuntu\n   WorkingDirectory=/home/ubuntu/telegram-me\n   ExecStart=/bin/bash -c 'source /home/ubuntu/telegram-me/venv/bin/activate \u0026\u0026 /bin/bash start.sh'\n   Restart=always\n   RestartSec=3\n   \n   [Install]\n   WantedBy=multi-user.target\n   ```\n   ```bash\n   systemctl enable fastapi\n   systemctl start fastapi\n   systemctl status fastapi\n   ```\n   If you see in the status that the application has launched, then consider it done, you've done it. To be sure, you can also use curl to check if the application is running correctly.\n   ```bash\n   curl -IX GET http://localhost:8000/\n   ```\nWell if everything works congratulations, if it doesn't it is also quite possible. Keep in mind that this is just a visual demonstration of one way of real deployment.\n\n## Development\n\nTo develop this project further:\n\n1. Ensure you have Python installed on your machine ([Install Python](https://www.python.org/downloads/)).\n\n2. Create and activate a virtual environment:\n\n   ```bash\n   python3 -m venv .venv\n   . ./.venv/bin/activate\n   ```\n\n3. Install the necessary dependencies:\n\n   ```bash\n   pip install -U -r requirements.txt\n   ```\n\n4. Start the FastAPI app in development mode:\n\n   ```bash\n   uvicorn main:app --reload\n   ```\n\n   This command will start the FastAPI app with automatic reloading enabled, allowing you to make changes and see them reflected immediately.\n\n5. You can now make changes to the codebase, add new features, or fix bugs as needed.\n\nFor more detailed contribution guidelines, please refer to [CONTRIBUTING.md](CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoval01%2Ftelegram-me","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoval01%2Ftelegram-me","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoval01%2Ftelegram-me/lists"}