Skip to content

How to send a file by uploading from the disk#

Installation#

python -m pip install whatsapp-api-client-python

Import#

from whatsapp_api_client_python import API

Examples#

How to initialize an object#

greenAPI = API.GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)

How to send a file by uploading from the disk#

Synchronous version:

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

Asynchronous version:

response = await greenAPI.sending.sendFileByUploadAsync(
    "79876543210@c.us",
    "data/logo.jpg",
    "logo.jpg",
    "logo"
)
print(response.data)

Examples list#

Description Module
Example of sending text sendTextMessage.py
Example of sending text asynchronously sendMessageAsync.py
Example of sending a picture by URL sendPictureByLink.py
Example of sending a file by URL asynchronously sendFileByUrlAsync.py
Example of sending a picture by uploading from the disk sendPictureByUpload.py
Example of sending file by uploading from the disk asynchronously sendFileByUploadAsync.py
Example of a group creation and sending a message to the group createGroupAndSendMessage.py
Example of a group creation and sending a message to the group asynchronously createGroupAndSendMessageAsync.py
Example of incoming webhooks receiving receiveNotification.py
Example of incoming webhooks receiving asynchronously receiveNotificationAsync.py
Example of sending a polling message sendPoll.py
Example of sending a polling message asynchronously sendPollAsync.py