|
| 1 | + |
| 2 | + |
| 3 | +<p align="center"> |
| 4 | + <img src="https://img.shields.io/pypi/v/wams-sdk.svg?style=flat-square" alt="PyPI"> |
| 5 | + <img src="https://img.shields.io/github/workflow/status/yourusername/wams-python-sdk/Python%20package/main?style=flat-square" alt="CI"> |
| 6 | + <img src="https://img.shields.io/github/license/yourusername/wams-python-sdk?style=flat-square" alt="License"> |
| 7 | +</p> |
| 8 | + |
| 9 | +# Wams Python SDK |
| 10 | +## Contributing |
| 11 | + |
| 12 | +See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. |
| 13 | + |
| 14 | +Pure Python SDK for sending all types of WhatsApp messages via the Wams API. |
| 15 | + |
| 16 | +## Features |
| 17 | + |
| 18 | +- Send text messages |
| 19 | +- Send media (images, videos, audio, documents) |
| 20 | +- Send interactive messages (buttons, lists) |
| 21 | +- Send location |
| 22 | +- Send contact cards (vCard) |
| 23 | +- Send product messages |
| 24 | +- Send text to WhatsApp channels |
| 25 | +- Send stickers |
| 26 | +- Send polls |
| 27 | + |
| 28 | +## Installation |
| 29 | + |
| 30 | +```bash |
| 31 | +pip install requests |
| 32 | +# or |
| 33 | +pip install -r requirements.txt |
| 34 | +``` |
| 35 | + |
| 36 | +## Usage |
| 37 | + |
| 38 | +```python |
| 39 | +from wams_sdk import WamsClient |
| 40 | + |
| 41 | +client = WamsClient(api_key="YOUR_API_KEY", sender="YOUR_NUMBER") |
| 42 | + |
| 43 | +# Send a text message |
| 44 | +resp = client.send_text(number="RECIPIENT", message="Hello World!", footer="Sent via wams") |
| 45 | +print(resp) |
| 46 | + |
| 47 | +# Send an image |
| 48 | +resp = client.send_media(number="RECIPIENT", media_type="image", url_="https://example.com/image.jpg", caption="Check this image!", footer="Sent via wams") |
| 49 | +print(resp) |
| 50 | + |
| 51 | +# Send a button message |
| 52 | +buttons = [ |
| 53 | + {"type": "reply", "displayText": "Reply Button"}, |
| 54 | + {"type": "call", "displayText": "Call Button", "phoneNumber": "1234567890"}, |
| 55 | + {"type": "url", "displayText": "URL Button", "url": "https://google.com"}, |
| 56 | + {"type": "copy", "displayText": "Copy Button", "copyText": "123123"} |
| 57 | +] |
| 58 | +resp = client.send_button(number="RECIPIENT", message="Choose an option", button=buttons, image="https://example.com/image.jpg", footer="optional") |
| 59 | +print(resp) |
| 60 | + |
| 61 | +# Send a list message |
| 62 | +sections = [ |
| 63 | + { |
| 64 | + "title": "Main Options", |
| 65 | + "description": "Select a basic option to proceed.", |
| 66 | + "rows": [ |
| 67 | + {"title": "Option 1", "rowId": "id1", "description": "Description for option 1"}, |
| 68 | + {"title": "Option 2", "rowId": "id2", "description": "Description for option 2"} |
| 69 | + ] |
| 70 | + }, |
| 71 | + { |
| 72 | + "title": "Advanced Options", |
| 73 | + "description": "Explore advanced settings.", |
| 74 | + "rows": [ |
| 75 | + {"title": "Option 3", "rowId": "id3", "description": "Description for option 3"} |
| 76 | + ] |
| 77 | + } |
| 78 | +] |
| 79 | +resp = client.send_list(number="RECIPIENT", name="Message list", title="title list", buttontext="Menu", message="Hello, this is a list button message", sections=sections, image="https://example.com/image.jpg", footer="optional") |
| 80 | +print(resp) |
| 81 | + |
| 82 | +# Send location |
| 83 | +resp = client.send_location(number="RECIPIENT", latitude="24.121231", longitude="55.1121221") |
| 84 | +print(resp) |
| 85 | + |
| 86 | +# Send vCard |
| 87 | +resp = client.send_vcard(number="RECIPIENT", name="magd", phone="1234567890") |
| 88 | +print(resp) |
| 89 | + |
| 90 | +# Send product message |
| 91 | +resp = client.send_product(number="RECIPIENT", url_="https://wa.me/p/12345678901234567/RECIPIENT", message="Check out this item!") |
| 92 | +print(resp) |
| 93 | + |
| 94 | +# Send text to channel |
| 95 | +resp = client.send_text_channel(url_="https://whatsapp.com/channel/ABCDEF123456", message="Hello World", footer="Sent via wams") |
| 96 | +print(resp) |
| 97 | + |
| 98 | +# Send sticker |
| 99 | +resp = client.send_sticker(number="RECIPIENT", url_="https://example.com/image.jpg") |
| 100 | +print(resp) |
| 101 | + |
| 102 | +# Send poll |
| 103 | +resp = client.send_poll(number="RECIPIENT", name="What color do you like?", option=["red", "blue", "yellow"], countable="1") |
| 104 | +print(resp) |
| 105 | +``` |
| 106 | + |
| 107 | +## API Reference |
| 108 | + |
| 109 | +All methods return the JSON response from the Wams API. |
| 110 | + |
| 111 | +**Constructor** |
| 112 | + |
| 113 | + WamsClient(api_key: str, sender: str) |
| 114 | + |
| 115 | +**Methods** |
| 116 | + |
| 117 | +- `send_text(number, message, footer=None, msgid=None, full=None)` |
| 118 | +- `send_media(number, media_type, url_, caption=None, footer=None, msgid=None, full=None)` |
| 119 | +- `send_button(number, message, button, image, footer=None)` |
| 120 | +- `send_list(number, name, title, buttontext, message, sections, image, footer=None, msgid=None, full=None)` |
| 121 | +- `send_location(number, latitude, longitude, msgid=None, full=None)` |
| 122 | +- `send_vcard(number, name, phone, msgid=None, full=None)` |
| 123 | +- `send_product(number, url_, message=None, msgid=None, full=None)` |
| 124 | +- `send_text_channel(url_, message, footer=None, full=None)` |
| 125 | +- `send_sticker(number, url_, msgid=None, full=None)` |
| 126 | +- `send_poll(number, name, option, countable="1", msgid=None, full=None)` |
| 127 | + |
| 128 | +See [wams_sdk/example.py](wams_sdk/example.py) for full working examples. |
| 129 | + |
| 130 | +## License |
| 131 | + |
| 132 | +MIT |
0 commit comments