Create a Virtual Environments (venv)
python3 -m venv venv
Move into Virtual Environments workspace
. venv/bin/activate
Install all python packages
python -m pip install -r requirements.txt
Copy example.configs.ini
to configs.ini
cp configs/example.configs/ini configs/configs.ini
python3 telegram_api.py
set log levels with the logs
variable. Default = "INFO"
logs=debug python3 telegram_api.py
POST /
{
"phonenumber": "[country_code][number]"
}
- If the user already has an active session, a
200
is sent back- If the user does not have an active session a
201
is sent back and a code is sent either to their Telegram App or via SMS. You should request and provide this code to finish the start session process. See Provide Code
PUT /
{
"phonenumber": "[country_code][number]",
"code": "[code]"
}
- If the user does not have a Telegram account a
202
is sent back. See Register user- If the code is wrong a
403
is sent back.- If the code is correct a
200
is sent back and an object
{
"phonenumber": "",
"profile": {}
}
- To continue using SWoB App, user must register a Telegram account by providing first and last name
POST /users
{
"phonenumber": "[country_code][number]",
"first_name": "",
"last_name": ""
}
- Returns
200
if successful and500
for any error
- Deleting the record of a user stored on local server. (Does not delete user from Telegram global server).
DELETE /users
{
"phonenumber": "[country_code][number]"
}
- Returns
200
if successful and500
for any error
- Fetch all user's telegram contacts
POST /contacts
{
"phonenumber": "[country_code][number]"
}
- Returns
200
if successful and500
for any error
- Fetch all user's active telegram chats
POST /dialogs
{
"phonenumber": "[country_code][number]"
}
- Returns
200
if successful and500
for any error
- Send a telegram message
- If the recipient's contact is not in the user's contact list, it will be imported automatically in order for the telegram message to be sent.
POST /message
{
"phonenumber": "[country_code][number]",
"recipient": "[country_code][number] or username or user ID",
"text": "Hello World!"
}
- If the
recipient
does not have a telegram account a422
is sent back.- Returns
200
if successful and500
for any error