| Title: | Client for the 'WAservix' 'WhatsApp' API Gateway |
|---|---|
| Description: | Client for the 'WAservix' 'WhatsApp' API Gateway <https://tekservix.com/waservix/>, which sends 'WhatsApp' messages from your own number connected by QR code. Send texts, images, documents and locations to numbers and groups, check message status, edit, delete and resend messages, check whether a number uses 'WhatsApp', list contacts and groups, and verify incoming event notifications. A 'Tekservix' account with 'WAservix' and a device API key are required. |
| Authors: | Joseph Niyogushimwa [aut, cre], Tekservix [cph, fnd] |
| Maintainer: | Joseph Niyogushimwa <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.1 |
| Built: | 2026-12-04 20:10:58 UTC |
| Source: | https://github.com/cran/waservix |
Create a WAservix client
waservix_client( key = Sys.getenv("WASERVIX_API_KEY"), base_url = "https://tekservix.com/waservix/api" )waservix_client( key = Sys.getenv("WASERVIX_API_KEY"), base_url = "https://tekservix.com/waservix/api" )
key |
The device API key of your WhatsApp number (starts with |
base_url |
API base URL. Change it only for tests or a proxy. |
An object of class waservix_client, used by every other function.
client <- waservix_client("wpk_your_device_key")client <- waservix_client("wpk_your_device_key")
Delete a message for everyone
waservix_delete_message(client, message_id)waservix_delete_message(client, message_id)
client |
A client from |
message_id |
Message ID. |
The API confirmation.
## Not run: waservix_delete_message(waservix_client("wpk_your_device_key"), 5473) ## End(Not run)## Not run: waservix_delete_message(waservix_client("wpk_your_device_key"), 5473) ## End(Not run)
WhatsApp allows edits for about 15 minutes after sending.
waservix_edit_message(client, message_id, text)waservix_edit_message(client, message_id, text)
client |
A client from |
message_id |
Message ID. |
text |
The new text. |
The API confirmation.
## Not run: waservix_edit_message(waservix_client("wpk_your_device_key"), 5473, "Corrected text") ## End(Not run)## Not run: waservix_edit_message(waservix_client("wpk_your_device_key"), 5473, "Corrected text") ## End(Not run)
Get one contact
waservix_get_contact(client, phone)waservix_get_contact(client, phone)
client |
A client from |
phone |
Phone number in international format. |
The contact.
## Not run: waservix_get_contact(waservix_client("wpk_your_device_key"), "+250788123456") ## End(Not run)## Not run: waservix_get_contact(waservix_client("wpk_your_device_key"), "+250788123456") ## End(Not run)
Get a group's details
waservix_get_group_metadata(client, group_id)waservix_get_group_metadata(client, group_id)
client |
A client from |
group_id |
Group ID, ending in |
The group's name, participants and settings.
## Not run: waservix_get_group_metadata(waservix_client("wpk_your_device_key"), "[email protected]") ## End(Not run)## Not run: waservix_get_group_metadata(waservix_client("wpk_your_device_key"), "[email protected]") ## End(Not run)
Get a sent message's status
waservix_get_message_info(client, message_id)waservix_get_message_info(client, message_id)
client |
A client from |
message_id |
Message ID. |
The message and its status (queued, sent, delivered, read, played or failed).
## Not run: waservix_get_message_info(waservix_client("wpk_your_device_key"), 5473) ## End(Not run)## Not run: waservix_get_message_info(waservix_client("wpk_your_device_key"), 5473) ## End(Not run)
Get your number's connection status
waservix_get_status(client)waservix_get_status(client)
client |
A client from |
The connection status of the number behind the API key.
## Not run: waservix_get_status(waservix_client("wpk_your_device_key")) ## End(Not run)## Not run: waservix_get_status(waservix_client("wpk_your_device_key")) ## End(Not run)
List contacts
waservix_list_contacts(client)waservix_list_contacts(client)
client |
A client from |
A list of your number's contacts.
## Not run: waservix_list_contacts(waservix_client("wpk_your_device_key")) ## End(Not run)## Not run: waservix_list_contacts(waservix_client("wpk_your_device_key")) ## End(Not run)
List groups
waservix_list_groups(client)waservix_list_groups(client)
client |
A client from |
The groups your number is in; IDs end in @g.us.
## Not run: waservix_list_groups(waservix_client("wpk_your_device_key")) ## End(Not run)## Not run: waservix_list_groups(waservix_client("wpk_your_device_key")) ## End(Not run)
Check whether a number uses WhatsApp
waservix_on_whatsapp(client, phone)waservix_on_whatsapp(client, phone)
client |
A client from |
phone |
Phone number in international format. |
A list telling whether the number is on WhatsApp.
## Not run: waservix_on_whatsapp(waservix_client("wpk_your_device_key"), "+250788123456") ## End(Not run)## Not run: waservix_on_whatsapp(waservix_client("wpk_your_device_key"), "+250788123456") ## End(Not run)
Low-level access for endpoints that have no helper of their own.
waservix_request(client, method, path, body = NULL, query = NULL)waservix_request(client, method, path, body = NULL, query = NULL)
client |
A client from |
method |
HTTP method, e.g. |
path |
Path after the base URL, e.g. |
body |
Optional list sent as JSON. |
query |
Optional named list of query parameters. |
The data part of the API answer, as a list.
## Not run: client <- waservix_client("wpk_your_device_key") waservix_request(client, "GET", "/status") ## End(Not run)## Not run: client <- waservix_client("wpk_your_device_key") waservix_request(client, "GET", "/status") ## End(Not run)
Resend a failed message
waservix_resend_message(client, message_id)waservix_resend_message(client, message_id)
client |
A client from |
message_id |
Message ID. |
The new send attempt.
## Not run: waservix_resend_message(waservix_client("wpk_your_device_key"), 5473) ## End(Not run)## Not run: waservix_resend_message(waservix_client("wpk_your_device_key"), 5473) ## End(Not run)
Send a document
waservix_send_document(client, to, url, file_name = NULL, caption = NULL)waservix_send_document(client, to, url, file_name = NULL, caption = NULL)
client |
A client from |
to |
Phone number in international format, or a group ID. |
url |
Public URL of the file. |
file_name |
Optional file name shown to the recipient. |
caption |
Optional caption. |
A list with the queued message ID and status.
## Not run: waservix_send_document(waservix_client("wpk_your_device_key"), "+250788123456", "https://example.com/inv-1042.pdf", file_name = "Invoice-1042.pdf", caption = "Your invoice") ## End(Not run)## Not run: waservix_send_document(waservix_client("wpk_your_device_key"), "+250788123456", "https://example.com/inv-1042.pdf", file_name = "Invoice-1042.pdf", caption = "Your invoice") ## End(Not run)
Send an image
waservix_send_image(client, to, url, caption = NULL)waservix_send_image(client, to, url, caption = NULL)
client |
A client from |
to |
Phone number in international format, or a group ID. |
url |
Public URL of the image. |
caption |
Optional caption. |
A list with the queued message ID and status.
## Not run: waservix_send_image(waservix_client("wpk_your_device_key"), "+250788123456", "https://example.com/catalogue.jpg", caption = "New arrivals") ## End(Not run)## Not run: waservix_send_image(waservix_client("wpk_your_device_key"), "+250788123456", "https://example.com/catalogue.jpg", caption = "New arrivals") ## End(Not run)
Send a location pin
waservix_send_location(client, to, latitude, longitude, name = NULL)waservix_send_location(client, to, latitude, longitude, name = NULL)
client |
A client from |
to |
Phone number in international format, or a group ID. |
latitude, longitude
|
Coordinates in decimal degrees. |
name |
Optional place name. |
A list with the queued message ID and status.
## Not run: waservix_send_location(waservix_client("wpk_your_device_key"), "+250788123456", -1.9441, 30.0619, name = "Our shop") ## End(Not run)## Not run: waservix_send_location(waservix_client("wpk_your_device_key"), "+250788123456", -1.9441, 30.0619, name = "Our shop") ## End(Not run)
Sends to a number ("+250788123456") or a group ID (ending in @g.us).
Field names follow the API: text, imageUrl, videoUrl, audioUrl,
documentUrl, fileName, location, poll, replyTo, mentions,
viewOnce.
waservix_send_message(client, to, ...)waservix_send_message(client, to, ...)
client |
A client from |
to |
Phone number in international format, or a group ID. |
... |
Message fields, named as in the API. |
A list with the queued message ID and status.
## Not run: client <- waservix_client("wpk_your_device_key") waservix_send_message(client, "+250788123456", videoUrl = "https://example.com/demo.mp4", text = "Demo") ## End(Not run)## Not run: client <- waservix_client("wpk_your_device_key") waservix_send_message(client, "+250788123456", videoUrl = "https://example.com/demo.mp4", text = "Demo") ## End(Not run)
Send a text message
waservix_send_text(client, to, text)waservix_send_text(client, to, text)
client |
A client from |
to |
Phone number in international format, or a group ID. |
text |
The message text. |
A list with the queued message ID and status.
## Not run: waservix_send_text(waservix_client("wpk_your_device_key"), "+250788123456", "Your order #1042 has shipped.") ## End(Not run)## Not run: waservix_send_text(waservix_client("wpk_your_device_key"), "+250788123456", "Your order #1042 has shipped.") ## End(Not run)
Compares the X-Webhook-Signature header with your number's webhook
secret. The comparison takes the same time whether or not they match.
waservix_verify_webhook(signature, secret)waservix_verify_webhook(signature, secret)
signature |
Value of the |
secret |
Your number's webhook secret. |
TRUE when the header matches the secret, otherwise FALSE.
waservix_verify_webhook("my-secret", "my-secret") waservix_verify_webhook("wrong", "my-secret")waservix_verify_webhook("my-secret", "my-secret") waservix_verify_webhook("wrong", "my-secret")