88
99- [ Документация на русском языке] ( https://github.com/green-api/whatsapp-api-client-python/blob/master/README_RUS.md ) .
1010
11- Python library for integration with WhatsAPP messanger via API of [ green-api.com ] ( https://green-api.com/en/ ) service. To
12- use the library you have to get a registration token and an account id in
13- the [ personal cabinet] ( https://console.green-api.com/ ) . There is a free developer account tariff plan .
11+ whatsapp-api-client-python is a library for integration with WhatsApp messenger using the API
12+ service [ green-api.com ] ( https://green-api.com/en/ ) . You should get a registration token and an account ID in
13+ your [ personal cabinet] ( https://console.green-api.com/ ) to use the library . There is a free developer account tariff.
1414
1515## API
1616
17- You can find REST API documentation by [ link] ( https://green-api.com/en/docs/ ) . The library is a wrapper for REST API,
18- so the documentation at the above url applies to the library as well .
17+ The documentation for the REST API can be found at the [ link] ( https://green-api.com/en/docs/ ) . The library is a wrapper
18+ for the REST API, so the documentation at the link above also applies.
1919
2020## Authorization
2121
22- To send a message or perform other Green API methods, the WhatsApp account in the phone app must be authorized. To
22+ To send a message or perform other GREEN API methods, the WhatsApp account in the phone app must be authorized. To
2323authorize the account, go to your [ cabinet] ( https://console.green-api.com/ ) and scan the QR code using the WhatsApp app.
2424
2525## Installation
@@ -39,7 +39,9 @@ from whatsapp_api_client_python import API
3939### How to initialize an object
4040
4141```
42- greenAPI = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
42+ greenAPI = API.GreenApi(
43+ "1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
44+ )
4345```
4446
4547### Sending a text message to a WhatsApp number
@@ -49,7 +51,9 @@ https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/sen
4951).
5052
5153```
52- greenAPI.sending.sendMessage('11001234567@c.us', 'Message text')
54+ response = greenAPI.sending.sendMessage("11001234567@c.us", "Message text")
55+
56+ print(response.data)
5357```
5458
5559### Sending an image via URL
@@ -59,12 +63,13 @@ https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/sen
5963).
6064
6165```
62- greenAPI.sending.sendFileByUrl(
63- '11001234567@c.us',
64- 'https://www.google.ru/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png',
65- 'googlelogo_color_272x92dp.png',
66- 'Google logo'
66+ response = greenAPI.sending.sendFileByUrl(
67+ "11001234567@c.us",
68+ "https://green-api.com/green-api-logo_2.png",
69+ "green-api-logo_2.png"
6770)
71+
72+ print(response.data)
6873```
6974
7075### Sending an image by uploading from the disk
@@ -74,34 +79,29 @@ https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/sen
7479).
7580
7681```
77- greenAPI.sending.sendFileByUpload(
78- '11001234567@c.us',
79- 'C:\Games\PicFromDisk.png',
80- 'PicFromDisk.png',
81- 'Picture from disk'
82+ response = greenAPI.sending.sendFileByUpload(
83+ "11001234567@c.us", "data/green-api-logo_2.png"
8284)
85+
86+ print(response.data)
8387```
8488
8589### Group creation and sending a message to the group
8690
87- IMPORTANT: If one tries to create a group with a non-existent number, WhatsApp may block the sender's number. The number
88- in the example is non-existent.
91+ ** Attention ** . If one tries to create a group with a non-existent number, WhatsApp may block the sender's number. The
92+ number in the example is non-existent.
8993
9094Link to example: [ createGroupAndSendMessage.py] (
9195https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/createGroupAndSendMessage.py
9296).
9397
9498```
95- chatIds = [
96- "11001234567@c.us"
97- ]
98- resultCreate = greenAPI.groups.createGroup(
99- 'GroupName', chatIds
99+ create_group_response = greenAPI.groups.createGroup(
100+ "Group Name", ["11001234567@c.us"]
100101)
101-
102- if resultCreate.code == 200:
103- resultSend = greenAPI.sending.sendMessage(
104- resultCreate.data['chatId'], 'Message text'
102+ if create_group_response.code == 200:
103+ send_message_response = greenAPI.sending.sendMessage(
104+ create_group_response.data["chatId"], "Message text"
105105 )
106106```
107107
@@ -111,24 +111,27 @@ Link to example: [receiveNotification.py](
111111https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/receiveNotification.py
112112).
113113
114- The general concept of receiving data in the Green API is described [ here] ( https://green-api.com/en/docs/api/receiving/ )
115- To start receiving messages by the HTTP API you need to execute the library method:
114+ The general concept of receiving data in the GREEN API is described [ here] (
115+ https://green-api.com/en/docs/api/receiving/
116+ ). To start receiving notifications by the HTTP API you need to execute the library method:
116117
117118```
118119greenAPI.webhooks.startReceivingNotifications(onEvent)
119120```
120121
121- onEvent - your method which should contain parameters:
122+ onEvent - your function which should contain parameters:
122123
123- | Parameter | Description |
124- | -------------| --------------------------------|
125- | typeWebhook | received message type (string ) |
126- | body | message body (json) |
124+ | Parameter | Description |
125+ | -------------| ---------------------------------- |
126+ | typeWebhook | received notification type (str ) |
127+ | body | notification body (dict) |
127128
128- Message body types and formats [ here] ( https://green-api.com/en/docs/api/receiving/notifications-format/ ) .
129+ Notification body types and formats can be found [ here] (
130+ https://green-api.com/en/docs/api/receiving/notifications-format/
131+ ).
129132
130- This method will be called when an incoming message is received. Next, process messages according to the business logic
131- of your system.
133+ This method will be called when an incoming notification is received. Next, process notifications according to the
134+ business logic of your system.
132135
133136## Examples list
134137
@@ -199,7 +202,7 @@ of your system.
199202
200203## External products
201204
202- - [ requests] ( https://requests.readthedocs.io/en/latest/ ) - for http requests.
205+ - [ requests] ( https://requests.readthedocs.io/en/latest/ ) - for HTTP requests.
203206
204207## License
205208
0 commit comments