It connects to Telegram's API. It generates JSON files containing channel's data, including channel's information and posts.

Overview

Telegram API


GitHub stars GitHub watchers Twitter estebanpdl License Open Source Made-with-python


Overview

It connects to Telegram's API. It generates JSON files containing channel's data, including channel's information and posts. You can search for a specific channel, or a set of channels provided in a text file (one channel per line.)

Files are saved by default in a folder called output/data. These folders are created by the script.

โ”œโ”€โ”€๐Ÿ—‚ Telegram-api
|   โ””โ”€โ”€main.py
|   โ””โ”€โ”€๐Ÿ—‚ config
|   	โ””โ”€โ”€config.ini
|   โ””โ”€โ”€๐Ÿ—‚ output
|   	โ””โ”€โ”€collected_chats.csv
|   	โ””โ”€โ”€๐Ÿ—‚ data
|   		โ””โ”€โ”€file_messages.json
|   		โ””โ”€โ”€channel.json
|   		โ””โ”€โ”€etc.

Software required

Python required libraries

Installing

  • Via git clone
git clone https://github.com/estebanpdl/telegram-api.git

This will create a directory called tg-api which contains the Python scripts. Cloning allows you to easily upgrade and switch between available releases.

  • From the github download button

Download the ZIP file from github and use your favorite zip utility to unpack the file tg-api.zip on your preferred location.

After cloning or downloding the repository, install the libraries from requirements.txt.

pip install -r requirements.txt

or

pip3 install -r requirements.txt

Once you obtain an API ID and API hash on my.telegram.org, populate the config/config.ini file with the described values.

[Telegram API credentials]
api_id = api_id
api_hash = api_hash
phone = phone

Example usage

main.py

This Python script will connect to Telegram's API and handle your API request.

Options

  • --telegram-channel Specifies Telegram Channel to download data from.
  • --batch-file File containing Telegram Channels to download data from, one channel per line.
  • --limit-download-to-channel-metadata Will collect channels metadata only, not channel's messages. (default = False)
  • --min-id Specifies the offset id. This will update Telegram data with new posts.

Examples

Basic request

