Skip to content

Commit 109adff

Browse files
committed
Updated docs
1 parent 476eb94 commit 109adff

File tree

2 files changed

+80
-77
lines changed

2 files changed

+80
-77
lines changed

README.md

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
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
2323
authorize 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

9094
Link to example: [createGroupAndSendMessage.py](
9195
https://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](
111111
https://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
```
118119
greenAPI.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

README_RUS.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
![](https://img.shields.io/github/actions/workflow/status/green-api/whatsapp-api-client-python/python-package.yml)
77
![](https://img.shields.io/pypi/dm/whatsapp-api-client-python)
88

9-
Python библиотека для интеграции с мессенджером WhatsApp через API сервиса [green-api.com](https://green-api.com/).
10-
Чтобы воспользоваться библиотекой, нужно получить регистрационный токен и ID аккаунта
11-
в [личном кабинете](https://console.green-api.com/). Есть бесплатный тариф аккаунта разработчика.
9+
whatsapp-api-client-python - библиотека для интеграции с мессенджером WhatsApp через API
10+
сервиса [green-api.com](https://green-api.com/). Чтобы воспользоваться библиотекой, нужно получить регистрационный токен
11+
и ID аккаунта в [личном кабинете](https://console.green-api.com/). Есть бесплатный тариф аккаунта разработчика.
1212

1313
## API
1414

@@ -38,85 +38,85 @@ from whatsapp_api_client_python import API
3838
### Как инициализировать объект
3939

4040
```
41-
greenAPI = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
41+
greenAPI = API.GreenApi(
42+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
43+
)
4244
```
4345

4446
### Отправка текстового сообщения на номер WhatsApp
4547

4648
Ссылка на пример: [sendTextMessage.py](examples/sendTextMessage.py).
4749

4850
```
49-
greenAPI.sending.sendMessage('11001234567@c.us', 'Message text')
51+
response = greenAPI.sending.sendMessage("11001234567@c.us", "Message text")
52+
53+
print(response.data)
5054
```
5155

5256
### Отправка картинки по URL
5357

5458
Ссылка на пример: [sendPictureByLink.py](examples/sendPictureByLink.py).
5559

5660
```
57-
greenAPI.sending.sendFileByUrl(
58-
'11001234567@c.us',
59-
'https://www.google.ru/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png',
60-
'googlelogo_color_272x92dp.png',
61-
'Google logo'
61+
response = greenAPI.sending.sendFileByUrl(
62+
"11001234567@c.us",
63+
"https://green-api.com/green-api-logo_2.png",
64+
"green-api-logo_2.png"
6265
)
66+
67+
print(response.data)
6368
```
6469

6570
### Отправка картинки загрузкой с диска
6671

6772
Ссылка на пример: [sendPictureByUpload.py](examples/sendPictureByUpload.py).
6873

6974
```
70-
greenAPI.sending.sendFileByUpload(
71-
'11001234567@c.us',
72-
'C:\\Games\\PicFromDisk.png',
73-
'PicFromDisk.png',
74-
'Picture from disk'
75+
response = greenAPI.sending.sendFileByUpload(
76+
"11001234567@c.us", "data/green-api-logo_2.png"
7577
)
78+
79+
print(response.data)
7680
```
7781

7882
### Создание группы и отправка сообщения в эту группу
7983

80-
ВАЖНО: Если попытаться создать группу с несуществующим номером WhatsApp может заблокировать номер отправителя. Номер в
81-
примере не существует.
84+
**Важно**. Если попытаться создать группу с несуществующим номером WhatsApp, то может заблокировать номер отправителя.
85+
Номер в примере не существует.
8286

8387
Ссылка на пример: [createGroupAndSendMessage.py](examples/createGroupAndSendMessage.py).
8488

8589
```
86-
chatIds = [
87-
"11001234567@c.us"
88-
]
89-
resultCreate = greenAPI.groups.createGroup(
90-
'GroupName', chatIds
90+
create_group_response = greenAPI.groups.createGroup(
91+
"Group Name", ["11001234567@c.us"]
9192
)
92-
93-
if resultCreate.code == 200:
94-
resultSend = greenAPI.sending.sendMessage(
95-
resultCreate.data['chatId'], 'Message text'
93+
if create_group_response.code == 200:
94+
send_message_response = greenAPI.sending.sendMessage(
95+
create_group_response.data["chatId"], "Message text"
9696
)
9797
```
9898

99-
### Получение входящих сообщений через HTTP API
99+
### Получение входящих уведомлений через HTTP API
100100

101101
Ссылка на пример: [receiveNotification.py](examples/receiveNotification.py).
102102

103-
Общая концепция получения данных в Green API описана [здесь](https://green-api.com/docs/api/receiving/). Для старта
104-
получения сообщений через HTTP API требуется выполнить метод библиотеки:
103+
Общая концепция получения данных в GREEN API описана [здесь](https://green-api.com/docs/api/receiving/). Для старта
104+
получения уведомлений через HTTP API требуется выполнить метод библиотеки:
105105

106106
```
107107
greenAPI.webhooks.startReceivingNotifications(onEvent)
108108
```
109109

110-
onEvent - ваш метод, который должен содержать параметры:
110+
onEvent - ваша функция, которая должен содержать параметры:
111111

112-
| Параметр | Описание |
113-
|-------------|------------------------------------|
114-
| typeWebhook | тип полученного сообщения (строка) |
115-
| body | тело сообщения (json) |
112+
| Параметр | Описание |
113+
|-------------|-----------------------------------|
114+
| typeWebhook | тип полученного уведомления (str) |
115+
| body | тело уведомления (dict) |
116116

117-
Типы и форматы тел сообщений [здесь](https://green-api.com/docs/api/receiving/notifications-format/).
117+
Типы и форматы тел уведомлений находятся [здесь](https://green-api.com/docs/api/receiving/notifications-format/).
118118

119-
Этот метод будет вызываться при получении входящего сообщения. Далее обрабатываете сообщения согласно бизнес-логике
119+
Эта функция будет вызываться при получении входящего уведомления. Далее обрабатываете уведомления согласно бизнес-логике
120120
вашей системы.
121121

122122
## Список примеров
@@ -188,7 +188,7 @@ onEvent - ваш метод, который должен содержать па
188188

189189
## Сторонние продукты
190190

191-
- [requests](https://requests.readthedocs.io/en/latest/) - для http запросов.
191+
- [requests](https://requests.readthedocs.io/en/latest/) - для HTTP запросов.
192192

193193
## Лицензия
194194

0 commit comments

Comments
 (0)