diff --git a/skills/SKILL.md b/skills/SKILL.md new file mode 100644 index 0000000..2143f76 --- /dev/null +++ b/skills/SKILL.md @@ -0,0 +1,340 @@ +--- +name: greenapi-client-python +description: > + Write correct Python code with the official GREEN-API SDK whatsapp-api-client-python + (package whatsapp_api_client_python). Use when sending/receiving WhatsApp messages, + files, polls, groups, journals, queues, statuses, contacts, partner instances, polling + notifications, or configuring a GREEN-API instance in Python. Triggers: GREEN-API, + green-api, whatsapp-api-client-python, GreenAPI, GreenApi, sendMessage, receiveNotification. +license: MIT +metadata: + version: "1.0.0" + sdk: whatsapp-api-client-python + pypi: whatsapp-api-client-python + docs: https://green-api.com/en/docs/api/ + github: https://github.com/green-api/whatsapp-api-client-python +--- + +# GREEN-API Python client (`whatsapp-api-client-python`) + +## When to apply + +Use this skill whenever the task is to call GREEN-API from **Python** via the official +SDK. Do **not** invent HTTP paths or method names from memory: only methods listed in +[references/inventory.md](references/inventory.md) exist in this SDK. Semantics of +parameters, `chatId` formats, delays, and notification types come from the official docs +linked in each method section — not from other repos. + +For **webhook HTTP server** libraries in other languages, use a language-specific +webhook skill if present. This SDK receives notifications via **polling** +(`webhooks.startReceivingNotifications` / `receiving.receiveNotification`) or you can +build your own HTTP endpoint for webhook-endpoint technology. + +## Sources of truth (mandatory) + +1. **Official API docs** — https://green-api.com/en/docs/api/ + Parameters, response shapes, limits, `chatId`, delays, notification formats. +2. **This repository / installed package** — method names, class attributes, init + signatures. Inventory: [references/inventory.md](references/inventory.md). + +If a method exists in the docs but **not** in the inventory → do not use it in code. + +## Install + +```shell +python -m pip install whatsapp-api-client-python +``` + +Requires Python **>= 3.10**. Credentials: `idInstance` and `apiTokenInstance` from +[console.green-api.com](https://console.green-api.com/). + +## Client initialization + +```python +from whatsapp_api_client_python import API + +greenAPI = API.GreenAPI( + "1101000001", # idInstance (string) + "d75b3a66374942c5b3c019c698abc2067e151558acbd412345", # apiTokenInstance +) +``` + +Optional constructor kwargs (from `GreenApi.__init__` in `API.py`): + +| Kwarg | Default | Meaning | +| --- | --- | --- | +| `debug_mode` | `False` | Verbose request logging | +| `raise_errors` | `False` | Raise `GreenAPIError` on failures | +| `host` | `https://api.green-api.com` | API host (`apiUrl`) | +| `media` | `https://media.green-api.com` | Media host for uploads | +| `host_timeout` | `180` | Seconds per host request retry | +| `media_timeout` | `10800` | Seconds per media request | + +Aliases: `API.GreenAPI` is the same class as `API.GreenApi`. + +Partner API (separate client): + +```python +partner = API.GreenApiPartner(partnerToken="PARTNER_TOKEN") +# then: partner.partner.getInstances() / createInstance / deleteInstanceAccount +``` + +### Response object + +Every API method returns `whatsapp_api_client_python.response.Response`: + +| Attribute | When | Content | +| --- | --- | --- | +| `code` | always | HTTP status, or `None` on transport failure | +| `data` | `code == 200` | Parsed JSON (`dict` / list) | +| `error` | non-200 | Response body text | + +Always check `response.code == 200` before reading `response.data`. + +### Async + +Most groups expose `*Async` twins (`sendMessageAsync`, `receiveNotificationAsync`, …). +Call them with `await` inside `asyncio`. + +## chatId and phone format + +Docs: https://green-api.com/en/docs/api/chat-id/ + +| Kind | Format | Example | +| --- | --- | --- | +| Personal chat | `@c.us` | `79876543210@c.us` | +| Group chat | `...@g.us` | `120363043968066561@g.us` | +| Lid | `...@lid` | returned by API; do not invent | + +- Phone: full international number, **digits only**, no `+`, spaces, or leading zeros tricks. +- **Never** hand-craft group IDs — take them from `createGroup`, journals, or notifications. +- Wrong `chatId` → validation 400: must be `phone_number@c.us` or `group_id@g.us`. + +## Instance must be authorized + +Docs: https://green-api.com/en/docs/api/account/GetStateInstance/ + +Before sending, verify: + +```python +state = greenAPI.account.getStateInstance() +print(state.data) # expect {"stateInstance": "authorized"} +``` + +Important states: `authorized`, `notAuthorized`, `blocked`, `starting`, `suspended`. +Authorize via console QR / `account.qr()` / `account.getAuthorizationCode(phoneNumber)`. +Messages sit in the send queue up to **24 hours** until the instance is authorized. + +## Message sending delay + +Docs: https://green-api.com/en/docs/api/send-messages-delay/ + +Outgoing messages go through a FIFO queue. Delay is controlled by instance setting +`delaySendMessagesMilliseconds` (min **500** ms, max **600000** ms; recommend ≤ 300000): + +```python +greenAPI.account.setSettings({"delaySendMessagesMilliseconds": 5000}) +``` + +Note: `setSettings` reboots the instance; settings apply within ~5 minutes. + +## Typical scenarios + +### 1. Send a text message + +Docs: https://green-api.com/en/docs/api/sending/SendMessage/ + +```python +from whatsapp_api_client_python import API + +greenAPI = API.GreenAPI(id_instance, api_token) + +response = greenAPI.sending.sendMessage( + "79876543210@c.us", + "Hello from GREEN-API", + typingTime=3000, # optional: 1000–20000 ms typing indicator +) + +if response.code == 200: + print(response.data["idMessage"]) +else: + print(response.error) +``` + +Required: `chatId`, `message` (max 20000 chars). Optional in SDK: `quotedMessageId`, +`archiveChat`, `linkPreview`, `typingTime`, `typePreview`, `customPreview`. +Response: `{ "idMessage": "..." }`. + +### 2. Send a file by URL + +Docs: https://green-api.com/en/docs/api/sending/SendFileByUrl/ + +```python +response = greenAPI.sending.sendFileByUrl( + "79876543210@c.us", + "https://download.samplelib.com/png/sample-clouds2-400x300.png", + "sample-clouds2-400x300.png", + "Caption text", +) +``` + +Required: `chatId`, `urlFile`, `fileName` (with extension). Max file size **100 MB**. + +### 3. Send a file by upload (local path) + +Docs: https://green-api.com/en/docs/api/sending/SendFileByUpload/ +Uses **media** host (SDK sets this automatically). + +```python +response = greenAPI.sending.sendFileByUpload( + "79876543210@c.us", + "data/logo.jpg", + "logo.jpg", + "Available rates", +) +# response.data: idMessage, urlFile (link valid 15 days) +``` + +SDK signature: `sendFileByUpload(chatId, path, fileName=None, caption=None, ...)`. +The local path is the second argument (`path`), not a raw file object. + +### 4. Receive notifications — polling (built-in) + +Docs: https://green-api.com/en/docs/api/receiving/technology-http-api/ReceiveNotification/ + +**Requirement:** instance `webhookUrl` must be **empty**. If a custom webhook URL is set, +`receiveNotification` returns an error telling you to clear it. + +```python +from whatsapp_api_client_python import API + +greenAPI = API.GreenAPI(id_instance, api_token) + + +def on_event(type_webhook: str, body: dict) -> None: + if type_webhook == "incomingMessageReceived": + chat_id = body["senderData"]["chatId"] + msg = body["messageData"] + if msg.get("typeMessage") == "textMessage": + text = msg["textMessageData"]["textMessage"] + print(chat_id, text) + + +# Blocks; Ctrl+C to stop. Internally: receiveNotification → handler → deleteNotification +greenAPI.webhooks.startReceivingNotifications(on_event) +``` + +Handler signature is fixed: `(typeWebhook: str, body: dict)`. +After handling, the SDK deletes the notification by `receiptId` (do not skip this +if you poll manually). + +Manual poll loop: + +```python +resp = greenAPI.receiving.receiveNotification(receiveTimeout=5) +if resp.code == 200 and resp.data: + receipt_id = resp.data["receiptId"] + body = resp.data["body"] + # ... process body["typeWebhook"] ... + greenAPI.receiving.deleteNotification(receipt_id) +``` + +`receiveTimeout`: 5–60 seconds (API default 5). Empty queue → empty body / no data. +Notifications live in the queue **24 hours**, FIFO. + +### 5. Receive notifications — webhook endpoint (your HTTP server) + +Docs: https://green-api.com/en/docs/api/receiving/technology-webhook-endpoint/ + +This SDK does **not** ship a webhook HTTP server. Configure the instance, then run your +own endpoint that accepts POST JSON and returns 200: + +```python +greenAPI.account.setSettings({ + "webhookUrl": "https://your.public.host/webhook", + "webhookUrlToken": "Bearer your-secret", # optional; see docs for Basic/Bearer + "incomingWebhook": "yes", + "outgoingWebhook": "yes", + "outgoingAPIMessageWebhook": "yes", + "stateWebhook": "yes", +}) +``` + +GREEN-API POSTs notification JSON to `webhookUrl`. Retries every ~1 minute; guaranteed +within 24 hours. While `webhookUrl` is set, **polling will not receive** those notifications. + +Common `typeWebhook` values: `incomingMessageReceived`, `outgoingMessageReceived`, +`outgoingAPIMessageReceived`, `outgoingMessageStatus`, `stateInstanceChanged`, +`statusInstanceChanged`, `incomingCall`, `outgoingCall`, `quotaExceeded`, … +Full list: https://green-api.com/en/docs/api/receiving/notifications-format/type-webhook/ + +### 6. Create a group and message it + +Docs: https://green-api.com/en/docs/api/groups/CreateGroup/ + +```python +created = greenAPI.groups.createGroup("Group Name", ["79876543210@c.us"]) +if created.code == 200 and created.data.get("created"): + chat_id = created.data["chatId"] # ...@g.us + greenAPI.sending.sendMessage(chat_id, "Hello group") +``` + +Do not create groups faster than about **1 per 5 minutes** (anti-spam). Invalid numbers +can get the sender blocked. + +## API surface map (SDK attributes) + +Access as `greenAPI..(...)`. + +| Attribute | Class | Reference | +| --- | --- | --- | +| `account` | `Account` | [references/account.md](references/account.md) | +| `sending` | `Sending` | [references/sending.md](references/sending.md) | +| `receiving` | `Receiving` | [references/receiving.md](references/receiving.md) | +| `webhooks` | `Webhooks` | [references/receiving.md](references/receiving.md) | +| `groups` | `Groups` | [references/groups.md](references/groups.md) | +| `journals` | `Journals` | [references/journals.md](references/journals.md) | +| `queues` | `Queues` | [references/queues.md](references/queues.md) | +| `serviceMethods` | `ServiceMethods` | [references/service-methods.md](references/service-methods.md) | +| `marking` | `Marking` | [references/marking.md](references/marking.md) | +| `contacts` | `Contacts` | [references/contacts.md](references/contacts.md) | +| `statuses` | `Statuses` | [references/statuses.md](references/statuses.md) | +| `device` | `Device` | [references/device.md](references/device.md) | +| `partner` | `Partner` | only on `GreenApiPartner` — [references/partner.md](references/partner.md) | + +Full method list + signatures: [references/inventory.md](references/inventory.md). + +## Pitfalls (read before coding) + +1. **`chatId` format** — personal `phone@c.us`, group `id@g.us`. No `+` in the phone part. +2. **Authorized instance** — `getStateInstance` must be `authorized` for delivery. +3. **Polling vs webhook** — mutually exclusive for the same traffic: clear `webhookUrl` + for HTTP API polling; set `webhookUrl` for push. +4. **Always `deleteNotification`** after processing a polled notification, or the same + event will be returned forever. +5. **Sending delay** — use `delaySendMessagesMilliseconds` ≥ 500 ms; bulk blasts without + delay risk limits / bans. +6. **File size** — max 100 MB; `sendFileByUpload` goes to `media.green-api.com`. +7. **Response handling** — use `response.data` only when `response.code == 200`. +8. **Deprecated sending APIs** still in SDK but marked deprecated: `sendButtons`, + `sendTemplateButtons`, `sendListMessage`, `sendLink` — prefer + `sendInteractiveButtons` / `sendInteractiveButtonsReply` / `sendMessage`. +9. **`serviceMethods` attribute name** — camelCase `serviceMethods`, not `service`. +10. **Partner methods** require `GreenApiPartner`, not `GreenAPI`. +11. **Groups rate limit** — create groups slowly; non-existent numbers are dangerous. +12. **Hosts** — default `api.green-api.com` / `media.green-api.com`; some accounts use + instance-specific hosts from console — pass `host=` / `media=` if console shows them. + +## Agent checklist + +When writing code for the user: + +- [ ] Import `from whatsapp_api_client_python import API` +- [ ] Init `API.GreenAPI(idInstance, apiTokenInstance)` with real or env credentials +- [ ] Use only methods from [references/inventory.md](references/inventory.md) +- [ ] Format `chatId` as `@c.us` / `@g.us` +- [ ] Check `response.code` before `response.data` +- [ ] For receive: either polling (`startReceivingNotifications` / manual receive+delete) + or webhook endpoint + `setSettings`, not a fictional SDK method +- [ ] Prefer reading the matching `references/*.md` file for parameters before coding +- [ ] Prefer official docs URL from the method docstring when unsure about edge cases diff --git a/skills/references/account.md b/skills/references/account.md new file mode 100644 index 0000000..14473ff --- /dev/null +++ b/skills/references/account.md @@ -0,0 +1,97 @@ +# Account (`greenAPI.account`) + +Class: `Account` in `tools/account.py`. +Index: https://green-api.com/en/docs/api/account/ + +## `getSettings` / `setSettings` + +- Get: https://green-api.com/en/docs/api/account/GetSettings/ +- Set: https://green-api.com/en/docs/api/account/SetSettings/ + +`setSettings(requestBody: dict)` — pass only fields to change. **Reboots instance**; +settings apply within ~5 minutes. Defaults after create: webhooks off. + +Important keys (docs): + +| Key | Values / notes | +| --- | --- | +| `webhookUrl` | URL or `""` to disable push / enable polling | +| `webhookUrlToken` | optional auth token for your server | +| `delaySendMessagesMilliseconds` | 500–600000; recommend ≤ 300000 | +| `incomingWebhook` | `yes` / `no` | +| `outgoingWebhook` | `yes` / `no` (statuses) | +| `outgoingMessageWebhook` | phone-sent messages | +| `outgoingAPIMessageWebhook` | API-sent messages | +| `stateWebhook` | auth state changes | +| `incomingCallWebhook` | calls | +| `pollMessageWebhook` | polls | +| `editedMessageWebhook` / `deletedMessageWebhook` | edits/deletes | +| `markIncomingMessagesReaded` | `yes` / `no` | +| `keepOnlineStatus` | keep online when phone off | +| `linkPreview` | `yes` / `no` | +| `autoTyping` | 0–10 typing speed preset | +| `enableLidMode` | work with `@lid` chatIds | + +```python +greenAPI.account.setSettings({ + "delaySendMessagesMilliseconds": 5000, + "incomingWebhook": "yes", + "webhookUrl": "", +}) +``` + +## `getStateInstance` + +Docs: https://green-api.com/en/docs/api/account/GetStateInstance/ + +Returns `{ "stateInstance": "..." }`: + +| State | Meaning | +| --- | --- | +| `authorized` | ready | +| `notAuthorized` | scan QR / auth code | +| `blocked` | banned | +| `starting` | booting (wait) | +| `suspended` | temporary restrictions | +| `sleepMode` | outdated status | +| `yellowCard` | deprecated → use `suspended` | + +## `getStatusInstance` + +Docs: https://green-api.com/en/docs/api/account/GetStatusInstance/ +Socket connection status with WhatsApp (archive section in docs). + +## `getWaSettings` + +Docs: https://green-api.com/en/docs/api/account/GetWaSettings/ +WhatsApp account information for the linked number. + +## `qr` + +Docs: https://green-api.com/en/docs/api/account/QR/ +Returns QR payload for authorization. + +## `getAuthorizationCode` + +Docs: https://green-api.com/en/docs/api/account/GetAuthorizationCode/ +`phoneNumber: int` — link by phone number (international digits). + +## `reboot` / `logout` + +- https://green-api.com/en/docs/api/account/Reboot/ +- https://green-api.com/en/docs/api/account/Logout/ + +## `setProfilePicture` + +Docs: https://green-api.com/en/docs/api/account/SetProfilePicture/ +SDK: `setProfilePicture(path)` local image path. + +## `getStateInstanceHistory` + +Docs: https://green-api.com/en/docs/api/account/GetStateInstanceHistory/ +Optional query `count`. + +## `updateApiToken` + +Docs: https://green-api.com/en/docs/api/account/UpdateApiToken/ +Generates a new `apiTokenInstance` — store the new token after success. diff --git a/skills/references/contacts.md b/skills/references/contacts.md new file mode 100644 index 0000000..64437c9 --- /dev/null +++ b/skills/references/contacts.md @@ -0,0 +1,19 @@ +# Contacts (`greenAPI.contacts`) + +Class: `Contacts` in `tools/contacts.py`. +Index: https://green-api.com/en/docs/api/contacts/ + +These manage the WhatsApp **address book** of the linked account (add/edit/delete contact). +For listing contacts / contact info, use `serviceMethods.getContacts` / `getContactInfo`. + +| Method | Params | Docs | +| --- | --- | --- | +| `addContact` | `chatId`, `firstName`, optional `lastName`, `saveInAddressbook=True` | https://green-api.com/en/docs/api/contacts/AddContact/ | +| `editContact` | same | https://green-api.com/en/docs/api/contacts/EditContact/ | +| `deleteContact` | `chatId` | https://green-api.com/en/docs/api/contacts/DeleteContact/ | + +```python +greenAPI.contacts.addContact("79876543210@c.us", "John", lastName="Doe") +``` + +All have `*Async` variants. diff --git a/skills/references/device.md b/skills/references/device.md new file mode 100644 index 0000000..3412954 --- /dev/null +++ b/skills/references/device.md @@ -0,0 +1,16 @@ +# Device (`greenAPI.device`) + +Class: `Device` in `tools/device.py`. + +## `getDeviceInfo` + +Docs: https://green-api.com/en/docs/api/phone/GetDeviceInfo/ + +**Deprecated** in both SDK docstring and docs archive. Prefer account / state methods +for operational checks. + +```python +greenAPI.device.getDeviceInfo() +``` + +No async twin in current SDK source. diff --git a/skills/references/groups.md b/skills/references/groups.md new file mode 100644 index 0000000..068543c --- /dev/null +++ b/skills/references/groups.md @@ -0,0 +1,42 @@ +# Groups (`greenAPI.groups`) + +Class: `Groups` in `tools/groups.py`. +Index: https://green-api.com/en/docs/api/groups/ + +Group chat IDs end with `@g.us` and are **returned by the API** — do not invent them. +Docs: https://green-api.com/en/docs/api/chat-id/ + +## `createGroup` + +Docs: https://green-api.com/en/docs/api/groups/CreateGroup/ + +| Param | Required | Notes | +| --- | --- | --- | +| `groupName` | yes | max 100 chars | +| `chatIds` | yes | list of participant `@c.us` ids | + +Response: `created`, `chatId`, `groupInviteLink`. + +**Rate:** create no more than ~1 group per 5 minutes. Numbers without WhatsApp can cause +errors or risk blocks. + +```python +r = greenAPI.groups.createGroup("My group", ["79876543210@c.us"]) +group_id = r.data["chatId"] +``` + +## Other methods + +| Method | Required params | Docs | +| --- | --- | --- | +| `updateGroupName` | `groupId`, `groupName` | https://green-api.com/en/docs/api/groups/UpdateGroupName/ | +| `getGroupData` | `groupId` | https://green-api.com/en/docs/api/groups/GetGroupData/ | +| `addGroupParticipant` | `groupId`, `participantChatId` | https://green-api.com/en/docs/api/groups/AddGroupParticipant/ | +| `removeGroupParticipant` | `groupId`, `participantChatId` | https://green-api.com/en/docs/api/groups/RemoveGroupParticipant/ | +| `setGroupAdmin` | `groupId`, `participantChatId` | https://green-api.com/en/docs/api/groups/SetGroupAdmin/ | +| `removeAdmin` | `groupId`, `participantChatId` | https://green-api.com/en/docs/api/groups/RemoveAdmin/ | +| `setGroupPicture` | `groupId`, `path` (local file) | https://green-api.com/en/docs/api/groups/SetGroupPicture/ | +| `leaveGroup` | `groupId` | https://green-api.com/en/docs/api/groups/LeaveGroup/ | +| `updateGroupSettings` | `groupId`, optional booleans `allowParticipantsEditGroupSettings`, `allowParticipantsSendMessages` | https://green-api.com/en/docs/api/groups/UpdateGroupSettings/ | + +All methods have `*Async` variants. diff --git a/skills/references/inventory.md b/skills/references/inventory.md new file mode 100644 index 0000000..8bf268c --- /dev/null +++ b/skills/references/inventory.md @@ -0,0 +1,194 @@ +# SDK method inventory + +Source of names/signatures: `whatsapp_api_client_python/` in package +`whatsapp-api-client-python`. Every entry below was taken from the Python source. +Async twins (`methodAsync`) exist where noted; signatures match the sync form. + +Official semantics: https://green-api.com/en/docs/api/ + +## Clients (`API.py`) + +| Class | Init | Notes | +| --- | --- | --- | +| `GreenApi` / `GreenAPI` | `(idInstance, apiTokenInstance, debug_mode=False, raise_errors=False, host=..., media=..., host_timeout=180, media_timeout=10800)` | Main client | +| `GreenApiPartner` | `(partnerToken, email=None, host=...)` | Partner API; exposes `.partner` | +| `GreenAPIError` | Exception | Raised when `raise_errors=True` | + +Response: `response.Response` → `.code`, `.data`, `.error`. + +## `account` → `Account` + +| Method | Params | Docs | +| --- | --- | --- | +| `getSettings` | — | https://green-api.com/en/docs/api/account/GetSettings/ | +| `getWaSettings` | — | https://green-api.com/en/docs/api/account/GetWaSettings/ | +| `setSettings` | `requestBody: Dict` | https://green-api.com/en/docs/api/account/SetSettings/ | +| `getStateInstance` | — | https://green-api.com/en/docs/api/account/GetStateInstance/ | +| `getStatusInstance` | — | https://green-api.com/en/docs/api/account/GetStatusInstance/ | +| `reboot` | — | https://green-api.com/en/docs/api/account/Reboot/ | +| `logout` | — | https://green-api.com/en/docs/api/account/Logout/ | +| `qr` | — | https://green-api.com/en/docs/api/account/QR/ | +| `setProfilePicture` | `path: str` | https://green-api.com/en/docs/api/account/SetProfilePicture/ | +| `getAuthorizationCode` | `phoneNumber: int` | https://green-api.com/en/docs/api/account/GetAuthorizationCode/ | +| `getStateInstanceHistory` | `count: Optional[int]=None` | https://green-api.com/en/docs/api/account/GetStateInstanceHistory/ | +| `updateApiToken` | — | https://green-api.com/en/docs/api/account/UpdateApiToken/ | + +Async: `getSettingsAsync`, `getWaSettingsAsync`, `setSettingsAsync`, `getStateInstanceAsync`, `rebootAsync`, `logoutAsync`, `qrAsync`, `setProfilePictureAsync`, `getAuthorizationCodeAsync`, `getStateInstanceHistoryAsync`, `updateApiTokenAsync`. +No async for `getStatusInstance` in current source. + +## `sending` → `Sending` + +| Method | Params | Docs | Notes | +| --- | --- | --- | --- | +| `sendMessage` | `chatId, message, quotedMessageId=None, archiveChat=None, linkPreview=None, typingTime=None, typePreview=None, customPreview=None` | https://green-api.com/en/docs/api/sending/SendMessage/ | | +| `sendButtons` | `chatId, message, buttons, footer=None, quotedMessageId=None, archiveChat=None` | https://green-api.com/en/docs/api/sending/SendButtons/ | **Deprecated** → interactive buttons | +| `sendTemplateButtons` | `chatId, message, templateButtons, footer=None, quotedMessageId=None, archiveChat=None` | https://green-api.com/en/docs/api/sending/SendTemplateButtons/ | **Deprecated** | +| `sendListMessage` | `chatId, message, buttonText, sections, title=None, footer=None, quotedMessageId=None, archiveChat=None` | https://green-api.com/en/docs/api/sending/SendListMessage/ | **Deprecated** | +| `sendFileByUpload` | `chatId, path, fileName=None, caption=None, quotedMessageId=None, typingTime=None, typingType=None` | https://green-api.com/en/docs/api/sending/SendFileByUpload/ | media host | +| `sendFileByUrl` | `chatId, urlFile, fileName, caption=None, quotedMessageId=None, archiveChat=None, typingTime=None, typingType=None` | https://green-api.com/en/docs/api/sending/SendFileByUrl/ | | +| `uploadFile` | `path: str` | https://green-api.com/en/docs/api/sending/UploadFile/ | media host | +| `sendLocation` | `chatId, latitude, longitude, nameLocation=None, address=None, quotedMessageId=None, typingTime=None` | https://green-api.com/en/docs/api/sending/SendLocation/ | | +| `sendContact` | `chatId, contact: Dict, quotedMessageId=None, typingTime=None` | https://green-api.com/en/docs/api/sending/SendContact/ | | +| `sendLink` | `chatId, urlLink, quotedMessageId=None` | https://green-api.com/en/docs/api/sending/SendLink/ | **Deprecated** → `sendMessage` | +| `forwardMessages` | `chatId, chatIdFrom, messages: List[str], typingTime=None` | https://green-api.com/en/docs/api/sending/ForwardMessages/ | | +| `sendPoll` | `chatId, message, options: List[Dict], multipleAnswers=None, quotedMessageId=None, typingTime=None` | https://green-api.com/en/docs/api/sending/SendPoll/ | | +| `sendInteractiveButtons` | `chatId, body, buttons, header=None, footer=None, typingTime=None` | https://green-api.com/en/docs/api/sending/SendInteractiveButtons/ | | +| `sendInteractiveButtonsReply` | `chatId, body, buttons, header=None, footer=None, typingTime=None` | https://green-api.com/en/docs/api/sending/SendInteractiveButtonsReply/ | | + +Async for non-deprecated (and most others): `sendMessageAsync`, `sendFileByUploadAsync`, `sendFileByUrlAsync`, `uploadFileAsync`, `sendLocationAsync`, `sendContactAsync`, `forwardMessagesAsync`, `sendPollAsync`, `sendInteractiveButtonsAsync`, `sendInteractiveButtonsReplyAsync`. +No async variants for `sendButtons`, `sendTemplateButtons`, `sendListMessage`, `sendLink` in current source. + +## `receiving` → `Receiving` + +| Method | Params | Docs | +| --- | --- | --- | +| `receiveNotification` | `receiveTimeout: Optional[int]=None` | https://green-api.com/en/docs/api/receiving/technology-http-api/ReceiveNotification/ | +| `deleteNotification` | `receiptId: int` | https://green-api.com/en/docs/api/receiving/technology-http-api/DeleteNotification/ | +| `downloadFile` | `chatId, idMessage` | https://green-api.com/en/docs/api/receiving/files/DownloadFile/ | + +Async: `receiveNotificationAsync`, `deleteNotificationAsync`, `downloadFileAsync`. + +## `webhooks` → `Webhooks` + +| Method | Params | Notes | +| --- | --- | --- | +| `startReceivingNotifications` | `onEvent: Callable[[str, dict], Any]` | Polling loop; blocks | +| `startReceivingNotificationsAsync` | `onEvent` | Async polling | +| `stopReceivingNotifications` | — | Stop loop | +| `stopReceivingNotificationsAsync` | — | | +| `started` (property) | — | **Deprecated** | +| `job` | `onEvent` | **Deprecated** | + +## `groups` → `Groups` + +| Method | Params | Docs | +| --- | --- | --- | +| `createGroup` | `groupName, chatIds: List[str]` | https://green-api.com/en/docs/api/groups/CreateGroup/ | +| `updateGroupName` | `groupId, groupName` | https://green-api.com/en/docs/api/groups/UpdateGroupName/ | +| `getGroupData` | `groupId` | https://green-api.com/en/docs/api/groups/GetGroupData/ | +| `addGroupParticipant` | `groupId, participantChatId` | https://green-api.com/en/docs/api/groups/AddGroupParticipant/ | +| `removeGroupParticipant` | `groupId, participantChatId` | https://green-api.com/en/docs/api/groups/RemoveGroupParticipant/ | +| `setGroupAdmin` | `groupId, participantChatId` | https://green-api.com/en/docs/api/groups/SetGroupAdmin/ | +| `removeAdmin` | `groupId, participantChatId` | https://green-api.com/en/docs/api/groups/RemoveAdmin/ | +| `setGroupPicture` | `groupId, path` | https://green-api.com/en/docs/api/groups/SetGroupPicture/ | +| `leaveGroup` | `groupId` | https://green-api.com/en/docs/api/groups/LeaveGroup/ | +| `updateGroupSettings` | `groupId, allowParticipantsEditGroupSettings=None, allowParticipantsSendMessages=None` | https://green-api.com/en/docs/api/groups/UpdateGroupSettings/ | + +All have `*Async` twins. + +## `journals` → `Journals` + +| Method | Params | Docs | +| --- | --- | --- | +| `getChatHistory` | `chatId, count=None` | https://green-api.com/en/docs/api/journals/GetChatHistory/ | +| `getMessage` | `chatId, idMessage` | https://green-api.com/en/docs/api/journals/GetMessage/ | +| `lastIncomingMessages` | `minutes=None` | https://green-api.com/en/docs/api/journals/LastIncomingMessages/ | +| `lastOutgoingMessages` | `minutes=None` | https://green-api.com/en/docs/api/journals/LastOutgoingMessages/ | +| `lastIncomingCalls` | `minutes=None` | https://green-api.com/en/docs/api/journals/LastIncomingCalls/ | +| `lastOutgoingCalls` | `minutes=None` | https://green-api.com/en/docs/api/journals/LastOutgoingCalls/ | + +All have `*Async` twins. + +## `queues` → `Queues` + +| Method | Params | Docs | +| --- | --- | --- | +| `showMessagesQueue` | — | https://green-api.com/en/docs/api/queues/ShowMessagesQueue/ | +| `clearMessagesQueue` | — | https://green-api.com/en/docs/api/queues/ClearMessagesQueue/ | +| `getMessagesCount` | — | https://green-api.com/en/docs/api/queues/GetMessagesCount/ | +| `getWebhooksCount` | — | https://green-api.com/en/docs/api/queues/GetWebhooksCount/ | +| `clearWebhooksQueue` | — | https://green-api.com/en/docs/api/queues/ClearWebhooksQueue/ | + +All have `*Async` twins. + +## `serviceMethods` → `ServiceMethods` + +| Method | Params | Docs | +| --- | --- | --- | +| `checkWhatsapp` | `phoneNumber=None, chatId=None, force=None` | https://green-api.com/en/docs/api/service/CheckWhatsapp/ | +| `getAvatar` | `chatId` | https://green-api.com/en/docs/api/service/GetAvatar/ | +| `getContacts` | `group=None, count=None` | https://green-api.com/en/docs/api/service/GetContacts/ | +| `getContactInfo` | `chatId` | https://green-api.com/en/docs/api/service/GetContactInfo/ | +| `deleteMessage` | `chatId, idMessage, onlySenderDelete=None` | https://green-api.com/en/docs/api/service/deleteMessage/ | +| `editMessage` | `chatId, idMessage, message` | https://green-api.com/en/docs/api/service/editMessage/ | +| `archiveChat` | `chatId` | https://green-api.com/en/docs/api/service/archiveChat/ | +| `unarchiveChat` | `chatId` | https://green-api.com/en/docs/api/service/unarchiveChat/ | +| `setDisappearingChat` | `chatId, ephemeralExpiration=None` | https://green-api.com/en/docs/api/service/SetDisappearingChat/ | +| `sendTyping` | `chatId, typingTime=None, typingType=None` | https://green-api.com/en/docs/api/service/SendTyping/ | +| `getChats` | `count=None` | https://green-api.com/en/docs/api/service/GetChats/ | + +All have `*Async` twins. + +## `marking` → `Marking` + +| Method | Params | Docs | +| --- | --- | --- | +| `readChat` | `chatId, idMessage=None` | https://green-api.com/en/docs/api/marks/ReadChat/ | + +Async: `readChatAsync`. + +## `contacts` → `Contacts` + +| Method | Params | Docs | +| --- | --- | --- | +| `addContact` | `chatId, firstName, lastName=None, saveInAddressbook=True` | https://green-api.com/en/docs/api/contacts/AddContact/ | +| `editContact` | `chatId, firstName, lastName=None, saveInAddressbook=True` | https://green-api.com/en/docs/api/contacts/EditContact/ | +| `deleteContact` | `chatId` | https://green-api.com/en/docs/api/contacts/DeleteContact/ | + +All have `*Async` twins. + +## `statuses` → `Statuses` + +| Method | Params | Docs | +| --- | --- | --- | +| `sendTextStatus` | `message, backgroundColor=None, font=None, participants=None` | https://green-api.com/en/docs/api/statuses/SendTextStatus/ | +| `sendVoiceStatus` | `urlFile, fileName, backgroundColor=None, participants=None` | https://green-api.com/en/docs/api/statuses/SendVoiceStatus/ | +| `sendMediaStatus` | `urlFile, fileName, caption=None, participants=None` | https://green-api.com/en/docs/api/statuses/SendMediaStatus/ | +| `deleteStatus` | `idMessage` | https://green-api.com/en/docs/api/statuses/DeleteStatus/ | +| `getStatusStatistic` | `idMessage` | https://green-api.com/en/docs/api/statuses/GetStatusStatistic/ | +| `getIncomingStatuses` | `minutes=None` | https://green-api.com/en/docs/api/statuses/GetIncomingStatuses/ | +| `getOutgoingStatuses` | `minutes=None` | https://green-api.com/en/docs/api/statuses/GetOutgoingStatuses/ | + +All have `*Async` twins. + +## `device` → `Device` + +| Method | Params | Docs | Notes | +| --- | --- | --- | --- | +| `getDeviceInfo` | — | https://green-api.com/en/docs/api/phone/GetDeviceInfo/ | **Deprecated** | + +No async twin in current source. + +## `partner` → `Partner` (on `GreenApiPartner` only) + +| Method | Params | Docs | +| --- | --- | --- | +| `getInstances` | — | https://green-api.com/en/docs/partners/getInstances/ | +| `createInstance` | `requestBody: Dict` | https://green-api.com/en/docs/partners/createInstance/ | +| `deleteInstanceAccount` | `idInstance: int` | https://green-api.com/en/docs/partners/deleteInstanceAccount/ | + +All have `*Async` twins. + +## Not in this SDK (do not invent) + +Examples of API areas that may exist in docs but are **not** wrapped here unless listed above: catalogs product methods, websocket QR scan, etc. Check inventory before coding. diff --git a/skills/references/journals.md b/skills/references/journals.md new file mode 100644 index 0000000..830cd2c --- /dev/null +++ b/skills/references/journals.md @@ -0,0 +1,22 @@ +# Journals (`greenAPI.journals`) + +Class: `Journals` in `tools/journals.py`. +Index: https://green-api.com/en/docs/api/journals/ + +| Method | Params | Docs | +| --- | --- | --- | +| `getChatHistory` | `chatId`, optional `count` | https://green-api.com/en/docs/api/journals/GetChatHistory/ | +| `getMessage` | `chatId`, `idMessage` | https://green-api.com/en/docs/api/journals/GetMessage/ | +| `lastIncomingMessages` | optional `minutes` | https://green-api.com/en/docs/api/journals/LastIncomingMessages/ | +| `lastOutgoingMessages` | optional `minutes` | https://green-api.com/en/docs/api/journals/LastOutgoingMessages/ | +| `lastIncomingCalls` | optional `minutes` | https://green-api.com/en/docs/api/journals/LastIncomingCalls/ | +| `lastOutgoingCalls` | optional `minutes` | https://green-api.com/en/docs/api/journals/LastOutgoingCalls/ | + +```python +history = greenAPI.journals.getChatHistory("79876543210@c.us", count=50) +msg = greenAPI.journals.getMessage("79876543210@c.us", id_message) +incoming = greenAPI.journals.lastIncomingMessages(minutes=1440) +``` + +Use `getMessage` to verify a message exists before quoting (`quotedMessageId`). +All methods have `*Async` variants. diff --git a/skills/references/marking.md b/skills/references/marking.md new file mode 100644 index 0000000..bc3f3d2 --- /dev/null +++ b/skills/references/marking.md @@ -0,0 +1,19 @@ +# Marking (`greenAPI.marking`) + +Class: `Marking` in `tools/marking.py`. + +## `readChat` + +Docs: https://green-api.com/en/docs/api/marks/ReadChat/ + +| Param | Required | Notes | +| --- | --- | --- | +| `chatId` | yes | | +| `idMessage` | no | if omitted, marks chat as read per API rules | + +```python +greenAPI.marking.readChat("79876543210@c.us") +greenAPI.marking.readChat("79876543210@c.us", idMessage="3EB0...") +``` + +Async: `readChatAsync`. diff --git a/skills/references/partner.md b/skills/references/partner.md new file mode 100644 index 0000000..e19b860 --- /dev/null +++ b/skills/references/partner.md @@ -0,0 +1,25 @@ +# Partner API (`GreenApiPartner`) + +Class: `Partner` in `tools/partner.py`, attached only to `API.GreenApiPartner`. +Docs base: https://green-api.com/en/docs/partners/ + +```python +from whatsapp_api_client_python import API + +partner = API.GreenApiPartner(partnerToken="YOUR_PARTNER_TOKEN") +``` + +| Method | Params | Docs | +| --- | --- | --- | +| `getInstances` | — | https://green-api.com/en/docs/partners/getInstances/ | +| `createInstance` | `requestBody: Dict` | https://green-api.com/en/docs/partners/createInstance/ | +| `deleteInstanceAccount` | `idInstance: int` | https://green-api.com/en/docs/partners/deleteInstanceAccount/ | + +```python +instances = partner.partner.getInstances() +created = partner.partner.createInstance({"...": "..."}) # fields per partner docs +partner.partner.deleteInstanceAccount(1101000001) +``` + +Do **not** call `greenAPI.partner` on a normal `GreenAPI` client — the attribute is not +created there. diff --git a/skills/references/queues.md b/skills/references/queues.md new file mode 100644 index 0000000..6e48c77 --- /dev/null +++ b/skills/references/queues.md @@ -0,0 +1,17 @@ +# Queues (`greenAPI.queues`) + +Class: `Queues` in `tools/queues.py`. +Index: https://green-api.com/en/docs/api/queues/ + +| Method | HTTP (SDK) | Docs | +| --- | --- | --- | +| `showMessagesQueue` | GET | https://green-api.com/en/docs/api/queues/ShowMessagesQueue/ | +| `clearMessagesQueue` | GET | https://green-api.com/en/docs/api/queues/ClearMessagesQueue/ | +| `getMessagesCount` | GET | https://green-api.com/en/docs/api/queues/GetMessagesCount/ | +| `getWebhooksCount` | GET | https://green-api.com/en/docs/api/queues/GetWebhooksCount/ | +| `clearWebhooksQueue` | DELETE | https://green-api.com/en/docs/api/queues/ClearWebhooksQueue/ | + +No request body parameters. All have `*Async` variants. + +Outgoing messages sit in the send queue until sent (delay setting applies). +Incoming notifications sit in the webhook queue until deleted / delivered. diff --git a/skills/references/receiving.md b/skills/references/receiving.md new file mode 100644 index 0000000..4340c11 --- /dev/null +++ b/skills/references/receiving.md @@ -0,0 +1,130 @@ +# Receiving notifications + +Index: https://green-api.com/en/docs/api/receiving/ + +Two technologies: + +1. **HTTP API polling** — `receiveNotification` + `deleteNotification` (this SDK helps). +2. **Webhook Endpoint** — GREEN-API POSTs to your public URL (configure via `setSettings`; + implement the HTTP server yourself). + +They are alternatives for the same instance: if `webhookUrl` is set, polling returns an +error that a custom webhook URL is configured. + +## `receiving.receiveNotification` + +Docs: https://green-api.com/en/docs/api/receiving/technology-http-api/ReceiveNotification/ + +| Param | Required | Notes | +| --- | --- | --- | +| `receiveTimeout` | no | 5–60 seconds; default 5 | + +Waits up to timeout for one notification. Empty queue → empty/`null` body. + +Success shape: + +```json +{ + "receiptId": 1234567, + "body": { + "typeWebhook": "incomingMessageReceived", + "instanceData": {}, + "timestamp": 1588091580, + "idMessage": "...", + "senderData": { "chatId": "...", "sender": "...", "senderName": "..." }, + "messageData": { "typeMessage": "textMessage", "textMessageData": { "textMessage": "..." } } + } +} +``` + +## `receiving.deleteNotification` + +Docs: https://green-api.com/en/docs/api/receiving/technology-http-api/DeleteNotification/ + +Required: `receiptId` (int) from the previous receive. **Must** call after processing, +or the queue will not advance. + +## `receiving.downloadFile` + +Docs: https://green-api.com/en/docs/api/receiving/files/DownloadFile/ + +Required: `chatId`, `idMessage`. Downloads media for a message the system knows about. + +## `webhooks.startReceivingNotifications` + +SDK helper (not a REST method). Implements the recommended poll loop: + +1. `receiveNotification` +2. if data: call `onEvent(typeWebhook, body)` +3. `deleteNotification(receiptId)` +4. repeat until `stopReceivingNotifications` or Ctrl+C + +```python +def on_event(type_webhook: str, body: dict) -> None: + if type_webhook == "incomingMessageReceived": + ... + +greenAPI.webhooks.startReceivingNotifications(on_event) +``` + +Async: `await greenAPI.webhooks.startReceivingNotificationsAsync(on_event)`. + +Deprecated: `webhooks.started`, `webhooks.job`. + +## Webhook endpoint (no SDK server) + +Docs: https://green-api.com/en/docs/api/receiving/technology-webhook-endpoint/ + +```python +greenAPI.account.setSettings({ + "webhookUrl": "https://example.com/green-api/webhook", + "webhookUrlToken": "Bearer secret", + "incomingWebhook": "yes", + "outgoingWebhook": "yes", + "outgoingAPIMessageWebhook": "yes", + "stateWebhook": "yes", + "incomingCallWebhook": "yes", +}) +``` + +- Endpoint must be public and answer **200**. +- Retries ~every 1 minute; delivery guaranteed **24 hours**. +- If `webhookUrlToken` set, expect `Authorization` header (`Bearer` default, or `Basic`). +- To go back to polling: set `webhookUrl` to `""`. + +## Notification types (`typeWebhook`) + +Docs: https://green-api.com/en/docs/api/receiving/notifications-format/type-webhook/ + +| typeWebhook | Meaning | +| --- | --- | +| `incomingMessageReceived` | Incoming message/file | +| `outgoingMessageReceived` | Message sent from phone | +| `outgoingAPIMessageReceived` | Message sent via API | +| `outgoingMessageStatus` | Delivery/read status | +| `stateInstanceChanged` | Auth state change | +| `statusInstanceChanged` | Socket status | +| `deviceInfo` | Device/battery (archive / may be off) | +| `incomingCall` / `outgoingCall` | Calls | +| `incomingBlock` | Block events | +| `quotaExceeded` | Developer plan limits | + +Enable categories via `setSettings` flags: `incomingWebhook`, `outgoingWebhook`, +`outgoingMessageWebhook`, `outgoingAPIMessageWebhook`, `stateWebhook`, +`incomingCallWebhook`, `pollMessageWebhook`, `editedMessageWebhook`, +`deletedMessageWebhook`, etc. +Docs: https://green-api.com/en/docs/api/account/SetSettings/ + +Message payload formats: https://green-api.com/en/docs/api/receiving/notifications-format/ + +### Extracting text from `incomingMessageReceived` + +```python +md = body["messageData"] +t = md.get("typeMessage") +if t == "textMessage": + text = md["textMessageData"]["textMessage"] +elif t == "extendedTextMessage": + text = md["extendedTextMessageData"]["text"] +# media types: imageMessage, videoMessage, documentMessage, ... see docs +``` diff --git a/skills/references/sending.md b/skills/references/sending.md new file mode 100644 index 0000000..a21b6cf --- /dev/null +++ b/skills/references/sending.md @@ -0,0 +1,123 @@ +# Sending (`greenAPI.sending`) + +Class: `Sending` in `tools/sending.py`. +Index: https://green-api.com/en/docs/api/sending/ + +All send methods enqueue messages. Queue retention **24 hours**. Rate controlled by +`delaySendMessagesMilliseconds` — https://green-api.com/en/docs/api/send-messages-delay/ + +Typical success body: `{ "idMessage": "..." }` (upload also returns `urlFile`). + +## `sendMessage` + +Docs: https://green-api.com/en/docs/api/sending/SendMessage/ + +| Param | Required | Notes | +| --- | --- | --- | +| `chatId` | yes | `@c.us` / `@g.us` | +| `message` | yes | max 20000 chars, UTF-8 | +| `quotedMessageId` | no | same chat only | +| `linkPreview` | no | bool; default on server | +| `typePreview` | no | `large` / `small` | +| `customPreview` | no | object: title, description, link, urlFile, jpegThumbnail | +| `typingTime` | no | 1000–20000 ms | +| `archiveChat` | no | SDK optional (if supported by account) | + +```python +greenAPI.sending.sendMessage("79876543210@c.us", "Hello") +await greenAPI.sending.sendMessageAsync("79876543210@c.us", "Hello") +``` + +## `sendFileByUrl` + +Docs: https://green-api.com/en/docs/api/sending/SendFileByUrl/ + +| Param | Required | Notes | +| --- | --- | --- | +| `chatId` | yes | | +| `urlFile` | yes | direct file URL, `http(s)://` | +| `fileName` | yes | **with extension** | +| `caption` | no | max 1024 | +| `quotedMessageId` | no | | +| `typingTime` / `typingType` | no | `typingType="recording"` for audio | +| `archiveChat` | no | | + +Max file size **100 MB**. One file per request. + +## `sendFileByUpload` + +Docs: https://green-api.com/en/docs/api/sending/SendFileByUpload/ + +Uses **media** host. SDK: second arg is filesystem `path`. + +| Param | Required | Notes | +| --- | --- | --- | +| `chatId` | yes | | +| `path` | yes | local file path (SDK-only name; becomes form file) | +| `fileName` | no | with extension | +| `caption` | no | max 1024 | +| `quotedMessageId`, `typingTime`, `typingType` | no | | + +Response: `idMessage`, `urlFile` (link ~15 days). + +## `uploadFile` + +Docs: https://green-api.com/en/docs/api/sending/UploadFile/ + +Upload to cloud storage; then send with `sendFileByUrl` using returned URL. + +```python +up = greenAPI.sending.uploadFile("data/logo.jpg") +# then sendFileByUrl(..., urlFile=up.data["urlFile"], fileName="logo.jpg") +``` + +## `sendLocation` + +Docs: https://green-api.com/en/docs/api/sending/SendLocation/ + +Required: `chatId`, `latitude`, `longitude`. Optional: `nameLocation`, `address`, +`quotedMessageId`, `typingTime`. + +## `sendContact` + +Docs: https://green-api.com/en/docs/api/sending/SendContact/ + +Required: `chatId`, `contact` dict (fields per docs: phoneContact, firstName, …). + +## `forwardMessages` + +Docs: https://green-api.com/en/docs/api/sending/ForwardMessages/ + +Required: `chatId` (destination), `chatIdFrom` (source), `messages` (list of idMessage). + +## `sendPoll` + +Docs: https://green-api.com/en/docs/api/sending/SendPoll/ + +```python +greenAPI.sending.sendPoll( + "79876543210@c.us", + "Choose a color:", + [{"optionName": "Red"}, {"optionName": "Green"}, {"optionName": "Blue"}], + multipleAnswers=False, +) +``` + +## `sendInteractiveButtons` / `sendInteractiveButtonsReply` + +Docs: + +- https://green-api.com/en/docs/api/sending/SendInteractiveButtons/ +- https://green-api.com/en/docs/api/sending/SendInteractiveButtonsReply/ + +SDK params: `chatId`, `body`, `buttons`, optional `header`, `footer`, `typingTime`. +Prefer these over deprecated `sendButtons` / `sendTemplateButtons` / `sendListMessage`. + +## Deprecated (still in SDK) + +Do not use in new code unless the user explicitly asks: + +- `sendButtons` → use `sendInteractiveButtons` +- `sendTemplateButtons` → use `sendInteractiveButtonsReply` +- `sendListMessage` → use `sendMessage` / interactive methods +- `sendLink` → use `sendMessage` with `linkPreview` diff --git a/skills/references/service-methods.md b/skills/references/service-methods.md new file mode 100644 index 0000000..b724e28 --- /dev/null +++ b/skills/references/service-methods.md @@ -0,0 +1,50 @@ +# Service methods (`greenAPI.serviceMethods`) + +Class: `ServiceMethods` in `tools/serviceMethods.py`. +Attribute name is **`serviceMethods`** (camelCase), not `service`. +Index: https://green-api.com/en/docs/api/service/ + +## `checkWhatsapp` + +Docs: https://green-api.com/en/docs/api/service/CheckWhatsapp/ + +Pass **either** `chatId` **or** `phoneNumber` (not both). Prefer `chatId`. + +| Param | Notes | +| --- | --- | +| `chatId` | e.g. `79001234567@c.us` or `@lid` | +| `phoneNumber` | int, 11–16 digits; deprecated but still in SDK | +| `force` | bool; refresh from WhatsApp, not cache | + +Response includes `existsWhatsapp`, `chatId`, `fromCache`. + +```python +greenAPI.serviceMethods.checkWhatsapp(chatId="79876543210@c.us") +``` + +## Contacts list / info / avatar + +| Method | Params | Docs | +| --- | --- | --- | +| `getAvatar` | `chatId` | https://green-api.com/en/docs/api/service/GetAvatar/ | +| `getContacts` | optional `group`, `count` (query) | https://green-api.com/en/docs/api/service/GetContacts/ | +| `getContactInfo` | `chatId` | https://green-api.com/en/docs/api/service/GetContactInfo/ | +| `getChats` | optional `count` | https://green-api.com/en/docs/api/service/GetChats/ | + +## Messages + +| Method | Params | Docs | +| --- | --- | --- | +| `deleteMessage` | `chatId`, `idMessage`, optional `onlySenderDelete` | https://green-api.com/en/docs/api/service/deleteMessage/ | +| `editMessage` | `chatId`, `idMessage`, `message` | https://green-api.com/en/docs/api/service/editMessage/ | + +## Chats + +| Method | Params | Docs | +| --- | --- | --- | +| `archiveChat` | `chatId` | https://green-api.com/en/docs/api/service/archiveChat/ | +| `unarchiveChat` | `chatId` | https://green-api.com/en/docs/api/service/unarchiveChat/ | +| `setDisappearingChat` | `chatId`, optional `ephemeralExpiration` | https://green-api.com/en/docs/api/service/SetDisappearingChat/ | +| `sendTyping` | `chatId`, optional `typingTime`, `typingType` | https://green-api.com/en/docs/api/service/SendTyping/ | + +`typingType`: use `"recording"` for audio recording indicator (per SendTyping docs). diff --git a/skills/references/statuses.md b/skills/references/statuses.md new file mode 100644 index 0000000..b0601ba --- /dev/null +++ b/skills/references/statuses.md @@ -0,0 +1,22 @@ +# Statuses (`greenAPI.statuses`) + +Class: `Statuses` in `tools/statuses.py`. +Index: https://green-api.com/en/docs/api/statuses/ (β-version in docs) + +| Method | Params | Docs | +| --- | --- | --- | +| `sendTextStatus` | `message`, optional `backgroundColor`, `font`, `participants` | https://green-api.com/en/docs/api/statuses/SendTextStatus/ | +| `sendVoiceStatus` | `urlFile`, `fileName`, optional `backgroundColor`, `participants` | https://green-api.com/en/docs/api/statuses/SendVoiceStatus/ | +| `sendMediaStatus` | `urlFile`, `fileName`, optional `caption`, `participants` | https://green-api.com/en/docs/api/statuses/SendMediaStatus/ | +| `deleteStatus` | `idMessage` | https://green-api.com/en/docs/api/statuses/DeleteStatus/ | +| `getStatusStatistic` | `idMessage` | https://green-api.com/en/docs/api/statuses/GetStatusStatistic/ | +| `getIncomingStatuses` | optional `minutes` | https://green-api.com/en/docs/api/statuses/GetIncomingStatuses/ | +| `getOutgoingStatuses` | optional `minutes` | https://green-api.com/en/docs/api/statuses/GetOutgoingStatuses/ | + +```python +greenAPI.statuses.sendTextStatus("Hello status") +greenAPI.statuses.getOutgoingStatuses(minutes=1440) +``` + +All have `*Async` variants. Confirm parameter enums (fonts, colors) on the official page +before hardcoding values.