python main.py --telegram-channel channelname`

Expected output

  • Excel file of collected channels
  • JSON file containing channel's profile metadata
  • JSON file containing posts from the requested channel

Request using a text file containing a set of channels

python main.py --batch-file './path/to/channels_text_file.txt'

Expected output

  • Excel file of collected channels
  • JSON files containing channels' profile metadata
  • JSON files containing posts from each requested channel

These examples will retrieve all posts available through the API from the requested channel. If you want to collect channel's information only, without posts, you can run:

Limit download to channel's metadata only

python main.py --telegram-channel channelname --limit-download-to-channel-metadata

or, using a set of telegram channels via a text file:

python main.py --batch-file './path/to/channels_text_file.txt' --limit-download-to-channel-metadata

Updating channel's data

If you want to collect new messages from one channel, you need to identify the message ID from the last post. Once you identify the id, run:

python main.py --telegram-channel channelname --min-id 12345

Expected output

  • Excel file of collected channels - based on new messages
  • JSON file containing channel's profile metadata
  • JSON file containing new messages posted after the requested ID (min ID)

build-datasets.py

python build-datasets.py

This Python script reads the collected files and creates a new dataset containing messages from the requested channels. By default, the created dataset in CSV format will be located in the output folder.

โ”œโ”€โ”€๐Ÿ—‚ Telegram-api
|   โ””โ”€โ”€main.py
|   โ””โ”€โ”€๐Ÿ—‚ output
|   	โ””โ”€โ”€msgs_dataset.csv

channels-to-network.py

python channels-to-network.py

This Python script builds a network graph. By default, the file will be located in the output folder. The script also shows a preliminary graph using the modules matplotlib, networkx, and python-louvain, which implements community detection. You can use import the graph file in different softwares, including Gephi.

โ”œโ”€โ”€๐Ÿ—‚ Telegram-api
|   โ””โ”€โ”€main.py
|   โ””โ”€โ”€๐Ÿ—‚ output
|   	โ””โ”€โ”€Graph.gexf

Owner
Esteban Ponce de Leon
Esteban Ponce de Leon
A file-based quote bot written in Python

Let's Write a Python Quote Bot! This repository will get you started with building a quote bot in Python. It's meant to be used along with the Learnin

1 Feb 03, 2022
A simple anti-ghostping python bot made using diskord.

Anti Ghostping A simple Anti-Ghostping python bot made with โค using Diskord Requirements No one will use this but, all you need for this bot is: Pytho

RyZe 2 Sep 12, 2022
Python client for Invidious' JSON API

Python project template A template for new Python projects. Features Automatically builds PDoc documentation & uploads package to PyPI on new GitHub r

Kevo 2 Jun 05, 2022
Develop and deploy applications with the Ionburst Cloud Python SDK.

Ionburst SDK for Python The Ionburst SDK for Python enables developers to easily integrate with Ionburst Cloud, building in ultra-secure and private o

Ionburst Cloud 3 Mar 06, 2022
A simple bot that lives in your Telegram group, logging messages to a Postgresql database and serving statistical tables and plots to users as Telegram messages.

telegram-stats-bot Telegram-stats-bot is a simple bot that lives in your Telegram group, logging messages to a Postgresql database and serving statist

22 Dec 26, 2022
Telegram File to Link Fastest Bot , also used for movies streaming

Telegram File Stream Bot ! A Telegram bot to stream files to web. Report a Bug | Request Feature About This Bot This bot will give you stream links fo

Avishkar Patil 194 Jan 07, 2023
A script written in python3 for bruteforcing Gmail accounts.

GmailBruteforce Made for bruteforcing gmail accounts. It needs Less Secure Apps setting turned on in order to work. Installation For windows git clone

Shinero 4 Sep 16, 2022
A simple Telegram bot that can broadcast messages and media to the bot subscribers. with mongo DB support

๐˜ฝ๐™ง๐™ค๐™–๐™™๐™˜๐™–๐™จ๐™ฉ ๐˜ฝ๐™ค๐™ฉ A simple Telegram bot that can broadcast messages and media to the bot subscribers using MongoDB. Features Support mongodb.c

N A C BOTS 70 Jan 02, 2023
Official python API for Phish.AI public and private API to detect zero-day phishing websites

phish-ai-api Summary Official python API for Phish.AI public and private API to detect zero-day phishing websites How it Works (TLDR) Essentially we h

Phish.AI 168 May 17, 2022
This is a music bot for discord written in python

this is a music bot for discord written in python, it is designed for educational use ONLY, I do not take any responsibility for uses outside of educational use

5 Dec 24, 2021
A bot to get Statistics like the Playercount from your Minecraft-Server on your Discord-Server

Hey Thanks for reading me. Warning: My English is not the best I have programmed this bot to show me statistics about the player numbers and ping of m

spaffel 12 Sep 24, 2022
Ubuntu env build; Nginx build; DB build;

Deploy ไป‹็ป Deploy related scripts bitnami Dependencies Ubuntu openssl envsubst docker v18.06.3 docker-compose init base env upload https://gitlab-runn

Colin(liuji) 10 Dec 01, 2021
Zendesk Ticket Viewer is a lightweight commandline client for fetching and displaying tickets from a Zendesk account provided by the user

Zendesk Ticket Viewer is a lightweight commandline client for fetching and displaying tickets from a Zendesk account provided by the user.

Parthesh Soni 1 Jan 24, 2022
An alternative launcher for Lunar Client which is aimed at portability and functionality.

Portaluna An alternative launcher for Lunar Client which is aimed at portability and functionality. Features Portable. Lightweight. Functional. Note:

4 Mar 05, 2022
Tools for use in DeFi. Impermanent Loss calculations, staking and farming strategies, coingecko and pancakeswap API queries, liquidity pools and more

DeFi open source tools Get Started Instalation General Tools Impermanent Loss, simple calculation Compare Buy & Hold with Staking and Farming Complete

Juan Pablo Pisano 467 Jan 08, 2023
ETL for tononkira.serasera.org

python-tononkiramalagasy-api Api Endpoints: ### get artists - /artists/int:page [page_offset = 20] ### get artist's songs, index was given by

Titosy Manankasina 1 Dec 24, 2021
A new coin listing alert bot using Python, Flask, MongoDB, Telegram API and Binance API

Bzzmans New Coin Listing Detection Bot Architecture About Project Work in progress. This bot basically gets new coin listings from Binance using Binan

Eyรผp Barlas 21 May 31, 2022
DSAIL repos - DSAIL Repository Template

DSAIL Repository Template DSAIL @ KAIST . โ”œโ”€โ”€ configs ('--F', help='for configur

yunhak 2 Feb 14, 2022
A VCVideoPlayer Bot for Telegram made with ๐Ÿ’ž By @TeamDeeCoDe

VC Video Player How To Host โœจ Heroku Deploy โœจ The easiest way to deploy this Bot is via Heroku. Credit ๐Ÿ”ฅ |๐Ÿ‡ฎ๐Ÿ‡ณ Louis |๐Ÿ‡ฎ๐Ÿ‡ณ Sammy |๐Ÿ‡ฎ๐Ÿ‡ณ Blaze |๐Ÿ‡ฎ๐Ÿ‡ณ S

TeamDeeCode 6 Feb 28, 2022
MusicBot is the original Discord music bot written for Python 3.5+, using the discord.py library

The original MusicBot for Discord (formerly SexualRhinoceros/MusicBot)

Just Some Bots 2.9k Jan 02, 2023