Skip to content

How to send a file by uploading it from disk#

Installation#

python -m pip install telegram-api-client-python

Import#

from telegram_api_client_python import API

Example#

How to initialize an object#

greenAPI = API.GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)

How to send a file by uploading it from disk#

A synchronous example:

response = greenAPI.sending.sendFileByUpload(
    "79876543210@c.us",
    "data/rates.png",
    "rates.png",
    "Available rates"
)
print(response.data)

An asynchronous example:

response = await greenAPI.sending.sendFileByUploadAsync(
    "79876543210@c.us",
    "data/rates.png",
    "rates.png",
    "Available rates"
)
print(response.data)

The full list of examples#

Description Module
An example of sending text sendtMessage.py
An example of sending an image by URL sendFileByUrl.py
An example of sending an image by uploading it from disk sendFileByUpload.py
An example of creating a group and sending a message to the group createGroupAndSendMessage.py
An example of receiving incoming notifications receiveNotification.py